/**
 * @file games/bumper/css/style.css
 * 题材原生视窗：微缩玩具撞车微型竞技台 (Diorama Bumper Console)。
 * 纯暗色沉浸背景、对称机械大按键、实体微浮雕与全端避让适配。
 */

:root {
  --bg-dark: #0a0d16;
  --panel-bg: #131826;
  --card-bg: #182033;
  --border-subtle: #242f47;
  --gold-primary: #f5ba31;
  --gold-glow: rgba(245, 186, 49, 0.25);
  --red-car: #ff4757;
  --red-glow: rgba(255, 71, 87, 0.35);
  --blue-car: #1e90ff;
  --blue-glow: rgba(30, 144, 255, 0.35);
  --text-main: #f1f2f6;
  --text-muted: #8c9cb8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-bottom: max(68px, calc(16px + env(safe-area-inset-bottom)));
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* 主容器 */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px var(--safe-bottom);
}

/* 顶栏控制台 */
.topbar-console {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.home-badge:hover {
  background: var(--border-subtle);
  border-color: var(--gold-primary);
  color: #fff;
}

.topbar-center {
  text-align: center;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

/* 触感药丸按钮 */
.btn-tactile {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-tactile:hover {
  border-color: var(--gold-primary);
  color: #fff;
}

.btn-tactile:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-tactile.mode-pill {
  background: linear-gradient(135deg, rgba(255, 71, 87, 0.2), rgba(30, 144, 255, 0.2));
  border-color: var(--gold-primary);
  color: #ffeaa7;
}

/* 核心对称微缩机台排版 */
.arena-assembly {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 16px;
  flex: 1;
}

/* 左右驾驶翼栏 */
.versus-wing {
  width: 170px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wing-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 8px;
}

.wing-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.wing-red .wing-badge {
  background: rgba(255, 71, 87, 0.2);
  color: var(--red-car);
  border: 1px solid var(--red-car);
}

.wing-blue .wing-badge {
  background: rgba(30, 144, 255, 0.2);
  color: var(--blue-car);
  border: 1px solid var(--blue-car);
}

.wing-player-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

/* 大号实体微浮雕冲刺按键 */
.thrust-pedestal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  width: 100%;
}

.btn-thrust-giant {
  width: 100%;
  height: 110px;
  border-radius: 18px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: pointer;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  touch-action: none;
}

.btn-thrust-red {
  background: linear-gradient(180deg, #ff6b81, #ff4757);
  color: #fff;
  box-shadow: 0 6px 0 #b33939, 0 8px 16px var(--red-glow);
}

.btn-thrust-red:active, .btn-thrust-red.pressed {
  transform: translateY(6px);
  box-shadow: 0 0 0 #b33939, 0 2px 8px var(--red-glow);
}

.btn-thrust-blue {
  background: linear-gradient(180deg, #70a1ff, #1e90ff);
  color: #fff;
  box-shadow: 0 6px 0 #1b6ca8, 0 8px 16px var(--blue-glow);
}

.btn-thrust-blue:active, .btn-thrust-blue.pressed {
  transform: translateY(6px);
  box-shadow: 0 0 0 #1b6ca8, 0 2px 8px var(--blue-glow);
}

.key-hint {
  font-size: 11px;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 4px;
}

.control-tip-pill {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  line-height: 1.4;
}

/* 中央主视窗 */
.stage-assembly {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 820px;
}

/* 顶棚比分牌 */
.scoreboard-canopy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 18px;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px 14px 0 0;
  border-bottom: none;
}

.score-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-digit {
  font-size: 32px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.score-red {
  color: var(--red-car);
}

.score-blue {
  color: var(--blue-car);
}

.bo5-dots {
  display: flex;
  gap: 5px;
}

.bo5-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #252d3d;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.bo5-dot.red-won {
  background: var(--red-car);
  box-shadow: 0 0 8px var(--red-glow);
}

.bo5-dot.blue-won {
  background: var(--blue-car);
  box-shadow: 0 0 8px var(--blue-glow);
}

.stage-title-wrap {
  text-align: center;
}

.current-stage-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold-primary);
}

.round-indicator {
  font-size: 11px;
  color: var(--text-muted);
}

/* 画布框架 */
.stage-frame {
  width: 100%;
  background: #000;
  border: 2px solid var(--border-subtle);
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

#stage {
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 480;
  display: block;
  outline: none;
}

.stage-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 17, 26, 0.94);
  border: 1px solid var(--gold-primary);
  color: #ffeaa7;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  text-align: center;
  max-width: 90%;
  white-space: nowrap;
}

/* 底座操作控制台 */
.console-pedestal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  width: 100%;
}

.btn-pedestal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 3px 0 #0d121c;
}

.btn-pedestal:hover {
  border-color: var(--gold-primary);
  color: #fff;
}

.btn-pedestal:active {
  transform: translateY(3px);
  box-shadow: none;
}

.btn-pedestal.btn-primary {
  background: linear-gradient(180deg, #f5ba31, #e0a31b);
  border-color: #d19714;
  color: #0b0f19;
  font-weight: 800;
  box-shadow: 0 3px 0 #9e710d;
}

/* 弹窗通用样式 (Native <dialog>) */
.diorama-modal {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--panel-bg);
  color: var(--text-main);
  max-width: 520px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
  outline: none;
}

.diorama-modal::backdrop {
  background: rgba(8, 12, 20, 0.78);
  backdrop-filter: blur(4px);
}

.modal-box {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.modal-content {
  font-size: 13px;
  line-height: 1.6;
  color: #d1d8e0;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-content h3 {
  font-size: 14px;
  color: var(--gold-primary);
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

/* 关卡选择抽屉网格 */
.modal-wide {
  max-width: 680px;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px;
}

.level-card-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.level-card-btn:hover:not(:disabled) {
  border-color: var(--gold-primary);
  background: rgba(245, 186, 49, 0.1);
}

.level-card-btn.current {
  border-color: var(--gold-primary);
  background: rgba(245, 186, 49, 0.18);
}

.level-card-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card-num {
  font-size: 15px;
  font-weight: 800;
}

.level-card-stars {
  font-size: 12px;
  color: var(--gold-primary);
}

.level-card-title {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

/* 结算弹窗星级 */
.stars-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.star-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #636e72;
}

.star-row.achieved {
  color: #ffeaa7;
}

.star-icon {
  font-size: 18px;
}

/* 响应式排版适配 */
@media (max-width: 900px) {
  .arena-assembly {
    flex-direction: column;
    align-items: center;
  }

  .versus-wing {
    width: 100%;
    max-width: 820px;
    flex-direction: row;
    justify-content: space-between;
  }

  .wing-card {
    flex: 1;
  }

  .btn-thrust-giant {
    height: 75px;
    font-size: 20px;
  }
}

/* 动效降级声明 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
