/* ==========================================================================
   地鐵搶座心理戰 / Next Stop Seat v2.0
   Swiss International Transit Design × Editorial Tactile UI
   ========================================================================== */

:root {
  --bg-paper: #F4F1EA;
  --bg-card: #FFFDF8;
  --bg-metal: #E7E3D9;
  --ink-primary: #161A20;
  --ink-secondary: #4E5661;
  --ink-muted: #808893;
  --border-ink: #161A20;
  --border-soft: rgba(22, 26, 32, 0.14);

  --line-red: #D93829;
  --line-blue: #1E64C8;
  --line-purple: #7C3AED;
  --line-green: #00875A;
  --signal-amber: #E59A00;
  --signal-pink: #E6396F;
  --led-bg: #13161A;
  --led-amber: #FFB833;
  --led-green: #38E089;

  --radius-sm: 7px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-hard: 4px 4px 0px #161A20;
  --shadow-sm: 2.5px 2.5px 0px #161A20;

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Helvetica Neue", "Inter", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ==================== 成就解鎖浮動通知 ==================== */
.ach-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #161A20;
  color: #FFFDF8;
  border: 2.5px solid #FFB833;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  animation: toastSlide 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes toastSlide {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.ach-toast-icon {
  font-size: 26px;
  line-height: 1;
}

.ach-toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ach-toast-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #FFB833;
}

.ach-toast-body strong {
  font-size: 14px;
}

/* ==================== 按鈕系統 ==================== */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.12s ease, border-color 0.15s ease;
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 26px;
  background: var(--ink-primary);
  color: #FFFDF8;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.03em;
  border-radius: var(--radius-md);
  border: 2px solid var(--ink-primary);
  box-shadow: var(--shadow-hard);
}

.btn-primary:hover {
  background: #282F38;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px #161A20;
}

.btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #161A20;
}

.btn-lg {
  padding: 16px 38px;
  font-size: 17px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  background: var(--bg-card);
  color: var(--ink-primary);
  font-weight: 800;
  font-size: 13.5px;
  border-radius: var(--radius-md);
  border: 2px solid var(--ink-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #EFEBE0;
  transform: translate(-1px, -1px);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-soft);
  background: rgba(255, 253, 248, 0.78);
}

.btn-ghost:hover {
  border-color: var(--ink-primary);
  color: var(--ink-primary);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 2px solid var(--ink-primary);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}

.icon-btn:hover {
  background: var(--ink-primary);
  color: var(--bg-card);
}

/* ==================== 標題畫面 ==================== */
.screen-title {
  position: relative;
  align-items: center;
  padding: 0 0 28px;
  overflow-x: hidden;
}

.station-ticker-bar {
  position: relative;
  z-index: 2;
  width: 100%;
  background: var(--led-bg);
  color: #FFD57A;
  border-bottom: 2.5px solid #161A20;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
  font-weight: 700;
}

.ticker-left, .ticker-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ticker-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-green);
  box-shadow: 0 0 8px var(--led-green);
  animation: blinkDot 1.4s infinite ease-in-out;
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.ticker-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #9CA3AF;
}

.ticker-center {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}

.title-bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(22, 26, 32, 0.042) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(22, 26, 32, 0.042) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.title-map-decor {
  position: fixed;
  top: 36px;
  left: 0;
  right: 0;
  height: 240px;
  pointer-events: none;
  z-index: 0;
}

.title-map-decor svg {
  width: 100%;
  height: 100%;
}

.title-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  padding: 26px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.title-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.metro-badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.metro-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  color: #FFFDF8;
  letter-spacing: 0.04em;
}

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.title-zh {
  font-size: clamp(32px, 4.8vw, 52px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink-primary);
}

.title-en {
  font-family: var(--font-mono);
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--line-red);
}

.game-subtitle {
  max-width: 640px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-secondary);
  font-weight: 600;
}

/* 大廳分區標題 */
.lobby-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--ink-primary);
  color: #FFFDF8;
}

.lobby-section-head h2 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.perk-count-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: #FFF6DC;
  border: 1.5px solid var(--ink-primary);
}

/* 5 路線選擇器 */
.line-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.line-card {
  position: relative;
  text-align: left;
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: 15px;
  padding: 16px 14px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  box-shadow: 3px 3px 0px rgba(22, 26, 32, 0.16);
}

.line-card:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0px var(--ink-primary);
}

.line-card.selected {
  background: #FFFDF3;
  box-shadow: 5px 5px 0px var(--ink-primary);
  outline: 3px solid var(--ink-primary);
  outline-offset: -5px;
}

.line-card-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--line-color);
}

.line-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.line-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--line-color);
  color: #fff;
}

.line-theme-pill {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-muted);
}

.line-card h3 {
  font-size: 16px;
  font-weight: 900;
}

.line-card p {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-secondary);
  flex: 1;
}

.line-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-muted);
}

/* 6 選 2 通勤心理戰裝備 */
.perk-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.perk-card {
  text-align: left;
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: 12px;
  padding: 11px 13px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.perk-card:hover {
  border-color: var(--ink-primary);
}

.perk-card.selected {
  background: #FFF9E6;
  border-color: var(--ink-primary);
  box-shadow: 3px 3px 0px var(--ink-primary);
}

.perk-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-paper);
  border: 1.5px solid var(--ink-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.perk-card.selected .perk-icon {
  background: #FFB833;
}

.perk-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.perk-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.perk-name {
  font-size: 13.5px;
  font-weight: 900;
}

.perk-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ink-primary);
  color: #fff;
}

.perk-desc {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-secondary);
}

.title-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.title-sub-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.count-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--ink-primary);
  color: #fff;
}

.title-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding-top: 10px;
  border-top: 1.5px solid var(--border-soft);
}

.best-record-strip {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-primary);
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-secondary);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  background: var(--bg-card);
  border: 1.5px solid var(--ink-primary);
  border-radius: 4px;
  box-shadow: 1px 1px 0px var(--ink-primary);
}

/* ==================== 遊戲主畫面 ==================== */
.screen-game {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg-paper);
}

.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--ink-primary);
  flex-shrink: 0;
}

.top-left-brand, .top-right-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.line-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 2px solid var(--ink-primary);
  background: var(--bg-paper);
  font-weight: 800;
  font-size: 13px;
}

.line-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-red);
}

.led-board {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 8px;
  background: var(--led-bg);
  border: 2px solid var(--ink-primary);
  color: var(--led-amber);
  font-family: var(--font-mono);
  min-width: 195px;
}

.led-board.glitch {
  animation: ledGlitch 0.16s infinite alternate;
}

@keyframes ledGlitch {
  from { color: #FF4D4D; border-color: #D93829; }
  to { color: #FFB833; border-color: #161A20; }
}

.led-label {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 184, 51, 0.18);
  color: var(--led-amber);
  letter-spacing: 0.08em;
}

.led-text {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 14px;
  color: #FFD57A;
  letter-spacing: 0.04em;
}

.led-tag {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--led-green);
  color: #0D1912;
}

.active-perks-strip {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-perk-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 7px;
  background: #FFF6DC;
  border: 1.5px solid var(--ink-primary);
  font-size: 11px;
  font-weight: 800;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  min-width: 68px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
}

.combo-chip.hot {
  background: #FFF3D1;
  border-color: var(--signal-amber);
}

/* 極簡水平地鐵路線圖 */
.route-map-strip {
  background: var(--bg-card);
  border-bottom: 1.5px solid var(--border-soft);
  padding: 8px 18px 10px;
  flex-shrink: 0;
  overflow-x: auto;
}

.route-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 580px;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  padding: 4px 12px 0;
}

.route-line-bg {
  position: absolute;
  top: 12px;
  left: 20px;
  right: 20px;
  height: 5px;
  border-radius: 999px;
  background: #DDD8CC;
  z-index: 0;
}

.route-line-progress {
  position: absolute;
  top: 12px;
  left: 20px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-red);
  z-index: 1;
  transition: width 0.35s linear;
}

.route-train-pill {
  position: absolute;
  top: 5px;
  left: 20px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #161A20;
  border: 2.5px solid #FFFDF8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  z-index: 4;
  transition: left 0.25s linear;
}

.route-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.route-node-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid #B6B0A2;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.route-node.transfer .route-node-dot {
  width: 17px;
  height: 17px;
  border-width: 4px;
}

.route-node.passed .route-node-dot {
  background: var(--active-line-color, var(--line-red));
  border-color: var(--active-line-color, var(--line-red));
}

.route-node.current .route-node-dot {
  background: #FFFDF8;
  border-color: var(--active-line-color, var(--line-red));
  transform: scale(1.26);
  box-shadow: 0 0 0 4px rgba(217, 56, 41, 0.16);
}

.route-node-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
}

.route-node.current .route-node-label {
  color: var(--ink-primary);
  font-weight: 900;
}

/* 主舞台容器 */
.stage-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
  padding: 9px 16px 11px;
  gap: 9px;
}

.meters-bar {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
  flex-shrink: 0;
}

.phase-panel, .awkward-panel {
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: var(--radius-md);
  padding: 7px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.awkward-panel.danger {
  border-color: var(--line-red);
  background: #FFF3F2;
  animation: pulseBorder 0.7s infinite alternate;
}

@keyframes pulseBorder {
  from { box-shadow: 0 0 0 0 rgba(217, 56, 41, 0.35); }
  to { box-shadow: 0 0 0 5px rgba(217, 56, 41, 0); }
}

.phase-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
}

.phase-badge {
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--ink-primary);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.phase-badge.approaching { background: var(--signal-amber); color: #161A20; }
.phase-badge.braking { background: var(--line-red); color: #fff; }
.phase-badge.doors { background: var(--line-green); color: #fff; }

.phase-timer {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
}

.awkward-title small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  margin-left: 4px;
}

.awkward-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 900;
  color: var(--line-red);
}

.progress-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #E6E2D8;
  overflow: hidden;
  border: 1px solid rgba(22, 26, 32, 0.16);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.1s linear;
}

.phase-fill { background: var(--ink-primary); }
.awkward-fill {
  background: linear-gradient(90deg, #F4B400 0%, #E65100 55%, #D93829 100%);
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Canvas 區域 */
.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 295px;
  background: #191D23;
  border: 2.5px solid var(--ink-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-hard);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

/* 突發事件橫幅 */
.event-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(22, 26, 32, 0.92);
  color: #FFFDF8;
  border: 2px solid #FFB833;
  font-size: 12.5px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  max-width: 94%;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: popDown 0.25s ease;
}

@keyframes popDown {
  from { transform: translate(-50%, -14px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.ev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFB833;
  flex-shrink: 0;
}

/* 搶座 / 讓座 / 秒掏手機救場 快反按鈕 */
.action-prompt {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  animation: popBounce 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popBounce {
  from { transform: translate(-50%, 16px) scale(0.85); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 999px;
  background: #FFB833;
  color: #161A20;
  border: 3px solid #161A20;
  font-weight: 900;
  font-size: 15.5px;
  box-shadow: 0 6px 0 #161A20, 0 12px 28px rgba(0, 0, 0, 0.35);
}

.quick-action-btn.yield-mode {
  background: #38E089;
}

.quick-action-btn.phone-save-mode {
  background: #38BDF8;
  color: #0F172A;
}

.qa-key {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #161A20;
  color: #FFFDF8;
}

/* 結果橫幅 */
.result-banner {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  text-align: center;
  padding: 17px 32px;
  border-radius: var(--radius-lg);
  border: 3px solid #161A20;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 6px 6px 0px #161A20;
  pointer-events: none;
  min-width: 280px;
  animation: bannerPop 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bannerPop {
  from { transform: translate(-50%, -50%) scale(0.84); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.result-banner.success { border-color: var(--line-green); }
.result-banner.awkward { background: #FFF1F0; border-color: var(--line-red); }
.result-banner.missed { background: #FFF8E6; border-color: var(--signal-amber); }

.rb-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
}

.rb-title {
  font-size: 27px;
  font-weight: 900;
  margin: 4px 0;
}

.result-banner.success .rb-title { color: var(--line-green); }
.result-banner.awkward .rb-title { color: var(--line-red); }
.result-banner.missed .rb-title { color: #B87300; }

.rb-sub {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* 暫停遮罩 */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(22, 26, 32, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-card {
  background: var(--bg-card);
  border: 3px solid var(--ink-primary);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  text-align: center;
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* 底部控制列 */
.bottom-control-deck {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.observation-ticker {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--ink-primary);
  color: #F4F1EA;
  font-size: 13px;
  font-weight: 600;
}

.obs-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-green);
  flex-shrink: 0;
}

.deck-controls-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.seat-quick-buttons {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.seat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: 10px;
  box-shadow: 2px 2px 0px var(--ink-primary);
}

.seat-btn:hover { background: #EFEBE0; }
.seat-btn.active {
  background: var(--ink-primary);
  color: #FFFDF8;
  transform: translateY(-2px);
}

.sb-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 900;
}

.sb-role {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.focus-btn {
  min-width: 126px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  background: #FFF6DC;
  border: 2px solid var(--ink-primary);
  border-radius: 10px;
  box-shadow: 2px 2px 0px var(--ink-primary);
  font-weight: 800;
  font-size: 12px;
}

.focus-btn.active {
  background: #FFB833;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--ink-primary);
}

.focus-icon { font-size: 16px; line-height: 1; }

.focus-meter {
  width: 100%;
  height: 5px;
  background: rgba(22, 26, 32, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

#focus-meter-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ink-primary);
}

/* ==================== 結算段位卡畫面 ==================== */
.screen-result {
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
}

.result-layout {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: minmax(300px, 440px) 1fr;
  gap: 28px;
  align-items: start;
}

.ticket-frame {
  background: var(--bg-card);
  border: 2.5px solid var(--ink-primary);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: 8px 8px 0px var(--ink-primary);
}

#rank-card-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.result-summary-panel {
  background: var(--bg-card);
  border: 2.5px solid var(--ink-primary);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--line-green);
  color: #fff;
  margin-bottom: 6px;
}

.result-tag.fail { background: var(--line-red); }
.result-header h2 { font-size: 30px; font-weight: 900; margin-bottom: 6px; }
.result-header p { font-size: 14px; color: var(--ink-secondary); line-height: 1.55; }

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.res-stat-card {
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
}

.res-stat-card .k { font-size: 11px; font-weight: 700; color: var(--ink-muted); }
.res-stat-card .v { font-family: var(--font-mono); font-size: 22px; font-weight: 900; margin-top: 2px; }

.newly-unlocked-box {
  background: #FFF9E6;
  border: 1.5px dashed var(--signal-amber);
  border-radius: 12px;
  padding: 12px 14px;
}

.newly-unlocked-box h4 { font-size: 13px; margin-bottom: 8px; }
.unlocked-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.unlocked-pill {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink-primary);
  color: #fff;
}

.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-nav-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.copy-toast { font-size: 13px; font-weight: 800; color: var(--line-green); text-align: center; }

/* ==================== Modal（圖鑑 / 成就 / 手冊） ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 26, 32, 0.64);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  background: var(--bg-paper);
  border: 2.5px solid var(--ink-primary);
  border-radius: var(--radius-lg);
  box-shadow: 8px 8px 0px var(--ink-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg { max-width: 980px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--ink-primary);
}

.modal-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--line-red);
}

.modal-header h2 { font-size: 22px; font-weight: 900; }
.modal-header-right { display: flex; align-items: center; gap: 12px; }

.codex-counter {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  padding: 5px 11px;
  background: var(--bg-paper);
  border: 1.5px solid var(--ink-primary);
  border-radius: 999px;
}

.codex-filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 22px;
  background: var(--bg-card);
  border-bottom: 1.5px solid var(--border-soft);
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1.5px solid var(--ink-primary);
  background: var(--bg-paper);
}

.filter-chip.active { background: var(--ink-primary); color: #fff; }

.codex-grid {
  padding: 18px 22px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.codex-card {
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 3px 3px 0px rgba(22, 26, 32, 0.16);
}

.codex-card.locked {
  background: #EBE7DE;
  border-style: dashed;
  opacity: 0.78;
}

.codex-card-top { display: flex; align-items: center; gap: 12px; }

.codex-avatar {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  border: 2px solid var(--ink-primary);
  background: var(--bg-paper);
  flex-shrink: 0;
  overflow: hidden;
}

.codex-name { font-size: 15.5px; font-weight: 900; }

.codex-rarity {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 3px;
  color: #fff;
}

.rarity-common { background: #64748B; }
.rarity-uncommon { background: #1E64C8; }
.rarity-rare { background: #9333EA; }
.rarity-legendary { background: #D93829; }

.codex-desc { font-size: 12px; line-height: 1.5; color: var(--ink-secondary); }
.codex-tells {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 11.5px;
}

/* 成就牆 */
.ach-grid {
  padding: 18px 22px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 12px;
}

.ach-card {
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: 13px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  box-shadow: 3px 3px 0px rgba(22, 26, 32, 0.16);
}

.ach-card.locked {
  background: #EBE7DE;
  border-style: dashed;
  opacity: 0.65;
}

.ach-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  border: 2px solid var(--ink-primary);
  background: #FFF6DC;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.ach-card.locked .ach-card-icon {
  background: #DCD8CE;
  filter: grayscale(1);
}

.ach-card-title { font-size: 14.5px; font-weight: 900; }
.ach-card-desc { font-size: 12px; color: var(--ink-secondary); margin-top: 3px; line-height: 1.4; }

.guide-body {
  padding: 20px 22px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.guide-section h3 { font-size: 16px; font-weight: 900; margin-bottom: 8px; }
.guide-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.guide-list li {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-left: 4px solid var(--line-green);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-secondary);
}
.guide-list.warning li { border-left-color: var(--line-red); }
.guide-list strong { color: var(--ink-primary); }

/* ==================== 響應式支援 ==================== */
@media (max-width: 1020px) {
  .line-selector { grid-template-columns: repeat(2, 1fr); }
  .perk-selector { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .line-selector, .perk-selector { grid-template-columns: 1fr; }
  .result-layout { grid-template-columns: 1fr; }
  .game-top-bar { flex-wrap: wrap; padding: 8px 10px; }
  .active-perks-strip { display: none; }
  .led-board { min-width: 140px; padding: 5px 10px; }
  .meters-bar { grid-template-columns: 1fr; gap: 8px; }
  .deck-controls-row { flex-direction: column; }
  .focus-btn { flex-direction: row; min-width: 0; padding: 10px 14px; }
  .focus-meter { width: 80px; }
  .ticker-right { display: none; }
}
