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

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

:root {
  --bg: #070b06;
  --bg-2: #0c130b;
  --ink: #eaffea;
  --dim: #9bb89b;
  --accent: #39ff6a;
  --accent-2: #21c74c;
  --gold: #ffcc33;
  --danger: #ff3b6b;
  --line: #1b2a19;
  --display: 'PixelUI', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --body: 'BodyUI', 'PixelUI', ui-monospace, Menlo, monospace;
  --fs-xs: 13px;
  --fs-sm: 16px;
  --fs-md: 18px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --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(--body);
  font-size: var(--fs-sm);
  line-height: 1.35;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

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 3px, rgba(0,0,0,.1) 3px 4px);
  opacity: .55;
}
.crt::after {
  content: ''; position: fixed; inset: 0; z-index: 49; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 58%, rgba(0,0,0,.38) 100%);
}

.frame {
  position: relative; z-index: 2;
  height: 100%; width: 100%;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(12px + 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;
  -webkit-overflow-scrolling: touch;
}

.cover {
  display: block; width: min(52vw, 210px); 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-family: var(--display);
  font-size: clamp(14px, 3.6vw, 18px);
  margin: 0; line-height: 1.45; letter-spacing: .5px;
}

.meme {
  margin: 0;
  font-size: clamp(15px, 3.8vw, 18px);
  line-height: 1.35; color: var(--dim); white-space: pre-line;
}

.fineprint {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.5; color: #5d7358;
}

.ladderbox {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 340px; padding: 12px 12px 14px;
  background: var(--bg-2); box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000;
}
.ladder-title {
  margin: 0;
  font-family: var(--display);
  font-size: 10px; letter-spacing: 1px; color: var(--dim);
}
.ladder { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.rung {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 9px; min-width: 52px;
  font-family: var(--display);
  font-size: 11px; color: var(--accent); background: #04240f;
  box-shadow: 0 0 0 2px var(--accent-2);
}
.rung i { font-family: var(--body); font-style: normal; font-size: 12px; color: #6f9472; 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: var(--fs-xs); line-height: 1.45; color: var(--dim); }

.howto {
  margin: 0; padding: 0; list-style: none;
  font-size: var(--fs-sm); line-height: 1.55; color: #86a484;
  text-align: left; max-width: 340px;
}
.howto li { margin: 0 0 4px; }
.howto li::before { content: '\25AE  '; color: var(--accent-2); font-family: var(--display); font-size: 10px; }

.claim {
  margin: 0; padding: 10px 14px; max-width: 340px;
  font-size: var(--fs-sm); line-height: 1.4; color: var(--gold);
  background: #1a1405; box-shadow: 0 0 0 2px #4a3a0c;
}

.fomo {
  margin: 0; display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); line-height: 1.4; color: var(--accent);
}
.fomo::before {
  content: ''; width: 8px; height: 8px; 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: var(--fs-sm); line-height: 1.4; color: var(--accent); }
.refnote[hidden] { display: none; }
.claim[hidden] { display: none; }

.langs { display: flex; gap: 10px; }
.lang {
  font-family: var(--display); font-size: 11px;
  color: var(--dim); background: var(--bg-2);
  border: 0; padding: 14px 18px; min-height: 48px; 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: 12px; justify-content: center; flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--bg-2);
  box-shadow: 0 0 0 2px var(--line), 0 0 0 4px #000;
}
.panel-wide { width: 100%; max-width: 340px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 84px; align-items: center; }
.stat-k {
  font-family: var(--display);
  font-size: 9px; color: var(--dim); letter-spacing: .5px;
}
.stat-v {
  font-family: var(--display);
  font-size: 12px;
}
.stat-v.big { font-size: 16px; color: var(--accent); }

.burst {
  font-family: var(--display);
  font-size: clamp(28px, 11vw, 48px);
  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: 340px;
  font-size: var(--fs-md); line-height: 1.4; color: var(--ink);
}

.warn {
  max-width: 340px; padding: 12px 14px;
  font-size: var(--fs-sm); line-height: 1.45; 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: 10px 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; min-width: 0; }
.hud-k {
  font-family: var(--display);
  font-size: 8px; color: var(--dim); letter-spacing: .4px;
}
.hud-v {
  font-family: var(--display);
  font-size: 11px;
}
.hud-lives { color: var(--danger); }
.hud-balance { color: var(--accent); }

.lives {
  display: inline-flex; gap: 3px; align-items: center; justify-content: center;
  vertical-align: middle;
}
.lives i {
  display: inline-block;
  width: 9px; height: 9px;
  background: var(--danger);
  box-shadow: inset -1px -1px 0 #b0123c, 1px 1px 0 #000;
  clip-path: polygon(50% 12%, 61% 0, 80% 0, 100% 20%, 100% 40%, 50% 100%, 0 40%, 0 20%, 20% 0, 39% 0);
}
.lives-count {
  font-family: var(--display);
  font-size: 11px;
  color: var(--danger);
}
.lives-empty { color: var(--dim); font-family: var(--display); font-size: 11px; }

.levelmeme {
  flex: 0 0 auto; margin: 8px 0 6px;
  font-size: var(--fs-xs); line-height: 1.4; color: var(--dim); text-align: center;
  min-height: 18px;
}

.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: 14px; padding: 16px; text-align: center;
  background: rgba(4,9,4,.92);
}
.overlay[hidden] { display: none; }
.overlay .o-title {
  font-family: var(--display);
  font-size: 16px; color: var(--danger);
}
.overlay .o-sub {
  font-size: var(--fs-sm); line-height: 1.45; color: var(--dim);
  max-width: 280px;
}
.overlay .actions { max-width: 280px; }

.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: 8px; width: 220px; margin: 0 auto;
}
.dbtn {
  font-family: var(--display); font-size: 14px;
  color: var(--accent); background: #0f1a0e;
  border: 0; padding: 0; min-height: 56px; cursor: pointer;
  box-shadow: 0 0 0 2px var(--line), 0 3px 0 #000;
  touch-action: manipulation;
  display: flex; align-items: center; justify-content: center;
}
.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: 12px; color: var(--dim); }
.dbtn-right { grid-area: 2 / 3; }
.dbtn-down { grid-area: 3 / 2; }

.arr {
  display: block;
  width: 0; height: 0;
  border-style: solid;
}
.arr-up {
  border-width: 0 8px 12px 8px;
  border-color: transparent transparent var(--accent) transparent;
}
.arr-down {
  border-width: 12px 8px 0 8px;
  border-color: var(--accent) transparent transparent transparent;
}
.arr-left {
  border-width: 8px 12px 8px 0;
  border-color: transparent var(--accent) transparent transparent;
}
.arr-right {
  border-width: 8px 0 8px 12px;
  border-color: transparent transparent transparent var(--accent);
}

.actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; }
.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(--display); font-size: 12px; line-height: 1.45;
  color: #04240f; background: var(--accent);
  border: 0; padding: 16px 18px; min-height: 56px; 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: 11px; padding: 14px 16px; min-height: 48px; }

.cta-wrap .ico, .btn .ico {
  font-family: var(--body);
  font-size: 18px; line-height: 1;
}
.cta-wrap .lbl, .btn .lbl { letter-spacing: .5px; }
.cta-wrap .sub, .btn .sub {
  font-family: var(--body);
  font-size: 14px; opacity: .8; letter-spacing: 0; line-height: 1.25;
}

.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)); }
  .cover { width: min(42vw, 160px); }
  .dbtn { min-height: 48px; }
  .dpad { width: 196px; gap: 7px; }
  .btn, .cta-wrap { padding: 14px 16px; min-height: 52px; font-size: 11px; }
  .levelmeme { display: none; }
  .howto { font-size: var(--fs-xs); }
}
@media (min-width: 420px) {
  .hud-k { font-size: 9px; }
  .hud-v { font-size: 12px; }
}
