﻿/* 奶蛙幸存者 —— 独立选角色界面样式（v0.10.0 重做：参照 Brotato 式角色选择页）
 * 只负责 #select 这块界面。
 * JS 会在 #select 上挂 .is-wide / .is-short / .is-tiny，布局自己缩。
 * 结构：顶栏（返回 / 角色选择 / 邀请好友）→ 中间三块（角色详情 / 纪录 / 运行选项）→ 底部角色栏。
 */

/* ---------------- 整页 ---------------- */
.select-overlay {
  z-index: 40;
  padding: 0;
  color: #e9eef7;
  background:
    radial-gradient(90% 80% at 18% 8%, rgba(88, 104, 140, .28), transparent 62%),
    radial-gradient(80% 90% at 82% 92%, rgba(52, 66, 96, .30), transparent 64%),
    linear-gradient(180deg, #232838 0%, #1a1e2b 46%, #141722 100%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.select-overlay.hidden { display: none; }
.select-overlay.is-open { animation: sel-fade .18s ease both; }

@keyframes sel-fade { from { opacity: 0; } to { opacity: 1; } }

.select-shell {
  --accent: #7fe07a;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(6px, calc(var(--stage-h, 100vh) * 1.2 / 100), 12px);
  width: 100%;
  height: 100%;
  padding: clamp(8px, calc(var(--stage-h, 100vh) * 1.8 / 100), 20px) clamp(10px, calc(var(--stage-w, 100vw) * 2 / 100), 34px) clamp(6px, calc(var(--stage-h, 100vh) * 1.2 / 100), 14px);
  text-align: left;
  outline: none;
  box-sizing: border-box;
}

/* 背景雾面：参考图那种深蓝灰、带点藤蔓剪影的感觉 */
.select-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 60% at 12% 30%, rgba(120, 150, 200, .07), transparent 70%),
    radial-gradient(50% 55% at 88% 70%, rgba(120, 150, 200, .06), transparent 70%);
}

/* ---------------- 顶栏 ---------------- */
.sel-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.sel-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-size: clamp(18px, calc(var(--stage-h, 100vh) * 3.4 / 100), 34px);
  font-weight: 900;
  letter-spacing: .12em;
  color: #f4f7fc;
  white-space: nowrap;
  text-shadow:
    0 2px 0 #10131b, 0 0 14px rgba(0, 0, 0, .6),
    2px 0 0 #10131b, -2px 0 0 #10131b, 0 2px 0 #10131b;
}
.sel-back,
.sel-invite {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: clamp(5px, .9vh, 9px) clamp(10px, calc(var(--stage-w, 100vw) * 1.4 / 100), 18px);
  font-family: inherit;
  font-size: clamp(11px, calc(var(--stage-h, 100vh) * 1.7 / 100), 15px);
  font-weight: 700;
  color: #dfe6f2;
  background: rgba(16, 20, 30, .82);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 7px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.sel-back:hover,
.sel-invite:hover { background: rgba(30, 38, 54, .92); }
.sel-back:active,
.sel-invite:active { transform: translateY(1px); }
.sel-back-arrow { font-size: 1.1em; line-height: 1; }
.sel-invite.is-done { color: #9be08a; }

/* ---------------- 中间三块 ---------------- */
.sel-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, .54fr) minmax(0, .62fr);
  gap: clamp(6px, calc(var(--stage-w, 100vw) * 1 / 100), 14px);
  min-height: 0;
}
.sel-char,
.sel-record,
.sel-opts {
  min-height: 0;
  border-radius: 8px;
  box-sizing: border-box;
}

/* 左：角色详情 */
.sel-char {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, calc(var(--stage-h, 100vh) * 1.2 / 100), 12px);
  padding: clamp(10px, calc(var(--stage-h, 100vh) * 2 / 100), 22px) clamp(12px, calc(var(--stage-w, 100vw) * 1.6 / 100), 24px);
  background: linear-gradient(180deg, rgba(38, 46, 66, .78), rgba(28, 34, 50, .82));
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .30), inset 0 1px 0 rgba(255, 255, 255, .04);
  overflow: hidden;
}
.sel-char-name {
  margin: 0;
  text-align: center;
  font-size: clamp(18px, calc(var(--stage-h, 100vh) * 3.3 / 100), 34px);
  font-weight: 900;
  letter-spacing: .08em;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .45);
}
.sel-char-body {
  display: flex;
  gap: clamp(10px, calc(var(--stage-w, 100vw) * 1.6 / 100), 26px);
  align-items: center;
  min-height: 0;
  flex: 1;
}
.sel-portrait {
  flex: 0 0 clamp(116px, calc(var(--stage-h, 100vh) * 24 / 100), 252px);
  aspect-ratio: 1 / 1.02;
  display: grid;
  place-items: center;
  padding: 6px;
  background: linear-gradient(160deg, rgba(70, 82, 108, .6), rgba(24, 29, 42, .8));
  border: 2px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .30);
}
.sel-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45));
  animation: char-bob 3.2s ease-in-out infinite;
}
@keyframes char-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.sel-stats {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0 2px 0 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(6px, calc(var(--stage-h, 100vh) * 1.35 / 100), 14px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.stat {
  display: flex;
  align-items: center;
  gap: clamp(6px, .8vw, 10px);
  font-size: clamp(12px, calc(var(--stage-h, 100vh) * 2.05 / 100), 19px);
  font-weight: 700;
  color: #cfd8e6;
}
.stat-ico {
  flex: 0 0 auto;
  width: 1.3em;
  text-align: center;
  font-size: .95em;
  color: #98a6bd;
}
.stat-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.up .stat-txt { color: #7fe07a; }
.stat.down .stat-txt { color: #ff8a72; }
.sel-passive {
  margin: 0;
  padding-top: clamp(4px, .8vh, 8px);
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: clamp(10px, calc(var(--stage-h, 100vh) * 1.55 / 100), 14px);
  line-height: 1.5;
  color: #8d9ab0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sel-passive b { color: var(--accent); }

/* 中：纪录 */
.sel-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, .9vh, 10px);
  padding: clamp(10px, calc(var(--stage-h, 100vh) * 2 / 100), 22px) 10px;
  text-align: center;
  background: rgba(7, 9, 15, .86);
  border: 1px solid rgba(255, 255, 255, .05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
}
.rec-glyph {
  width: clamp(18px, calc(var(--stage-h, 100vh) * 3 / 100), 30px);
  height: clamp(24px, calc(var(--stage-h, 100vh) * 4 / 100), 40px);
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(180deg, #3a4256, #232a3a);
  border: 1px solid rgba(255, 255, 255, .10);
  position: relative;
}
.rec-glyph::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 40%;
  height: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .35);
  box-shadow: 0 -4px 0 rgba(255, 255, 255, .18), 0 -8px 0 rgba(255, 255, 255, .12);
}
.sel-record h3 {
  margin: 0;
  font-size: clamp(11px, calc(var(--stage-h, 100vh) * 1.9 / 100), 17px);
  font-weight: 800;
  letter-spacing: .12em;
  color: #dfe6f2;
}
.rec-state {
  margin: 0;
  font-size: clamp(12px, calc(var(--stage-h, 100vh) * 2.1 / 100), 19px);
  font-weight: 900;
  letter-spacing: .06em;
  color: #9aa7bd;
}
.sel-record.has .rec-state { color: #ffd24a; }
.rec-hint {
  margin: 0;
  font-size: clamp(9px, calc(var(--stage-h, 100vh) * 1.4 / 100), 12px);
  color: #76839a;
}
.rec-detail {
  margin: 0;
  font-size: clamp(8px, calc(var(--stage-h, 100vh) * 1.25 / 100), 11px);
  color: #67738a;
  min-height: 1em;
}

/* 右：运行选项 */
.sel-opts {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, calc(var(--stage-h, 100vh) * 1 / 100), 10px);
  padding: clamp(10px, calc(var(--stage-h, 100vh) * 1.8 / 100), 18px) clamp(10px, calc(var(--stage-w, 100vw) * 1.2 / 100), 16px);
  background: linear-gradient(180deg, rgba(34, 41, 58, .80), rgba(23, 28, 42, .84));
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .30);
  overflow: hidden;
}
.opts-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: clamp(11px, calc(var(--stage-h, 100vh) * 1.8 / 100), 16px);
  font-weight: 800;
  letter-spacing: .08em;
  color: #e4eaf4;
}
.opts-gear {
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  border: 2px dotted #aab6c8;
  box-shadow: inset 0 0 0 2px #2a3246;
  flex: 0 0 auto;
}
.opts-select-wrap {
  position: relative;
}
.opts-select-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -2px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #cfd8e6;
  pointer-events: none;
}
.opts-select {
  width: 100%;
  padding: clamp(6px, calc(var(--stage-h, 100vh) * 1 / 100), 10px) 26px clamp(6px, calc(var(--stage-h, 100vh) * 1 / 100), 10px) 10px;
  font-family: inherit;
  font-size: clamp(10px, calc(var(--stage-h, 100vh) * 1.6 / 100), 14px);
  font-weight: 700;
  color: #e9eef7;
  background: rgba(12, 15, 23, .85);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 6px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.opts-list {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(2px, .5vh, 6px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: clamp(4px, .8vh, 8px) 2px;
  border-radius: 5px;
}
.opt-name {
  font-size: clamp(10px, calc(var(--stage-h, 100vh) * 1.6 / 100), 14px);
  font-weight: 700;
  color: #cfd8e6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opt-soon .opt-name { color: #6d7a90; }
.opt-soon { opacity: .55; }

.switch {
  position: relative;
  flex: 0 0 auto;
  width: clamp(30px, calc(var(--stage-h, 100vh) * 4.4 / 100), 44px);
  height: clamp(16px, calc(var(--stage-h, 100vh) * 2.4 / 100), 23px);
  padding: 0;
  background: #3a4256;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 99px;
  cursor: pointer;
  transition: background .18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(100% * .5 - 2px);
  height: calc(100% - 4px);
  background: #c8d1df;
  border-radius: 99px;
  transition: transform .18s ease, background .18s ease;
}
.switch.on { background: #7f8ea8; }
.switch.on::after { transform: translateX(100%); background: #f2f5fa; }
.switch:disabled { cursor: not-allowed; }
/* v0.16.2：按住时不再把滑块拉宽（原来的宽度动画在手机上看着像变形） */
.switch:active:not(:disabled) { background: #4a5570; }
.switch:active:not(:disabled)::after { background: #e6eefb; }
.switch { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.sel-go {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: clamp(7px, calc(var(--stage-h, 100vh) * 1.3 / 100), 13px) 10px;
  font-family: inherit;
  font-size: clamp(11px, calc(var(--stage-h, 100vh) * 1.8 / 100), 16px);
  font-weight: 900;
  letter-spacing: .10em;
  color: #161a22;
  background: linear-gradient(180deg, #ffe08a, #f2c94c);
  border: 1px solid #c9a63f;
  border-radius: 7px;
  box-shadow: 0 4px 0 #8a6f27, 0 8px 18px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.sel-go:hover { filter: brightness(1.06); }
.sel-go:active { transform: translateY(2px); box-shadow: 0 2px 0 #8a6f27; }

/* ---------------- 底部角色栏 ---------------- */
.sel-roster {
  display: flex;
  gap: clamp(5px, .7vw, 11px);
  align-items: stretch;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px clamp(2px, .4vw, 6px) 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
.tile {
  position: relative;
  flex: 0 0 auto;
  width: clamp(48px, calc(var(--stage-h, 100vh) * 10.6 / 100), 104px);
  height: clamp(48px, calc(var(--stage-h, 100vh) * 10.6 / 100), 104px);
  padding: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #232b3d, #161b28);
  border: 2px solid rgba(255, 255, 255, .10);
  border-radius: 7px;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color .14s ease, transform .1s ease, background .14s ease;
}
.tile img {
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
}
.tile:hover { border-color: rgba(255, 255, 255, .30); background: linear-gradient(180deg, #2b3549, #1b2130); }
.tile.on {
  border-color: #ffd24a;
  background: linear-gradient(180deg, #343d52, #1e2434);
  box-shadow: 0 0 0 1px rgba(255, 210, 74, .55), 0 0 16px rgba(255, 210, 74, .22);
}
.tile.on::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid #ffd24a;
}
.tile-name {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  font-size: clamp(7px, calc(var(--stage-h, 100vh) * 1.15 / 100), 10px);
  font-weight: 700;
  text-align: center;
  color: #aeb9cc;
  letter-spacing: .02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
  pointer-events: none;
}
.tile.on .tile-name { color: #ffe9a8; }
.tile-lock { cursor: default; opacity: .55; border-style: dashed; }
.tile-lock:hover { border-color: rgba(255, 255, 255, .10); background: linear-gradient(180deg, #232b3d, #161b28); }
.lock-mark { font-size: clamp(12px, calc(var(--stage-h, 100vh) * 2.4 / 100), 22px); opacity: .7; }

/* ---------------- 底部提示 ---------------- */
.sel-keys {
  margin: 0;
  text-align: center;
  font-size: clamp(8px, calc(var(--stage-h, 100vh) * 1.2 / 100), 11px);
  color: #6b778d;
  flex: 0 0 auto;
}
.sel-keys kbd {
  display: inline-block;
  min-width: 1.2em;
  margin: 0 1px;
  padding: 0 3px;
  font-family: inherit;
  font-size: .95em;
  color: #b9c4d6;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 3px;
}

/* ---------------- 窄屏 / 矮屏 ---------------- */
/* 手机伪横屏（高 390 左右）：三栏压扁，纪录栏收窄 */
.select-overlay.is-short .sel-char { gap: 4px; }
.select-overlay.is-short .sel-passive { display: none; }
.select-overlay.is-short .sel-keys { display: none; }
.select-overlay.is-short .sel-main { grid-template-columns: minmax(0, 1.4fr) minmax(0, .5fr) minmax(0, .72fr); }
.select-overlay.is-short .rec-glyph { display: none; }

/* 真·竖屏 / 很窄：三块改成两栏（角色 + 选项），纪录挪到下面 */
.select-overlay.is-tiny .sel-main,
.select-overlay:not(.is-wide) .sel-main {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
}
.select-overlay:not(.is-wide) .sel-char { grid-column: 1 / 2; grid-row: 1 / 2; }
.select-overlay:not(.is-wide) .sel-opts { grid-column: 2 / 3; grid-row: 1 / 2; }
.select-overlay:not(.is-wide) .sel-record {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  padding: 6px 10px;
}
.select-overlay:not(.is-wide) .rec-glyph,
.select-overlay:not(.is-wide) .rec-detail { display: none; }
.select-overlay.is-tiny .sel-char-body { gap: 8px; }
.select-overlay.is-tiny .sel-portrait { flex-basis: 96px; }

/* v0.16.2 运行选项：只允许纵向滚动，别冒横向滚动条 */
.sel-opts,
.opts-list { scrollbar-width: none; -ms-overflow-style: none; }
.sel-opts::-webkit-scrollbar,
.opts-list::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sel-opts { overflow: hidden; }
.opts-list { overflow-x: hidden; overflow-y: auto; }
.opts-list .opt { min-width: 0; }
.opts-list .opt-name { min-width: 0; }
