@font-face {
  font-family: 'PixelUI';
  src: url('../assets/fonts/pixel.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #070b06;
  --bg-2: #0c130b;
  --ink: #eaffea;
  --dim: #7d9a7d;
  --accent: #39ff6a;
  --accent-2: #21c74c;
  --gold: #ffcc33;
  --danger: #ff3b6b;
  --line: #1b2a19;
  --pixel: 'PixelUI', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --tg-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--pixel);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body { user-select: none; -webkit-user-select: none; }

.crt { position: relative; height: 100%; width: 100%; overflow: hidden; }

.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px);
  mix-blend-mode: multiply;
}
.crt::after {
  content: ''; position: fixed; inset: 0; z-index: 49; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
}

.frame {
  position: relative; z-index: 2;
  height: 100%; width: 100%;
  max-width: 560px; margin: 0 auto;
  padding: 10px 16px calc(10px + var(--tg-bottom));
  display: flex; flex-direction: column;
}

.screen { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.screen.is-active { display: flex; }

#screen-start, #screen-levelup, #screen-over, #screen-jackpot {
  align-items: center; justify-content: center;
  text-align: center; gap: 14px;
  overflow-y: auto;
}

.cover {
  display: block; width: min(58vw, 230px); height: auto;
  filter: drop-shadow(0 0 18px rgba(57,255,106,.22));
}

.sronly {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.h2 { font-size: clamp(12px, 4vw, 17px); margin: 0; line-height: 1.5; letter-spacing: .5px; }

.meme {
  margin: 0; font-size: clamp(8px, 2.9vw, 11px);
  line-height: 1.9; color: var(--dim); white-space: pre-line;
}

.fineprint { margin: 0; font-size: 7px; line-height: 1.8; color: #44593f; }

.ladderbox {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%; max-width: 330px; padding: 10px 10px 12px;
  background: var(--bg-2); box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000;
}
.ladder-title { margin: 0; font-size: 6.5px; letter-spacing: 1px; color: var(--dim); }
.ladder { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.rung {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 7px; min-width: 42px;
  font-size: 9px; color: var(--accent); background: #04240f;
  box-shadow: 0 0 0 2px var(--accent-2);
}
.rung i { font-style: normal; font-size: 5.5px; color: #4f7a52; letter-spacing: .5px; }
.rung-top {
  color: #2a1f04; background: var(--gold);
  box-shadow: 0 0 0 2px #fff0a8, 0 0 14px rgba(255,204,51,.55);
  animation: glow 1.6s steps(2) infinite;
}
.rung-top i { color: #5a4505; }
@keyframes glow { 0%, 60% { filter: brightness(1); } 61%, 100% { filter: brightness(1.25); } }
.ladder-note { margin: 0; font-size: 7px; line-height: 1.7; color: var(--dim); }

.howto {
  margin: 0; padding: 0; list-style: none;
  font-size: 7.5px; line-height: 2.2; color: #6c8a6a;
  text-align: left; max-width: 330px;
}
.howto li::before { content: '\25AE  '; color: var(--accent-2); }

.claim {
  margin: 0; padding: 7px 12px; max-width: 330px;
  font-size: 8px; line-height: 1.7; color: var(--gold);
  background: #1a1405; box-shadow: 0 0 0 2px #4a3a0c;
}

.fomo {
  margin: 0; display: flex; align-items: center; gap: 7px;
  font-size: 7.5px; line-height: 1.7; color: var(--accent);
}
.fomo::before {
  content: ''; width: 7px; height: 7px; flex: 0 0 auto;
  background: var(--accent); box-shadow: 0 0 6px var(--accent);
  animation: blip 1.4s steps(2) infinite;
}
@keyframes blip { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .25; } }

.refnote { margin: 0; font-size: 7.5px; line-height: 1.7; color: var(--accent); }
.refnote[hidden] { display: none; }

.langs { display: flex; gap: 8px; }
.lang {
  font-family: var(--pixel); font-size: 8px;
  color: var(--dim); background: var(--bg-2);
  border: 0; padding: 8px 12px; cursor: pointer;
  box-shadow: 0 0 0 2px var(--line);
}
.lang.is-on { color: #04240f; background: var(--accent); box-shadow: 0 0 0 2px #04240f; }

.panel {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg-2);
  box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000;
}
.panel-wide { width: 100%; max-width: 320px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 76px; }
.stat-k { font-size: 6.5px; color: var(--dim); letter-spacing: .5px; }
.stat-v { font-size: 10px; }
.stat-v.big { font-size: 15px; color: var(--accent); }

.burst {
  font-size: clamp(28px, 11vw, 50px);
  color: var(--accent);
  text-shadow: 4px 4px 0 #04240f, 8px 8px 0 rgba(0,0,0,.55);
  animation: pop .45s steps(3) 1;
}
.burst-red { color: var(--danger); text-shadow: 4px 4px 0 #2a0410, 8px 8px 0 rgba(0,0,0,.55); }
.burst-gold { color: var(--gold); text-shadow: 4px 4px 0 #2a1f04, 8px 8px 0 rgba(0,0,0,.55); }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }

.choice {
  margin: 0; max-width: 330px;
  font-size: 9px; line-height: 1.8; color: var(--ink);
}

.warn {
  max-width: 330px; padding: 10px 12px;
  font-size: 8px; line-height: 1.9; color: var(--gold);
  background: #1a1405; box-shadow: 0 0 0 2px #4a3a0c;
  white-space: pre-line;
}

.hud {
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; padding: 8px 6px;
  background: var(--bg-2);
  box-shadow: 0 0 0 2px var(--line);
}
.hud-col { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.hud-k { font-size: 6px; color: var(--dim); }
.hud-v { font-size: 9px; }
.hud-lives { color: var(--danger); letter-spacing: 1px; }
.hud-balance { color: var(--accent); }

.levelmeme {
  flex: 0 0 auto; margin: 7px 0 5px;
  font-size: 7.5px; line-height: 1.7; color: var(--dim); text-align: center;
  min-height: 13px;
}

.stage {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
#board {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000, 0 0 26px rgba(57,255,106,.12);
}

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; text-align: center;
  background: rgba(4,9,4,.9);
}
.overlay[hidden] { display: none; }
.overlay .o-title { font-size: 15px; color: var(--danger); }
.overlay .o-sub { font-size: 8px; line-height: 1.9; color: var(--dim); }

.controls { flex: 0 0 auto; padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }

.dpad {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 6px; width: 168px; margin: 0 auto;
}
.dbtn {
  font-family: var(--pixel); font-size: 12px;
  color: var(--accent); background: #0f1a0e;
  border: 0; padding: 14px 0; cursor: pointer;
  box-shadow: 0 0 0 2px var(--line), 0 3px 0 #000;
  touch-action: manipulation;
}
.dbtn:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--line), 0 1px 0 #000; }
.dbtn-up { grid-area: 1 / 2; }
.dbtn-left { grid-area: 2 / 1; }
.dbtn-mid { grid-area: 2 / 2; font-size: 9px; color: var(--dim); }
.dbtn-right { grid-area: 2 / 3; }
.dbtn-down { grid-area: 3 / 2; }

.actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }
.hud-cta { display: flex; flex-direction: column; gap: 8px; }

.btn, .cta-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  font-family: var(--pixel); font-size: 10px; line-height: 1.6;
  color: #04240f; background: var(--accent);
  border: 0; padding: 14px 16px; cursor: pointer; text-align: center;
  box-shadow: 0 0 0 2px #04240f, 0 4px 0 #000;
  transition: transform .06s steps(2);
}
.btn:active, .cta-wrap:active { transform: translateY(2px); box-shadow: 0 0 0 2px #04240f, 0 2px 0 #000; }

.btn.alt, .cta-wrap.alt {
  color: var(--gold); background: #1b1405;
  box-shadow: 0 0 0 2px var(--gold), 0 4px 0 #000;
}
.btn.ghost, .cta-wrap.ghost {
  color: var(--dim); background: var(--bg-2);
  box-shadow: 0 0 0 2px var(--line), 0 4px 0 #000;
}
.btn.danger, .cta-wrap.danger {
  color: #fff; background: #8c0f32;
  box-shadow: 0 0 0 2px var(--danger), 0 4px 0 #000;
}
.btn.qa, .cta-wrap.qa { font-size: 8px; padding: 10px 12px; }

.cta-wrap .ico, .btn .ico { font-size: 12px; }
.cta-wrap .lbl, .btn .lbl { letter-spacing: .5px; }
.cta-wrap .sub, .btn .sub { font-size: 6.5px; opacity: .75; }

.cta-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.cta-wrap > .cta-click {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  color: transparent;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  z-index: 1;
  border-radius: inherit;
}

.cta-wrap > .cta-click:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.cta-wrap > *:not(.cta-click) {
  pointer-events: none;
  position: relative;
  z-index: 2;
}

@media (max-height: 680px) {
  .frame { padding: 6px 12px calc(6px + var(--tg-bottom)); }
  .dbtn { padding: 10px 0; }
  .dpad { width: 150px; }
  .levelmeme { display: none; }
  .ladderbox {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%; max-width: 330px; padding: 10px 10px 12px;
  background: var(--bg-2); box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000;
}
.ladder-title { margin: 0; font-size: 6.5px; letter-spacing: 1px; color: var(--dim); }
.ladder { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.rung {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 7px; min-width: 42px;
  font-size: 9px; color: var(--accent); background: #04240f;
  box-shadow: 0 0 0 2px var(--accent-2);
}
.rung i { font-style: normal; font-size: 5.5px; color: #4f7a52; letter-spacing: .5px; }
.rung-top {
  color: #2a1f04; background: var(--gold);
  box-shadow: 0 0 0 2px #fff0a8, 0 0 14px rgba(255,204,51,.55);
  animation: glow 1.6s steps(2) infinite;
}
.rung-top i { color: #5a4505; }
@keyframes glow { 0%, 60% { filter: brightness(1); } 61%, 100% { filter: brightness(1.25); } }
.ladder-note { margin: 0; font-size: 7px; line-height: 1.7; color: var(--dim); }

.howto { font-size: 7px; line-height: 1.9; }
}
@media (min-width: 420px) {
  .hud-k { font-size: 7px; }
  .hud-v { font-size: 10px; }
}
