/* 泡泡射手 · 极光冰窟机台样式（对称双舷窗 / 一体化掌机 / 广告安全避让） */

:root {
  --ink: #eaf4ff;
  --ink-dim: #9fb7d4;
  --deep: #07162e;
  --deep-2: #0d2447;
  --panel: rgba(14, 38, 68, 0.78);
  --panel-2: rgba(10, 28, 52, 0.9);
  --line: rgba(140, 200, 255, 0.18);
  --mint: #6ef2d0;
  --ice: #7fd8ff;
  --rose: #ff7ba8;
  --gold: #e8c274;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(110, 242, 208, 0.16), transparent 60%),
    radial-gradient(900px 600px at 88% 8%, rgba(140, 120, 255, 0.18), transparent 62%),
    linear-gradient(170deg, #0a1c38 0%, #07162e 45%, #061325 100%);
  background-attachment: fixed;
}

#game-app {
  min-height: 100vh;
  padding-bottom: max(68px, calc(16px + env(safe-area-inset-bottom)));
  display: flex;
  flex-direction: column;
}

/* ---------- 机顶内嵌控制栏 ---------- */
#stage-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(9, 26, 50, 0.96), rgba(9, 26, 50, 0.78));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(6px);
}

#stage-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(127, 216, 255, 0.45);
}

#back-home,
.bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(46, 96, 150, 0.55), rgba(16, 44, 78, 0.65));
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35), 0 3px 10px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, filter 0.12s ease;
}

#back-home:hover,
.bar-btn:hover {
  filter: brightness(1.12);
}

#back-home:active,
.bar-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.stage-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 机台主体 ---------- */
#stage-core {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  padding: 16px 18px 8px;
}

#panel-left,
#panel-right {
  width: 208px;
  flex: 0 0 208px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel-chunk {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(8, 24, 44, 0.55);
  border: 1px solid rgba(127, 216, 255, 0.1);
}

.p-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-dim);
}

.dim {
  color: var(--ink-dim);
  font-size: 12px;
  margin: 0;
}

.lcd {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
  color: var(--ice);
  text-shadow: 0 0 12px rgba(127, 216, 255, 0.5);
}

.lcd.big {
  font-size: 26px;
  color: var(--mint);
  text-shadow: 0 0 16px rgba(110, 242, 208, 0.55);
}

.lcd.small {
  font-size: 12px;
}

#panel-left h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 1px;
}

#stage-cabinet {
  flex: 1 1 auto;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#mobile-hud {
  display: none;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 360 / 640;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(140, 200, 255, 0.28);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(80, 180, 255, 0.08);
  background: #0a1830;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  overscroll-behavior: none;
  cursor: crosshair;
}

/* ---------- 浮层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 18px;
  overflow-y: auto;
  text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, rgba(12, 34, 62, 0.94), rgba(6, 16, 32, 0.97));
  backdrop-filter: blur(3px);
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  text-shadow: 0 0 20px rgba(127, 216, 255, 0.4);
}

.overlay p {
  margin: 0;
  max-width: 320px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-dim);
}

.mode-row,
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn,
.chip,
.deck-btn {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(52, 106, 160, 0.6), rgba(16, 44, 78, 0.7));
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn {
  padding: 10px 16px;
}

.chip {
  padding: 7px 10px;
  font-size: 12px;
}

.btn:hover,
.chip:hover,
.deck-btn:hover {
  filter: brightness(1.14);
}

.btn:active,
.chip:active,
.deck-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.btn-primary {
  background: linear-gradient(180deg, rgba(110, 242, 208, 0.85), rgba(30, 140, 120, 0.85));
  color: #04231d;
  font-weight: 600;
  border-color: rgba(180, 255, 235, 0.5);
}

.chip.is-on {
  background: linear-gradient(180deg, rgba(127, 216, 255, 0.85), rgba(30, 96, 150, 0.85));
  color: #04202c;
  font-weight: 600;
}

/* ---------- 选关网格 ---------- */
#level-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 320px;
  margin-top: 4px;
}

#level-grid .cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 32, 58, 0.85);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease;
}

#level-grid .cell b {
  font-size: 13px;
}

#level-grid .cell i {
  font-style: normal;
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 1px;
}

#level-grid .cell.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

#level-grid .cell.done {
  border-color: rgba(110, 242, 208, 0.6);
  box-shadow: 0 0 14px rgba(110, 242, 208, 0.25);
}

#level-grid .cell:active {
  transform: translateY(2px);
}

.start-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-dim);
}

.stars-line {
  font-size: 18px !important;
  color: var(--gold) !important;
  letter-spacing: 3px;
}

/* ---------- 提示气泡 ---------- */
#toast {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translate(-50%, -8px);
  z-index: 5;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(8, 24, 44, 0.82);
  border: 1px solid rgba(127, 216, 255, 0.35);
  color: var(--ice);
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-shadow: 0 0 12px rgba(127, 216, 255, 0.5);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast.big {
  font-size: 18px;
  color: var(--mint);
  padding: 10px 22px;
  box-shadow: 0 0 26px rgba(110, 242, 208, 0.35);
}

/* ---------- 操作台 ---------- */
#deck {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}

.deck-btn {
  flex: 1;
  padding: 12px 8px;
  min-height: 44px;
  font-size: 13px;
}

.deck-btn.fire {
  background: linear-gradient(180deg, rgba(255, 160, 120, 0.9), rgba(180, 70, 50, 0.9));
  color: #2a0d06;
  font-weight: 700;
}

#key-tip,
#touch-tip {
  font-size: 11.5px;
  text-align: center;
}

#touch-tip {
  display: none;
}

/* ---------- 响应式：一体化掌机 ---------- */
@media (max-width: 899px) {
  #stage-core {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 4px;
  }

  #panel-left,
  #panel-right {
    display: none;
  }

  #mobile-hud {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
  }

  .mh-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .mh-item b {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 15px;
    color: var(--ice);
  }

  .mh-item i {
    font-style: normal;
    font-size: 10px;
    color: var(--ink-dim);
  }

  #key-tip {
    display: none;
  }

  #touch-tip {
    display: block;
  }
}

@media (max-width: 420px) {
  #stage-title {
    font-size: 15px;
    letter-spacing: 1px;
  }

  #level-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

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

  #toast {
    transition: opacity 0.001ms ease;
  }
}
