/* 奶蛙幸存者 —— 独立选角色界面样式
 * 只负责 #select 这块界面，以及开始页上的「当前角色」入口。
 * 布局按舞台宽高切换：竖屏用上下两段，横屏（含伪横屏）用左右两栏。
 * JS 会在 #select 上挂 .is-wide / .is-short。
 */

/* ---------------- 开始页：当前角色入口 ---------------- */
.char-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 12px;
  padding: 8px 10px;
  text-align: left;
  font-family: inherit;
  color: #eaf3ea;
  background: linear-gradient(180deg, #1b2a23, #141d19);
  border: 1px solid #2f4438;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.char-chip:hover { border-color: #4a6b55; }
.char-chip:active { transform: translateY(1px); border-color: #5f8a6c; }
.char-chip img {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5));
}
.char-chip-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.char-chip-label { font-size: 9px; letter-spacing: .18em; color: #6f8a78; }
.char-chip-name { font-size: 15px; font-weight: 700; color: #c9f3a8; line-height: 1.2; }
.char-chip-meta { font-size: 10px; color: #8fa89b; }
.char-chip-edit {
  flex: 0 0 auto;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
  color: #9fe89a;
  background: #16211c;
  border: 1px solid #3d5546;
  border-radius: 8px;
}

/* ---------------- 选角界面 ---------------- */
.select-overlay {
  z-index: 40;
  padding: 6px;
  background:
    radial-gradient(80% 70% at 10% 0%, rgba(111, 208, 106, .16), transparent 60%),
    radial-gradient(70% 70% at 100% 100%, rgba(127, 180, 255, .12), transparent 60%),
    rgba(4, 9, 7, .92);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}
.select-overlay.is-open { animation: sel-fade .2s ease both; }

.select-shell {
  --accent: #7fe07a;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  width: min(460px, 100%);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
  text-align: left;
  background: linear-gradient(168deg, #22332b 0%, #17231d 48%, #101815 100%);
  border: 1px solid rgba(127, 224, 122, .22);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .72), inset 0 1px 0 rgba(255, 255, 255, .07);
  outline: none;
}
.select-shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -34%;
  right: -14%;
  width: 62%;
  aspect-ratio: 1;
  background: radial-gradient(circle, var(--accent) 0%, transparent 68%);
  opacity: .16;
  pointer-events: none;
  transition: background .35s ease;
}
.select-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 120%, rgba(0, 0, 0, .45), transparent 62%);
}

.select-overlay.is-open .select-shell {
  animation: sel-pop .34s cubic-bezier(.2, .9, .25, 1) both;
}
.select-overlay:not(.is-open):not(.hidden) .select-shell {
  opacity: 0;
  transform: scale(.97);
  transition: opacity .16s ease, transform .16s ease;
}

/* 头部 */
.sel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.sel-kicker {
  margin: 0 0 2px;
  font-size: 9px;
  letter-spacing: .3em;
  color: #6f8a78;
}
.sel-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 1px;
  color: #eaf3ea;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
}
.sel-title em { font-style: normal; color: var(--accent); }
.sel-back {
  flex: 0 0 auto;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: #b7c9bd;
  background: rgba(255, 255, 255, .03);
  border: 1px solid #3d5546;
  border-radius: 9px;
  cursor: pointer;
}
.sel-back:active { background: #1d2e25; }

/* 主体：竖屏 = 列表在上、详情在下 */
.sel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}
.sel-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-height: 0;
}
.rail-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 7px 3px 8px;
  text-align: center;
  font-family: inherit;
  color: inherit;
  background: linear-gradient(180deg, #1a2821, #131d18);
  border: 1px solid #2c4136;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .18s, background .18s, transform .18s, box-shadow .18s;
}
.rail-card:hover { border-color: #4a6b55; }
.rail-card.is-sel {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(47, 68, 56, .92), #16221c);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(127, 224, 122, .12), 0 8px 20px rgba(0, 0, 0, .35);
}
.rail-card.is-sel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--accent);
}
.rail-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
}
.rail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
}
.rail-meta { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.rail-name { font-size: 12px; font-weight: 700; line-height: 1.25; color: #d6efd2; }
.rail-tag { font-size: 8.5px; color: #8fa89b; white-space: nowrap; }
.rail-rec {
  display: none;
  position: absolute;
  top: 4px;
  right: 5px;
  padding: 1px 5px;
  font-size: 8px;
  font-weight: 700;
  color: #1d2a12;
  background: #cfe58a;
  border-radius: 99px;
}
.rail-check {
  display: none;
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border-radius: 50%;
}
.rail-check::after {
  content: "";
  width: 6px;
  height: 3px;
  margin-top: -1px;
  border-left: 1.8px solid #0d1a10;
  border-bottom: 1.8px solid #0d1a10;
  transform: rotate(-45deg);
}
.rail-card.is-sel .rail-check { display: flex; }

/* 详情 */
.sel-detail {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 0;
  padding: 2px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sel-portrait {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.portrait-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 88%;
  aspect-ratio: 1;
  transform: translate(-50%, -52%);
  background: radial-gradient(circle, var(--accent) 0%, transparent 66%);
  opacity: .26;
  filter: blur(5px);
  pointer-events: none;
  transition: background .35s ease;
}
.portrait-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 82%;
  aspect-ratio: 1;
  margin: -41% 0 0 -41%;
  border: 1px dashed rgba(255, 255, 255, .14);
  border-radius: 50%;
  animation: sel-spin 28s linear infinite;
  pointer-events: none;
}
.portrait-img-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, .55));
  animation: sel-float 4.4s ease-in-out infinite;
}
.portrait-img {
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  display: block;
}
.portrait-weapon {
  position: relative;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 9px;
  color: #cfe3d4;
  white-space: nowrap;
  background: rgba(8, 14, 11, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 99px;
}

.sel-info {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.sel-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.sel-name {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 1px;
  color: #f0f8ee;
}
.sel-tag {
  padding: 2px 8px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 99px;
  opacity: .9;
}
.sel-rec {
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 700;
  color: #1d2a12;
  background: #cfe58a;
  border-radius: 99px;
}
.sel-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #9fb6a7;
}
.sel-stats { display: grid; gap: 5px; }
.stat {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: #8fa89b;
}
.stat-label { white-space: nowrap; }
.stat-track {
  height: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, .08);
  border-radius: 99px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .4);
}
.stat-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  box-shadow: 0 0 8px var(--accent);
  transition: width .4s cubic-bezier(.2, .9, .25, 1);
}
.stat-val {
  font-weight: 700;
  text-align: right;
  color: #d9ead9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sel-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 2px 7px;
  font-size: 9.5px;
  color: #c5d8ca;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 99px;
  white-space: nowrap;
}
.chip i { margin-right: 4px; font-style: normal; color: #7f9a8a; }
.chip-gold {
  color: #ffd98a;
  background: rgba(255, 217, 138, .1);
  border-color: rgba(255, 217, 138, .35);
}

.sel-passive {
  padding: 7px 9px;
  background: linear-gradient(180deg, rgba(60, 48, 24, .55), rgba(34, 28, 16, .42));
  border: 1px solid rgba(232, 195, 106, .32);
  border-radius: 10px;
}
.sel-passive-kicker {
  display: block;
  font-size: 8px;
  letter-spacing: .18em;
  color: #c9a75c;
}
.sel-passive b {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  color: #ffd98a;
}
.sel-passive p {
  margin: 1px 0 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: #c5b48a;
}
.sel-tip {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: #9fb6a7;
}
.sel-tip b { color: #c9f3a8; font-weight: 700; }

.sel-detail.is-swap .sel-portrait,
.sel-detail.is-swap .sel-info { animation: sel-rise .3s ease backwards; }
.sel-detail.is-swap .sel-info { animation-delay: .04s; }

/* 底部 */
.sel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sel-keys {
  display: none;
  margin: 0;
  font-size: 10px;
  color: #6f8a78;
  white-space: nowrap;
}
.sel-keys kbd {
  display: inline-block;
  margin-right: 2px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 9.5px;
  color: #b7c9bd;
  background: #16211c;
  border: 1px solid #3d5546;
  border-radius: 4px;
}
.sel-go {
  flex: 1;
  width: auto;
  margin-left: auto;
  padding: 11px 18px;
  font-size: 15px;
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
}
.sel-go:active { transform: translateY(1px) scale(.995); }

/* ---------------- 横屏 / 宽屏：左右两栏 ---------------- */
.select-overlay.is-wide .select-shell {
  width: min(920px, 100%);
  height: min(620px, 100%);
  padding: 18px 20px;
  gap: 12px;
  border-radius: 22px;
}
.select-overlay.is-wide .sel-title { font-size: 25px; }
.select-overlay.is-wide .sel-back { padding: 8px 15px; font-size: 12px; }
.select-overlay.is-wide .sel-body {
  grid-template-columns: 206px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
}
.select-overlay.is-wide .sel-rail {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.select-overlay.is-wide .rail-card {
  grid-template-columns: 56px minmax(0, 1fr);
  justify-items: stretch;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
  border-radius: 13px;
}
.select-overlay.is-wide .rail-card.is-sel { transform: translateX(3px); }
.select-overlay.is-wide .rail-card.is-sel::before {
  left: 0;
  right: auto;
  top: 0;
  bottom: 0;
  width: 3px;
  height: auto;
}
.select-overlay.is-wide .rail-avatar { width: 56px; height: 56px; }
.select-overlay.is-wide .rail-meta { align-items: flex-start; gap: 2px; }
.select-overlay.is-wide .rail-name { font-size: 15px; }
.select-overlay.is-wide .rail-tag { font-size: 9.5px; }
.select-overlay.is-wide .rail-rec { display: inline-block; }
.select-overlay.is-wide .rail-check { right: 8px; bottom: 7px; width: 15px; height: 15px; }
.select-overlay.is-wide .sel-detail {
  grid-template-columns: minmax(140px, 33%) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  overflow: hidden;
}
.select-overlay.is-wide .portrait-img { max-height: 210px; }
.select-overlay.is-wide .portrait-weapon { margin-top: 6px; padding: 3px 10px; font-size: 10px; }
.select-overlay.is-wide .sel-info { gap: 9px; }
.select-overlay.is-wide .sel-name { font-size: 32px; }
.select-overlay.is-wide .sel-desc { font-size: 13px; }
.select-overlay.is-wide .sel-stats { gap: 7px; }
.select-overlay.is-wide .stat {
  grid-template-columns: 34px minmax(0, 1fr) 64px;
  gap: 8px;
  font-size: 10.5px;
}
.select-overlay.is-wide .stat-track { height: 6px; }
.select-overlay.is-wide .sel-chips { gap: 6px; }
.select-overlay.is-wide .chip { padding: 3px 8px; font-size: 10px; }
.select-overlay.is-wide .sel-passive { padding: 8px 11px; border-radius: 12px; }
.select-overlay.is-wide .sel-passive b { font-size: 13.5px; }
.select-overlay.is-wide .sel-passive p { font-size: 11px; }
.select-overlay.is-wide .sel-tip { font-size: 11px; }
.select-overlay.is-wide .sel-keys { display: block; }
.select-overlay.is-wide .sel-go {
  flex: 0 0 auto;
  min-width: 190px;
  padding: 11px 26px;
  font-size: 15px;
}

/* 矮屏（伪横屏手机、桌面小窗）：压紧一档，保证不用滚 */
.select-overlay.is-short .select-shell { padding: 12px 16px; gap: 8px; }
.select-overlay.is-short .sel-kicker { display: none; }
.select-overlay.is-short .sel-title { font-size: 20px; }
.select-overlay.is-short .sel-name { font-size: 26px; }
.select-overlay.is-short .sel-desc { font-size: 11.5px; }
.select-overlay.is-short .sel-info { gap: 6px; }
.select-overlay.is-short .sel-stats { gap: 4px; }
.select-overlay.is-short .stat { font-size: 10px; }
.select-overlay.is-short .stat-track { height: 5px; }
.select-overlay.is-short .sel-passive { padding: 6px 9px; }
.select-overlay.is-short .sel-passive p { font-size: 10px; line-height: 1.4; }
.select-overlay.is-short .sel-tip { display: none; }
.select-overlay.is-short .sel-keys { display: none; }
.select-overlay.is-short .sel-go { min-width: 0; padding: 9px 18px; font-size: 14px; }
.select-overlay.is-short .portrait-img { max-height: 168px; }
.select-overlay.is-short .sel-detail { overflow-y: auto; }
.select-overlay.is-short .sel-foot { gap: 8px; }

/* 极小屏：详情改成单列，免得左右挤成一团 */
@media (max-width: 359px) {
  .sel-detail { grid-template-columns: minmax(0, 1fr); }
  .sel-portrait { display: none; }
}

/* ---------------- 动画 ---------------- */
@keyframes sel-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sel-pop {
  from { opacity: 0; transform: translateY(12px) scale(.965); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sel-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sel-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes sel-spin {
  to { transform: rotate(360deg); }
}
.select-overlay.is-open .rail-card {
  animation: sel-rise .34s ease backwards;
  animation-delay: calc(60ms + var(--i, 0) * 45ms);
}

@media (prefers-reduced-motion: reduce) {
  .select-overlay,
  .select-overlay.is-open .select-shell,
  .select-overlay.is-open .rail-card,
  .sel-detail.is-swap .sel-portrait,
  .sel-detail.is-swap .sel-info,
  .portrait-img-wrap,
  .portrait-ring {
    animation: none !important;
  }
  .stat-fill { transition: none; }
}

/* 开始页压缩时，入口也跟着收紧（规模和原角色卡一致） */
body.fake-landscape .char-chip {
  margin-bottom: 6px;
  padding: 5px 8px;
  gap: 8px;
  border-radius: 10px;
}
body.fake-landscape .char-chip img { width: 34px; height: 34px; flex-basis: 34px; }
body.fake-landscape .char-chip-label { display: none; }
body.fake-landscape .char-chip-name { font-size: 12px; }
body.fake-landscape .char-chip-meta { font-size: 9px; }
body.fake-landscape .char-chip-edit { padding: 4px 7px; font-size: 10px; }

@media (max-height: 480px) {
  .char-chip { margin-bottom: 6px; padding: 5px 8px; }
  .char-chip img { width: 32px; height: 32px; flex-basis: 32px; }
  .char-chip-label { display: none; }
  .char-chip-name { font-size: 12px; }
  .char-chip-meta { font-size: 9px; }
}
