/* TSA Arena — 設計系統 */
:root {
  --bg: #0b1020;
  --bg-soft: #111832;
  --panel: #161f3d;
  --panel-2: #1c2750;
  --line: rgba(148, 163, 255, 0.16);
  --text: #e7ecff;
  --muted: #93a0c9;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --accent-3: #34d399;
  --gold: #fbbf24;
  --danger: #fb7185;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(2, 6, 23, 0.55);
  --font-display: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-display);
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(167, 139, 250, 0.18), transparent 60%),
    radial-gradient(900px 500px at 10% -10%, rgba(56, 189, 248, 0.16), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

body.ranked-secure,
body.ranked-secure #game-host {
  -webkit-user-select: none;
  user-select: none;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- 頂欄 ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 4px; margin-bottom: 18px;
}
.logo { display: flex; align-items: baseline; gap: 10px; font-weight: 900; font-size: 22px; letter-spacing: 1px; }
.logo .mark { color: var(--accent); text-shadow: 0 0 18px rgba(56, 189, 248, 0.8); }
.logo .sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.topbar nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.navlink {
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 700;
  color: var(--muted); border: 1px solid transparent; transition: 0.15s;
}
.navlink:hover { color: var(--text); border-color: var(--line); }
.navlink.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }

/* ---------- 面板/卡片 ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel h2 { font-size: 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-weight: 800; font-size: 15px; cursor: pointer; transition: 0.15s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(148, 163, 255, 0.4); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: rgba(125, 211, 252, 0.5);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
}
.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.22);
}
.btn-ghost { background: transparent; }
.btn-lg { padding: 15px 30px; font-size: 17px; border-radius: 14px; }

/* ---------- 表單 ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field input {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 16px; outline: none; transition: 0.15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18); }
.form-error { color: var(--danger); font-size: 13.5px; font-weight: 700; min-height: 18px; }

/* ---------- 遊戲卡 ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.game-card {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  cursor: pointer; transition: 0.18s; overflow: hidden;
}
.game-card:hover { transform: translateY(-3px); border-color: rgba(148, 163, 255, 0.45); box-shadow: var(--shadow); }
.game-card .icon { font-size: 30px; }
.game-card .title { font-weight: 900; font-size: 16.5px; }
.game-card .skill {
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.4px;
  color: var(--accent); background: rgba(56, 189, 248, 0.12);
  align-self: flex-start; padding: 3px 9px; border-radius: 999px;
}
.game-card .desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; flex: 1; }
.game-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.game-card .mech { color: var(--muted); }
.stars { letter-spacing: 2px; font-size: 14px; }
.stars .on { color: var(--gold); text-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.stars .off { color: #3b4570; }

/* ---------- 領域 ---------- */
.domain-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.domain-tab {
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; gap: 8px; transition: 0.15s; color: var(--muted);
}
.domain-tab.active { color: var(--text); border-color: currentColor; }
.domain-tab.active.dA { color: var(--accent); background: rgba(56, 189, 248, 0.1); }
.domain-tab.active.dB { color: var(--accent-2); background: rgba(167, 139, 250, 0.1); }
.domain-tab.active.dC { color: var(--accent-3); background: rgba(52, 211, 153, 0.1); }

.progressbar { height: 10px; border-radius: 999px; background: #232c54; overflow: hidden; }
.progressbar > div { height: 100%; border-radius: 999px; transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

/* ---------- 段位徽章 ---------- */
.tier-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; font-weight: 900; font-size: 14px;
  border: 1px solid var(--line); background: var(--bg-soft);
}
.tier-bronze { color: #d9a066; }
.tier-silver { color: #c8d3e8; }
.tier-gold { color: #fbbf24; }
.tier-platinum { color: #7dd3fc; }
.tier-diamond { color: #818cf8; }
.tier-master { color: #e879f9; }
.tier-champion { color: #fb7185; text-shadow: 0 0 12px rgba(251, 113, 133, 0.6); }

/* ---------- 龍虎榜 ---------- */
.board { width: 100%; border-collapse: collapse; }
.board th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.board td { padding: 11px 12px; border-bottom: 1px solid rgba(148, 163, 255, 0.07); font-size: 14.5px; }
.board tr:hover td { background: rgba(148, 163, 255, 0.05); }
.board .rank-num { font-weight: 900; width: 44px; }
.board tr.top1 .rank-num { color: var(--gold); font-size: 18px; }
.board tr.top2 .rank-num { color: #c8d3e8; font-size: 16px; }
.board tr.top3 .rank-num { color: #d9a066; font-size: 16px; }

/* ---------- 遊戲外殼 ---------- */
.hud {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.hud .hud-item { display: flex; flex-direction: column; min-width: 64px; }
.hud .hud-label { font-size: 10.5px; color: var(--muted); font-weight: 800; letter-spacing: 1px; }
.hud .hud-value { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud .timerbar { flex: 1; min-width: 120px; }
.hud .combo { color: var(--gold); }

#game-host {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 480px; overflow: hidden;
  box-shadow: var(--shadow);
}

/* 引擎共用元件 */
.eng-keypad { display: grid; grid-template-columns: repeat(4, 64px); gap: 8px; justify-content: center; }
.eng-key {
  height: 52px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 19px; font-weight: 800;
  cursor: pointer; transition: 0.1s;
}
.eng-key:hover { border-color: var(--accent); }
.eng-key:active { transform: scale(0.94); }
.eng-key.eng-key-ok { background: linear-gradient(135deg, #0ea5e9, #6366f1); border: none; }
.eng-key.eng-key-warn { color: var(--gold); }
.eng-display {
  min-width: 200px; text-align: center; font-size: 26px; font-weight: 900;
  background: #0a0f22; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; margin: 0 auto 12px; font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.eng-choices { display: grid; gap: 10px; }
.eng-choice {
  padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 16px; font-weight: 700;
  cursor: pointer; text-align: left; transition: 0.12s;
}
.eng-choice:hover { border-color: var(--accent); transform: translateX(3px); }

.eng-feedback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 54px; font-weight: 900; pointer-events: none; z-index: 30;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); opacity: 0;
}
.eng-feedback.show { animation: engPop 0.7s ease-out; }
@keyframes engPop {
  0% { opacity: 0; transform: scale(0.4); }
  25% { opacity: 1; transform: scale(1.12); }
  60% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
.shake { animation: engShake 0.4s both; }
@keyframes engShake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* 結算畫面 */
.result-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 20, 0.82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.result-card {
  width: min(480px, 100%); text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 20px; padding: 34px 28px;
  box-shadow: var(--shadow); animation: resultIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes resultIn { from { opacity: 0; transform: translateY(26px) scale(0.96); } }
.result-card h1 { font-size: 30px; margin-bottom: 6px; }
.result-stars { font-size: 42px; letter-spacing: 8px; margin: 12px 0; }
.result-stats { display: flex; justify-content: center; gap: 26px; margin: 18px 0 24px; }
.result-stats .v { font-size: 26px; font-weight: 900; }
.result-stats .k { font-size: 12px; color: var(--muted); font-weight: 700; }
.lp-delta { font-size: 38px; font-weight: 900; margin: 10px 0; }
.lp-delta.up { color: var(--accent-3); }
.lp-delta.down { color: var(--danger); }

/* ---------- 雷達圖容器 ---------- */
.radar-wrap { display: flex; align-items: center; justify-content: center; }

/* ---------- 首頁 hero ---------- */
.hero { text-align: center; padding: 56px 16px 36px; }
.hero h1 { font-size: clamp(30px, 5.5vw, 52px); font-weight: 900; line-height: 1.18; }
.hero h1 .grad {
  background: linear-gradient(92deg, #38bdf8, #a78bfa 55%, #fb7185);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); margin-top: 14px; font-size: 16.5px; }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 34px; }
.mode-card { text-align: left; padding: 26px; }
.mode-card .big { font-size: 38px; }
.mode-card h3 { font-size: 20px; margin: 10px 0 8px; }
.mode-card p { color: var(--muted); font-size: 14px; line-height: 1.6; }

.lock-hint {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--gold); background: rgba(251, 191, 36, 0.1);
  padding: 4px 12px; border-radius: 999px; font-weight: 800;
}

@media (max-width: 640px) {
  .hud .hud-value { font-size: 16px; }
  .eng-keypad { grid-template-columns: repeat(4, 1fr); width: 100%; }
}
