/* Nocna Bocznica — a steam depot at night. Tokens first, then surfaces. */

@font-face {
  font-family: 'Bevan';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../assets/fonts/bevan-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Bevan';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../assets/fonts/bevan-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Archivo Narrow';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../../assets/fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo Narrow';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../../assets/fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* One depot lamp, wet ballast, cast iron. Everything else is tinted from that. */
  --soot-900: #0a0c0e;
  --soot-800: #12171a;
  --soot-700: #171d21;
  --soot-600: #1f262b;
  --brass-300: #e8b868;
  --brass-deep: #8a6420;
  --steam: #ede7da;
  --steam-dim: #b6c0c6;
  --signal: #c8453a;
  --signal-deep: #7e241c;
  --enamel: #e4dac6;
  --ink: #191512;
  --radius-lg: 26px;
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0.9, 0.25, 1);
  --display: 'Bevan', 'Rockwell', Georgia, serif;
  --ui: 'Archivo Narrow', 'Arial Narrow', system-ui, -apple-system, sans-serif;
  --stroke-steel: rgba(182, 192, 198, 0.12);
  --stroke-steel-strong: rgba(190, 200, 206, 0.2);
  --stroke-light: rgba(237, 231, 218, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--soot-900);
  color: var(--steam);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

h1,
h2,
p {
  margin: 0;
}

/* ------------------------------------------------------------- atmosphere */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(64% 48% at 14% 4%, rgba(255, 186, 104, 0.3) 0%, rgba(255, 176, 90, 0.07) 42%, transparent 74%),
    radial-gradient(120% 80% at 50% -18%, #1b2429 0%, #10161a 46%, #080a0c 100%),
    linear-gradient(180deg, #0d1114, #080a0b);
  overflow: hidden;
}
.bokeh {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.55;
  will-change: transform;
}
.bokeh-a {
  width: 320px;
  height: 260px;
  top: 1%;
  left: -14%;
  background: radial-gradient(circle, rgba(255, 190, 110, 0.72), transparent 66%);
}
.bokeh-b {
  width: 540px;
  height: 190px;
  top: 50%;
  left: -22%;
  background: radial-gradient(ellipse, rgba(198, 216, 222, 0.26), transparent 70%);
  filter: blur(30px);
}
.bokeh-c {
  width: 140px;
  height: 140px;
  top: 18%;
  right: -8%;
  background: radial-gradient(circle, rgba(200, 69, 58, 0.62), transparent 66%);
}
.atmosphere::after {
  content: '';
  position: absolute;
  inset: -20% -30% 30% -40%;
  background: linear-gradient(118deg, rgba(255, 196, 128, 0.13) 0%, rgba(255, 186, 110, 0.05) 26%, transparent 52%);
  pointer-events: none;
}
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ------------------------------------------------------------------ shell */
#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));
}
body[data-screen='game'] #app {
  padding-left: 12px;
  padding-right: 12px;
}
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 1px solid rgba(237, 231, 218, 0.04);
  border-right: 1px solid rgba(237, 231, 218, 0.04);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  padding: inherit;
  display: none;
  flex-direction: column;
}
.screen.is-active {
  display: flex;
  animation: screenIn 0.36s var(--ease);
}
@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ------------------------------------------------------------------- menu */
.menu-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding-top: 6px;
}
.brand-mark {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(29px, 8.8vw, 40px);
  letter-spacing: 0.005em;
  line-height: 0.96;
  text-transform: uppercase;
  color: var(--brass-300);
  text-shadow:
    0 1px 0 rgba(8, 10, 12, 0.9),
    0 12px 28px rgba(0, 0, 0, 0.75);
}
.brand-sub {
  margin-top: 7px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(214, 222, 226, 0.86);
}

.gift {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(46, 54, 59, 0.95), rgba(19, 24, 27, 0.95));
  border: 1px solid var(--stroke-steel-strong);
  color: rgba(226, 233, 236, 0.86);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px -12px rgba(0, 0, 0, 0.8);
  animation: giftPulse 2.6s ease-in-out infinite;
}
.gift-icon {
  width: 16px;
  height: 16px;
}
@keyframes giftPulse {
  50% {
    transform: translateY(-2px);
  }
}

.hero {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  padding: 18px 0 8px;
}
.hero-art {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: auto;
  min-height: 128px;
  margin-bottom: 2px;
}
.hero-art img {
  width: 32%;
  max-width: 126px;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.7));
  animation: float 6s ease-in-out infinite;
}
.hero-art img:nth-child(1) {
  transform: rotate(-8deg) translateY(6px);
  animation-delay: -1s;
}
.hero-art img:nth-child(2) {
  z-index: 1;
  transform: scale(1.16);
  animation-delay: -3s;
}
.hero-art img:nth-child(3) {
  transform: rotate(7deg) translateY(8px);
  animation-delay: -5s;
}
@keyframes float {
  50% {
    translate: 0 -10px;
  }
}

.hero-card {
  position: relative;
  padding: 15px 18px 13px;
  border-radius: 12px;
  background: linear-gradient(178deg, #efe6d2 0%, #ded3ba 62%, #cdc0a4 100%);
  border: 1px solid rgba(120, 100, 60, 0.55);
  box-shadow:
    0 26px 48px -26px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 8px rgba(90, 78, 52, 0.3);
  color: var(--ink);
}
.hero-card::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 8px;
  border: 1px solid rgba(60, 48, 28, 0.3);
  pointer-events: none;
}
.hero-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #463718;
}
.hero-level {
  margin-top: 3px;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(25, 21, 18, 0.82);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.hero-level strong {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
}
.hero-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #3b3222;
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.stat b {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-dim {
  color: rgba(59, 50, 34, 0.92);
}
.star-ico {
  width: 14px;
  height: 14px;
}
.streak {
  margin-top: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--signal-deep);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 10px;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 2px;
  font-size: 12px;
  color: rgba(182, 192, 198, 0.66);
}
.coin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.coin-ico {
  width: 15px;
  height: 15px;
}
.coin b {
  color: var(--brass-300);
  font-variant-numeric: tabular-nums;
}
.coin-label {
  color: rgba(200, 208, 213, 0.72);
}

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition:
    transform 0.16s var(--ease),
    filter 0.16s ease,
    background 0.16s ease;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.45;
}
.btn-primary {
  background: linear-gradient(180deg, #d4503f 0%, #b83a2c 48%, #7e241c 100%);
  color: #fff6ec;
  border: 1px solid rgba(255, 232, 206, 0.22);
  box-shadow:
    0 16px 28px -14px rgba(168, 50, 40, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 8px rgba(60, 16, 10, 0.5);
  text-shadow: 0 1px 2px rgba(60, 16, 10, 0.5);
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 1px 1px 55% 1px;
  border-radius: 9px 9px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn-xl {
  min-height: 62px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.btn-ghost {
  background: linear-gradient(180deg, rgba(31, 38, 43, 0.9), rgba(14, 18, 20, 0.9));
  border: 1px solid var(--stroke-steel-strong);
  color: var(--brass-300);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.btn-quiet {
  min-height: 40px;
  font-size: 13px;
  color: rgba(237, 231, 218, 0.6);
}
.btn-danger {
  background: rgba(160, 45, 36, 0.16);
  border: 1px solid rgba(200, 69, 58, 0.4);
  color: #efcabc;
  min-height: 46px;
}
.btn-danger.is-armed {
  background: rgba(160, 45, 36, 0.4);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: rgba(237, 231, 218, 0.7);
  background: rgba(237, 231, 218, 0.04);
  border: 1px solid rgba(237, 231, 218, 0.07);
  transition: transform 0.16s var(--ease);
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* -------------------------------------------------------------------- map */
.map-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 10px;
}
.map-title {
  flex: 1;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.map-stars {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  font-size: 14px;
  color: var(--brass-300);
  font-variant-numeric: tabular-nums;
}
.map-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
  scrollbar-width: none;
}
.map-list::-webkit-scrollbar {
  display: none;
}
.chapter {
  margin-bottom: 20px;
}
.chapter-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(228, 234, 238, 0.9);
  padding: 6px 2px 10px;
}
.chapter-range {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(212, 220, 225, 0.78);
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.level-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: linear-gradient(180deg, #e7ddc8, #d3c6a8);
  border: 1px solid rgba(60, 48, 28, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 14px -12px rgba(0, 0, 0, 0.95);
  transition:
    transform 0.16s var(--ease),
    border-color 0.2s ease;
  padding: 6px 4px;
}
.level-tile:active {
  transform: scale(0.95);
}
.tile-num {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1;
}
.tile-stars {
  display: flex;
  gap: 2px;
  height: 7px;
}
.tile-stars i {
  width: 7px;
  height: 7px;
  background: rgba(80, 64, 38, 0.25);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.tile-stars i.on {
  background: linear-gradient(180deg, #b98a2c, #7c5a14);
}
.level-tile.is-current {
  border-color: var(--brass-300);
  background: linear-gradient(180deg, #f6eeda, #e2d6b8);
  box-shadow:
    0 0 0 1px rgba(232, 184, 104, 0.55),
    0 14px 26px -16px rgba(232, 184, 104, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.level-tile.is-current .tile-num {
  color: var(--ink);
}
.level-tile.is-locked {
  background: rgba(11, 14, 16, 0.6);
  border: 1px dashed rgba(182, 192, 198, 0.22);
  box-shadow: none;
}
.level-tile.is-locked .tile-num {
  font-size: 15px;
  color: rgba(182, 192, 198, 0.34);
}
.level-tile.is-locked .tile-stars i {
  background: rgba(182, 192, 198, 0.12);
}

/* ------------------------------------------------------------------- game */
.screen-game {
  gap: 10px;
  justify-content: flex-start;
}
.game-top,
.game-bottom {
  gap: 6px;
  margin-top: auto;
}
.game-bottom {
  gap: 6px;
}
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.hud-mid {
  flex: 1;
  min-width: 0;
}
.hud-level {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-300);
  text-shadow: 0 1px 3px rgba(8, 6, 3, 0.9);
}
.hud-name {
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(237, 231, 218, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-moves-wrap {
  display: grid;
  justify-items: center;
  min-width: 64px;
  padding: 5px 10px 4px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(31, 38, 43, 0.92), rgba(12, 16, 18, 0.95));
  border: 1px solid var(--stroke-steel-strong);
  box-shadow:
    inset 0 1px 0 rgba(220, 232, 238, 0.1),
    inset 0 -8px 12px -10px rgba(0, 0, 0, 0.9);
}
.hud-moves {
  font-family: var(--display);
  font-size: 27px;
  font-weight: 400;
  line-height: 0.95;
  color: var(--brass-300);
  font-variant-numeric: tabular-nums;
}
.hud-moves.is-low {
  color: #e0655a;
  animation: lowPulse 1.4s ease-in-out infinite;
}
.hud-moves.bump {
  animation: bump 0.28s var(--ease);
}
.hud-moves-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(237, 231, 218, 0.68);
}
@keyframes bump {
  40% {
    transform: scale(1.18);
  }
}
@keyframes lowPulse {
  50% {
    opacity: 0.55;
  }
}

.goals-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.goals {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.goal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px 0 4px;
  border-radius: 9px;
  background: rgba(4, 6, 8, 0.42);
  box-shadow:
    inset 0 2px 5px -2px rgba(0, 0, 0, 0.9),
    inset 0 -1px 0 rgba(220, 232, 238, 0.06);
  transition:
    background 0.24s ease,
    box-shadow 0.24s ease;
}
.goal-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.goal-count {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(237, 231, 218, 0.82);
  letter-spacing: 0.01em;
}
.goal.is-done {
  background: rgba(140, 170, 110, 0.14);
  box-shadow:
    inset 0 2px 5px -2px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(140, 170, 110, 0.28);
}
.goal.is-done .goal-count {
  color: #c6d8b0;
}
.score-unit {
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(184, 194, 200, 0.7);
}
.score-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--brass-300);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}


.sugar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sugar-track {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(214, 228, 236, 0.07), rgba(214, 228, 236, 0) 48%),
    #161B1F;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(190, 200, 206, 0.14),
    inset 0 -1px 0 rgba(214, 228, 236, 0.08);
  overflow: hidden;
}
.sugar-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(10, 12, 14, 0.55) 0 1px, transparent 1px 9px);
  pointer-events: none;
}
.sugar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #c8453a 0%, #f0a24a 55%, #ffe9a8 100%);
  transition: width 0.4s var(--ease);
  box-shadow: 0 0 12px rgba(255, 176, 90, 0.6);
}
.sugar-label {
  min-width: 96px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(237, 231, 218, 0.68);
  white-space: nowrap;
}
.sugar-track.is-active {
  background: rgba(232, 184, 104, 0.24);
  box-shadow: 0 0 16px rgba(232, 184, 104, 0.5);
}
body.is-sugar .board-wrap {
  position: relative;
  flex: 0 1 auto;
  min-height: 210px;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  align-self: center;
  margin-block: 6px;
  border-radius: 14px;
  background:
    radial-gradient(120% 90% at 30% 0%, rgba(255, 214, 150, 0.07), transparent 55%),
    linear-gradient(180deg, rgba(31, 38, 43, 0.95), rgba(11, 14, 16, 0.98));
  border: 1px solid rgba(190, 200, 206, 0.14);
  box-shadow:
    0 26px 55px -26px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -26px 44px -32px rgba(0, 0, 0, 0.95);
  padding: 8px;
  overflow: hidden;
  transition: box-shadow 0.4s ease;
}
.board-wrap::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 10px;
  pointer-events: none;
  background:
    radial-gradient(circle 2.5px at 9px 9px, rgba(232, 184, 104, 0.6) 0 40%, transparent 100%),
    radial-gradient(circle 2.5px at calc(100% - 9px) 9px, rgba(232, 184, 104, 0.6) 0 40%, transparent 100%),
    radial-gradient(circle 2.5px at 9px calc(100% - 9px), rgba(232, 184, 104, 0.6) 0 40%, transparent 100%),
    radial-gradient(circle 2.5px at calc(100% - 9px) calc(100% - 9px), rgba(232, 184, 104, 0.6) 0 40%, transparent 100%);
}

.board-wrap {
  position: relative;
  flex: 0 1 auto;
  min-height: 210px;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  align-self: center;
  margin-block: auto;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 90% at 30% 0%, rgba(237, 231, 218, 0.07), transparent 55%),
    linear-gradient(180deg, rgba(31, 38, 43, 0.88), rgba(16, 19, 22, 0.94));
  border: 1px solid rgba(190, 200, 206, 0.1);
  box-shadow:
    0 26px 55px -26px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -20px 40px -30px rgba(0, 0, 0, 0.55);
  padding: 8px;
  overflow: hidden;
  transition: box-shadow 0.4s ease;
}
.board-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 32%);
}
#board {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  display: block;
  border-radius: 18px;
  touch-action: none;
  cursor: grab;
}
#board.is-pressed {
  cursor: grabbing;
}

.objective {
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgba(237, 231, 218, 0.55);
  text-align: center;
  padding: 2px 8px 0;
}
.objective b {
  color: var(--brass-300);
  font-weight: 600;
}
.fatal {
  position: fixed;
  inset: auto 12px 12px 12px;
  z-index: 99;
  padding: 12px 14px;
  border-radius: 14px;
  background: #3a1a12;
  border: 1px solid #c8453a;
  color: #f3d9d0;
  font: 12px/1.4 ui-monospace, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 40vh;
  overflow-y: auto;
}

.hint {
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  color: rgba(237, 231, 218, 0.68);
  padding: 0 8px;
}

.boosters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-bottom: 2px;
}
.booster {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(237, 231, 218, 0.07), rgba(237, 231, 218, 0.02));
  border: 1px solid rgba(237, 231, 218, 0.08);
  transition:
    transform 0.16s var(--ease),
    border-color 0.2s ease;
}
.booster:active {
  transform: scale(0.95);
}
.booster svg {
  width: 20px;
  height: 20px;
  color: var(--brass-300);
}
.booster-name {
  font-size: 11px;
  font-weight: 500;
  color: rgba(237, 231, 218, 0.72);
}
.booster-count.is-price {
  color: var(--brass-300);
}
.booster-count {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brass-300);
  font-variant-numeric: tabular-nums;
}
.booster.is-empty .booster-count {
  color: rgba(232, 184, 104, 0.55);
}
.booster.is-armed {
  border-color: rgba(200, 69, 58, 0.7);
  background: rgba(200, 69, 58, 0.16);
  box-shadow: 0 0 0 1px rgba(200, 69, 58, 0.4), 0 10px 22px -12px rgba(200, 69, 58, 0.9);
}

/* ------------------------------------------------------------ combo + toast */
.combo {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}
.combo strong {
  font-family: var(--display);
  font-size: clamp(24px, 7.4vw, 34px);
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #ffe2ae;
  text-shadow:
    0 2px 0 rgba(60, 36, 0, 0.45),
    0 10px 26px rgba(0, 0, 0, 0.7);
}
.combo span {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(237, 231, 218, 0.66);
}
.combo.is-on {
  animation: comboIn 1.05s var(--ease) forwards;
}
@keyframes comboIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
  }
  32% {
    transform: translate(-50%, -50%) scale(1);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(1);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 40;
  max-width: min(88vw, 400px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(10, 13, 15, 0.94);
  border: 1px solid var(--stroke-steel);
  color: var(--steam);
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.24s ease,
    transform 0.24s var(--ease);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
}
.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 12, 0.72);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.overlay.is-on {
  opacity: 1;
}
.overlay-card {
  width: min(100%, 400px);
  padding: 22px 20px 20px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(200, 69, 58, 0.16), transparent 60%),
    linear-gradient(180deg, #171d21, #141a1d);
  border: 1px solid var(--stroke-steel-strong);
  box-shadow:
    0 40px 80px -30px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s var(--ease);
}
.overlay.is-on .overlay-card {
  transform: none;
}
.overlay-card h2 {
  font-family: var(--display);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.muted {
  margin-top: 4px;
  font-size: 12.5px;
  color: rgba(182, 192, 198, 0.66);
  min-height: 1.2em;
}
.end-next {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--brass-300);
}

.stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.stars i {
  width: 38px;
  height: 38px;
  background: rgba(237, 231, 218, 0.1);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.stars i.on {
  background: linear-gradient(180deg, #f6ead0, #e8b868 45%, #a87e2a);
  filter: drop-shadow(0 6px 14px rgba(232, 184, 104, 0.5));
  animation: starPop 0.5s var(--ease) both;
}
@keyframes starPop {
  0% {
    transform: scale(0.4) rotate(-18deg);
  }
  60% {
    transform: scale(1.16) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}
.end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0 18px;
}
.end-stats div {
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(237, 231, 218, 0.04);
  border: 1px solid rgba(237, 231, 218, 0.06);
}
.end-stats dt {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(210, 218, 223, 0.74);
}
.end-stats dd {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  color: var(--steam);
  font-variant-numeric: tabular-nums;
}
.end-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ------------------------------------------------------------------ sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 8, 10, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.sheet.is-on {
  opacity: 1;
}
.sheet-panel {
  width: min(100%, 480px);
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #171d21, #13181b);
  border: 1px solid var(--stroke-steel-strong);
  border-bottom: 0;
  transform: translateY(100%);
  transition: transform 0.28s var(--ease);
}
.sheet.is-on .sheet-panel {
  transform: none;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sheet-head h2 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
}
.setting {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(237, 231, 218, 0.06);
  font-size: 14px;
  color: rgba(237, 231, 218, 0.86);
}
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(237, 231, 218, 0.12);
  transition: background 0.2s ease;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e6e7e3;
  transition: transform 0.2s var(--ease);
}
.setting.is-on .switch {
  background: linear-gradient(180deg, #e0655a, #7e241c);
}
.setting.is-on .switch::after {
  transform: translateX(18px);
}
.legend-intro {
  margin: 2px 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(237, 231, 218, 0.72);
}
.legend-title {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(228, 234, 238, 0.9);
}
.legend-row {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 2px 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(190, 200, 206, 0.08);
}
.legend-row img {
  grid-row: span 2;
}
.legend-row b {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.legend-row span {
  grid-column: 2;
  font-size: 12px;
  line-height: 1.3;
  color: rgba(206, 214, 219, 0.62);
}
.sheet-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0 4px;
}
.sheet-stats div {
  padding: 8px 2px;
  border-radius: 12px;
  background: rgba(237, 231, 218, 0.04);
  border: 1px solid rgba(237, 231, 218, 0.06);
  text-align: center;
}
.sheet-stats dt {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(206, 214, 219, 0.7);
}
.sheet-stats dd {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--steam);
  font-variant-numeric: tabular-nums;
}
.endless-teaser {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(232, 184, 104, 0.08), rgba(200, 69, 58, 0.06));
  border: 1px dashed rgba(182, 192, 198, 0.24);
}
.endless-teaser .chapter-title {
  padding: 0 0 6px;
}
.endless-teaser p {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(237, 231, 218, 0.55);
}
.sheet-panel .btn {
  margin-top: 12px;
}
.fine {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(206, 214, 219, 0.64);
  text-align: center;
  text-wrap: balance;
}

:focus-visible {
  outline: 2px solid var(--brass-300);
  outline-offset: 2px;
  border-radius: 10px;
}

/* ---------------------------------------------------------------- utility */
[hidden] {
  display: none !important;
}

@media (min-width: 620px) {
  body {
    font-size: 16px;
  }
  #app {
    padding-left: 22px;
    padding-right: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* the in-game switch must do what the OS setting does */
html.rm *,
html.rm *::before,
html.rm *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
.overlay-card:focus,
.sheet-panel:focus {
  outline: none;
}
