/* ===== Barrel Tower — fixed "night shift" theme =====
   Self-contained c-* chrome: this page ignores the center's light/dark mode
   and never loads shared/css/glass.css. Layout rule for the tall stage:
   size it from the viewport height so the whole tower fits on desktop. */

:root {
  --bt-bg: #070c17;
  --bt-panel: #121b2c;
  --bt-panel-2: #182338;
  --bt-line: rgba(255, 255, 255, .09);
  --bt-cream: #f4e6c8;
  --bt-muted: #97a4b8;
  --bt-amber: #f0b44c;
  --bt-amber-d: #b87a22;
  --bt-brown: #a86a32;
  --bt-red: #e2574c;
  --bt-mint: #6fd6a4;
  --bt-steel: #2a3854;
  --bt-ink: #0b1019;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body.bt-page {
  margin: 0;
  color: var(--bt-cream);
  background:
    radial-gradient(1200px 700px at 50% -10%, #1b2a44 0%, rgba(27, 42, 68, 0) 62%),
    radial-gradient(900px 600px at 85% 110%, #231d12 0%, rgba(35, 29, 18, 0) 60%),
    var(--bt-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.c-app {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px 24px;
}

/* ---------- Top bar ---------- */
.c-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--bt-line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(26, 38, 60, .94), rgba(15, 23, 38, .94));
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(10px);
}

.c-bar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.c-bar__brand svg { flex: none; }

.c-bar__title {
  margin: 0;
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.c-bar__stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.c-bar__stats .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--bt-line);
  border-radius: 999px;
  background: rgba(9, 15, 26, .6);
  color: var(--bt-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.c-bar__stats .stat b {
  color: var(--bt-cream);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.c-bar__stats .stat i {
  color: var(--bt-muted);
  font-style: normal;
  font-size: 11px;
}

.stat--lives { padding-right: 8px; }

.bt-lives {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transform: translateY(1px);
}

.bt-lives i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bt-amber);
  box-shadow: 0 0 8px rgba(240, 180, 76, .55);
  transition: background .2s, box-shadow .2s, opacity .2s;
}

.bt-lives i.is-off {
  background: #33415a;
  box-shadow: none;
  opacity: .6;
}

.c-bar__controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 10px;
  background: linear-gradient(180deg, #243450, #1a2740);
  color: var(--bt-cream);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 3px 8px rgba(0, 0, 0, .25);
  transition: transform .12s, border-color .15s, background .15s;
}

.c-btn:hover {
  border-color: rgba(240, 180, 76, .55);
  transform: translateY(-1px);
}

.c-btn:active { transform: translateY(0); }

.c-btn--primary {
  border-color: #f6c877;
  background: linear-gradient(180deg, #f7c46b, #e3a238);
  color: #221605;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 4px 12px rgba(240, 180, 76, .28);
}

.c-btn--primary:hover { background: linear-gradient(180deg, #ffd083, #edaf45); }

/* ---------- Board / stage ---------- */
.c-table {
  display: flex;
  justify-content: center;
  padding: 14px 0 0;
}

.bt-board {
  width: min(94vw, calc((100dvh - 218px) * .75), 500px);
  min-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
}

.bt-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 480 / 640;
  border: 4px solid #2b3a58;
  border-radius: 18px;
  background: #070c17;
  box-shadow:
    0 24px 50px rgba(0, 0, 0, .55),
    0 0 0 1px rgba(255, 255, 255, .06) inset,
    0 0 0 6px rgba(10, 16, 28, .55);
  overflow: hidden;
}

.bt-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bt-stage::after {
  /* faint scanline / CRT texture over the whole tower */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .022) 0 1px,
    rgba(0, 0, 0, 0) 1px 3px
  );
  mix-blend-mode: screen;
  opacity: .5;
}

.bt-hint {
  margin: 0;
  min-height: 17px;
  color: var(--bt-muted);
  font-size: 12px;
  font-weight: 550;
  text-align: center;
  letter-spacing: .01em;
}

/* ---------- Overlays ---------- */
.bt-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 9, 17, .72);
  backdrop-filter: blur(4px);
}

.bt-overlay[hidden] { display: none; }

.bt-card {
  width: min(100%, 330px);
  padding: 20px 20px 18px;
  border: 1px solid rgba(240, 180, 76, .28);
  border-radius: 16px;
  background: linear-gradient(180deg, #1a263c, #111a2a);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .07);
  text-align: center;
}

.bt-card__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.bt-card__icon svg { width: 72px; height: 72px; }

.bt-card h2 {
  margin: 2px 0 8px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .01em;
}

.bt-card p {
  margin: 0 0 16px;
  color: #c0cbdb;
  font-size: 13px;
  line-height: 1.5;
}

.bt-card .c-btn { min-width: 140px; }

.c-win__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Overlay action rows pack two buttons per line more comfortably. */
.bt-card .c-win__actions .c-btn { min-width: 0; flex: 1 1 118px; }

/* ---------- Tower picker ---------- */
.bt-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 4px;
}

.bt-level {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 9px;
  padding: 9px 11px;
  border: 1px solid rgba(240, 180, 76, .26);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(38, 52, 74, .9), rgba(22, 31, 45, .92));
  color: var(--bt-cream);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}

.bt-level b {
  grid-row: 1 / 3;
  min-width: 18px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  color: var(--bt-amber);
}

.bt-level span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.25;
}

.bt-level small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--bt-muted);
}

.bt-level small svg { width: 10px; height: 10px; }

.bt-level:hover:not(:disabled),
.bt-level:focus-visible {
  border-color: rgba(240, 180, 76, .62);
  transform: translateY(-1px);
}

.bt-level:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(240, 180, 76, .45); }

.bt-level.is-cleared {
  border-color: rgba(240, 180, 76, .68);
  box-shadow: inset 0 0 0 1px rgba(240, 180, 76, .32), 0 0 16px rgba(240, 180, 76, .12);
}

.bt-level.is-cleared b { color: #ffd479; }
.bt-level.is-cleared small { color: rgba(255, 212, 121, .9); }

.bt-level.is-next {
  border-color: rgba(240, 180, 76, .42);
}

.bt-level.is-next small { color: var(--bt-amber); }

.bt-level.is-locked {
  opacity: .45;
  cursor: not-allowed;
}

.bt-level.is-locked b { color: var(--bt-muted); }

/* ---------- Touch controls ---------- */
.bt-touch {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 0;
}

.bt-touch__group {
  display: flex;
  gap: 10px;
}

.bt-tb {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  background: rgba(30, 44, 68, .86);
  color: var(--bt-cream);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .09);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.bt-tb svg { width: 24px; height: 24px; }

.bt-tb:active { background: rgba(48, 68, 100, .95); transform: scale(.96); }

.bt-tb--jump {
  border-color: rgba(240, 180, 76, .6);
  background: linear-gradient(180deg, #f0b44c, #cf8f2e);
  color: #241705;
}

.bt-tb--jump:active { background: #ffca6d; }

@media (hover: none), (pointer: coarse) {
  .bt-touch { display: flex; }
  .bt-board { width: min(94vw, calc((100dvh - 300px) * .75), 460px); }
  .bt-hint { display: none; }
}

/* ---------- Modal (rules) ----------
   The overlay scrolls, never the card: no max-height/overflow on the panel. */
.c-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.c-modal[hidden] { display: none; }

.c-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, .74);
  backdrop-filter: blur(3px);
}

.c-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: auto;
  border: 1px solid rgba(240, 180, 76, .22);
  border-radius: 18px;
  background: linear-gradient(180deg, #18233a, #101827);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .07);
  color: var(--bt-cream);
}

.c-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--bt-line);
}

.c-modal__head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.c-modal__x {
  width: 32px;
  height: 32px;
  border: 1px solid var(--bt-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .05);
  color: var(--bt-cream);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.c-modal__x:hover { border-color: rgba(240, 180, 76, .5); }

.c-modal__body {
  padding: 14px 18px 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #c6d0df;
}

.c-modal__lead {
  margin: 0 0 14px;
  color: var(--bt-cream);
}

.c-modal__lead b { color: var(--bt-amber); }

.c-modal__body h3 {
  margin: 16px 0 6px;
  color: var(--bt-cream);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.c-modal__body ul {
  margin: 0;
  padding-left: 18px;
}

.c-modal__body li { margin: 5px 0; }

.c-modal__body b { color: #ffd489; }

.c-modal__body kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .07);
  color: var(--bt-cream);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

.c-modal__note {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 10px;
  color: var(--bt-muted);
  font-size: 12px;
}

.c-modal__foot {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .c-bar__stats { margin-left: 0; order: 3; width: 100%; }
  .c-bar__controls { margin-left: auto; }
}

@media (max-width: 560px) {
  .c-app { padding: 8px 10px 18px; }
  .c-bar { gap: 10px; padding: 9px 11px; }
  .c-bar__title { font-size: 17px; }
  .c-bar__stats .stat { padding: 4px 8px; font-size: 10px; }
  .c-bar__stats .stat b { font-size: 13px; }
  .c-btn { padding: 7px 11px; font-size: 12px; }
  .bt-board { width: min(96vw, calc((100dvh - 200px) * .75), 480px); }
  .bt-stage { border-width: 3px; border-radius: 15px; }
  .bt-card { padding: 16px 15px 15px; }
  .bt-card h2 { font-size: 21px; }
  .bt-card p { font-size: 12.5px; }
  .bt-touch { display: flex; }
  .bt-hint { display: none; }
}

@media (max-width: 380px) {
  .c-bar__controls { width: 100%; }
  .c-bar__controls .c-btn { flex: 1; }
  .c-bar__stats { gap: 6px; }
  .c-bar__stats .stat { flex: 1; justify-content: center; }
  .bt-tb { width: 50px; height: 50px; }
  .bt-levels { grid-template-columns: 1fr; }
}
