@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: #14100c;
  --bg-2: #1e1812;
  --ink: #fff8e8;
  --dim: #d8c8a8;
  --accent: #3dff72;
  --accent-2: #1db954;
  --gold: #ffd24a;
  --danger: #ff4d75;
  --sand: #e2c48a;
  --line: #6a5438;
  --display: 'PixelUI', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --body: 'BodyUI', 'PixelUI', ui-monospace, Menlo, monospace;
  --fs-xs: 14px;
  --fs-sm: 17px;
  --fs-md: 19px;
  --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:
    radial-gradient(ellipse at 50% 0%, #2a2016 0%, var(--bg) 55%),
    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 5px, rgba(0,0,0,.05) 5px 6px);
  opacity: .22;
}
body.is-game .scanlines,
body.is-game .crt::after { opacity: 0; }

.crt::after {
  content: ''; position: fixed; inset: 0; z-index: 49; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 65%, rgba(0,0,0,.22) 100%);
}

.frame {
  position: relative; z-index: 2;
  height: 100%; width: 100%;
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(14px + 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: flex-start;
  text-align: center; gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 6px;
}

.hero {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%;
}
.hero-art {
  position: relative;
  width: min(42vw, 168px);
}
.cover {
  display: block; width: 100%; height: auto;
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--line), 0 10px 28px rgba(0,0,0,.45);
  filter: saturate(1.1) contrast(1.05);
}
.hero-digger {
  position: absolute;
  right: -10px; bottom: -6px;
  width: 44px; height: 52px;
  image-rendering: pixelated;
  background:
    linear-gradient(#2a1a0a 0 8px, transparent 8px) 14px 0 / 16px 8px no-repeat,
    linear-gradient(#f0c8a0 0 14px, transparent 14px) 12px 8px / 20px 14px no-repeat,
    linear-gradient(#1a0a04 0 3px, transparent 3px) 16px 12px / 4px 3px no-repeat,
    linear-gradient(#1a0a04 0 3px, transparent 3px) 24px 12px / 4px 3px no-repeat,
    linear-gradient(#3dff72 0 16px, transparent 16px) 12px 22px / 20px 16px no-repeat,
    linear-gradient(#147a32 0 12px, transparent 12px) 10px 36px / 10px 12px no-repeat,
    linear-gradient(#147a32 0 12px, transparent 12px) 24px 36px / 10px 12px no-repeat,
    linear-gradient(#6b4423 0 18px, transparent 18px) 32px 20px / 5px 18px no-repeat,
    linear-gradient(#9aa3ad 0 8px, transparent 8px) 28px 34px / 14px 8px no-repeat;
  animation: digger-bob 1.2s steps(2) infinite;
  filter: drop-shadow(0 3px 0 #000);
}
@keyframes digger-bob {
  0%, 49% { transform: translateY(0); }
  50%, 100% { transform: translateY(2px); }
}

.brand {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: clamp(22px, 7vw, 34px);
  line-height: 1.15;
  letter-spacing: 1px;
  color: var(--ink);
  text-shadow: 3px 3px 0 #000, 0 0 18px rgba(61,255,114,.18);
}

.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;
  max-width: 340px;
  font-size: clamp(16px, 4vw, 19px);
  line-height: 1.35; color: var(--dim); white-space: pre-line;
}

.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;
  animation: claimpulse 2.2s steps(2) infinite;
}
@keyframes claimpulse {
  0%, 70% { box-shadow: 0 0 0 2px #4a3a0c; }
  71%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(255,210,74,.35); }
}

.tip {
  margin: 0;
  max-width: 340px;
  padding: 10px 14px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--ink);
  background: linear-gradient(180deg, #24301c, #1a2414);
  box-shadow: 0 0 0 2px var(--accent-2);
}

.fineprint {
  margin: 0 0 8px;
  font-size: var(--fs-xs);
  line-height: 1.5; color: #7a6d58;
}

.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); }

.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;
}
.fomo-pulse { font-size: var(--fs-md); color: var(--gold); }
.fomo-pulse::before { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.fomo-hot {
  margin: -4px 0 0;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: .4px;
  color: var(--danger);
  text-shadow: 0 0 10px rgba(255,77,117,.35);
}
@keyframes blip { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .25; } }

.pressure {
  margin: 0; max-width: 340px;
  font-size: var(--fs-sm); line-height: 1.4; color: var(--danger);
}

.mummy-banner {
  flex: 0 0 auto;
  margin: 0 0 6px;
  padding: 8px 12px;
  text-align: center;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 1px;
  color: #2a1008;
  background: var(--gold);
  box-shadow: 0 0 0 2px #fff0a8, 0 0 18px rgba(255,210,74,.45);
  animation: mummyflash .7s steps(2) infinite;
}
.mummy-banner[hidden] { display: none; }
@keyframes mummyflash {
  0%, 55% { filter: brightness(1); }
  56%, 100% { filter: brightness(1.25); }
}

body.is-mummy #board {
  box-shadow: 0 0 0 3px var(--danger), 0 0 0 7px #000, 0 0 28px rgba(255,77,117,.35);
}
body.is-mummy .trapchip {
  animation: blip 0.7s steps(2) infinite;
}

.refnote { margin: 0; font-size: var(--fs-sm); line-height: 1.4; color: var(--accent); }
.refnote[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 8px;
  background: linear-gradient(180deg, #241c14, 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-col-focus {
  background: rgba(61,255,114,.08);
  box-shadow: inset 0 0 0 1px rgba(61,255,114,.35);
  border-radius: 4px;
  padding: 4px 2px;
}
.hud-k {
  font-family: var(--display);
  font-size: 8px; color: var(--dim); letter-spacing: .4px;
}
.hud-v {
  font-family: var(--display);
  font-size: 12px;
}
.hud-coins { color: var(--gold); font-size: 14px; }
.hud-coins.is-pop { animation: coinpop .35s steps(3) 1; }
@keyframes coinpop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.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: 10px; height: 10px;
  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: 12px;
  color: var(--danger);
}
.lives-empty { color: var(--dim); font-family: var(--display); font-size: 12px; }

.gamebar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 8px 0;
  min-height: 28px;
}
.levelmeme {
  margin: 0; flex: 1 1 auto; min-width: 0;
  font-size: var(--fs-xs); line-height: 1.35; color: var(--dim);
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trapchip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  font-family: var(--display); font-size: 12px; color: var(--ink);
  background: #2a1218;
  box-shadow: 0 0 0 2px var(--danger);
}
.trapchip i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px #fff0f4 inset;
}

.stage {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(226,196,138,.08), transparent 60%);
}
.stage.is-shake { animation: boardshake .2s steps(2) 1; }
.stage.is-shake-hard { animation: boardshake-hard .4s steps(3) 1; }
@keyframes boardshake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px); }
  75% { transform: translate(3px, -1px); }
}
@keyframes boardshake-hard {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}

.loot-title {
  margin: 0;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--dim);
}
.lootrow {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  min-height: 36px;
}
.lootrow[hidden] { display: none; }
.loot-coin {
  width: 36px; height: 36px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 #000);
  animation: pop .4s steps(3) 1;
}
.loot-fallback {
  font-family: var(--display);
  font-size: 11px;
  color: var(--gold);
  padding: 10px 8px;
  background: #1b1405;
  box-shadow: 0 0 0 2px var(--gold);
}
#board {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  border-radius: 6px;
  box-shadow: 0 0 0 3px #c9a66a, 0 0 0 7px #000, 0 12px 30px rgba(0,0,0,.4);
}

.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(10,8,4,.9);
  backdrop-filter: blur(2px);
}
.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; }

.toolrow {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 8px; width: 100%; max-width: 360px; margin: 0 auto;
}
.tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--display); font-size: 12px;
  color: var(--ink); background: #2a2118;
  border: 0; padding: 12px 10px; min-height: 58px; cursor: pointer;
  box-shadow: 0 0 0 2px var(--line), 0 3px 0 #000;
  touch-action: manipulation;
  letter-spacing: .4px;
}
.tbtn:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--line), 0 1px 0 #000; }
.tbtn.is-on {
  color: #04240f; background: var(--accent);
  box-shadow: 0 0 0 2px #04240f, 0 3px 0 #000;
}
.tbtn[data-mode="flag"].is-on {
  color: #2a1f04; background: var(--gold);
  box-shadow: 0 0 0 2px #fff0a8, 0 3px 0 #000;
}
.tbtn-pause { min-width: 64px; color: var(--dim); }

.tico {
  width: 18px; height: 18px;
  image-rendering: pixelated;
}
.tico-dig {
  background:
    linear-gradient(#6b4423 0 100%) 7px 0 / 4px 12px no-repeat,
    linear-gradient(#9aa3ad 0 100%) 2px 11px / 14px 6px no-repeat;
}
.tico-flag {
  background:
    linear-gradient(#5a4010 0 100%) 5px 2px / 3px 14px no-repeat,
    linear-gradient(#ffd24a 0 100%) 8px 2px / 9px 7px no-repeat;
}
.tbtn.is-on .tico-dig {
  background:
    linear-gradient(#04240f 0 100%) 7px 0 / 4px 12px no-repeat,
    linear-gradient(#1a2a1a 0 100%) 2px 11px / 14px 6px no-repeat;
}

.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: 700px) {
  .frame { padding: 8px 12px calc(8px + var(--tg-bottom)); }
  .hero-art { width: min(34vw, 130px); }
  .brand { font-size: clamp(18px, 5.5vw, 26px); }
  .ladderbox { display: none; }
  .tbtn { min-height: 50px; }
  .levelmeme { max-width: 58%; }
}
@media (min-width: 420px) {
  .hud-k { font-size: 9px; }
  .hud-v { font-size: 13px; }
  .hud-coins { font-size: 15px; }
}
