:root {
  --bg: #0c1410;
  --panel: #14211a;
  --panel2: #1b2c22;
  --ink: #d8e8dc;
  --dim: #7d9486;
  --zombie: #6fd06f;
  --toxic: #9aff5e;
  --blood: #d04848;
  --gold: #ffd34e;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 10px; padding: 10px 14px; background: rgba(12,20,16,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #243a2c; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.brand span { color: var(--toxic); }
.me-banner { font-size: 12px; color: var(--dim); flex: 1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flip-btn { font-size: 20px; background: var(--panel2); color: var(--ink);
  border: 2px solid #2f4a38; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
#mute-btn { margin-left: auto; }
.flip-btn.real { background: #2c2438; border-color: #4a3f5e; }

main { padding: 14px; max-width: 900px; margin: 0 auto; }

#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: #0a110d; border-top: 1px solid #243a2c;
  padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; background: none; border: none; color: var(--dim); font-size: 11px;
  padding: 8px 0 6px; display: flex; flex-direction: column; gap: 2px; align-items: center; cursor: pointer; }
#tabs button span { font-size: 20px; }
#tabs button.active { color: var(--toxic); }

h2.year-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 2px 4px;
  font-size: 20px; color: var(--toxic); }
h2.year-head small { color: var(--dim); font-size: 12px; font-weight: 400; }
.year-progress { font-size: 11px; color: var(--dim); margin: 0 2px 10px; }

.plague { margin: 30px 0; text-align: center; padding: 16px; border: 1px dashed #4a3030;
  border-radius: var(--radius); color: #c97e7e; background: #190f0f;
  font-weight: 700; letter-spacing: 3px; }
.plague small { display: block; letter-spacing: 1px; font-weight: 400; color: #8a5c5c; margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { position: relative; border-radius: 10px; overflow: hidden; background: var(--panel);
  aspect-ratio: 1; cursor: pointer; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .15s; }
.card:active img { transform: scale(.97); }
.card .mode-dot { position: absolute; top: 6px; right: 6px; font-size: 14px;
  background: rgba(0,0,0,.55); border-radius: 999px; padding: 2px 6px; pointer-events: none; }
.card.locked { display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; color: #3e5546; background:
  repeating-linear-gradient(45deg, #131e17, #131e17 12px, #16241b 12px, #16241b 24px);
  font-size: 12px; cursor: default; }
.card.locked .lock { font-size: 26px; }

.meter { background: #0a110d; border: 1px solid #243a2c; border-radius: 999px;
  height: 16px; overflow: hidden; margin: 6px 0 2px; }
.meter > div { height: 100%; background: linear-gradient(90deg, var(--zombie), var(--toxic));
  width: 0%; transition: width .6s; border-radius: 999px; }
.meter-label { font-size: 12px; color: var(--dim); margin-bottom: 12px; }

.panel { background: var(--panel); border: 1px solid #243a2c; border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.panel p { margin: 6px 0; font-size: 14px; color: var(--dim); }

.coin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.coin { background: var(--panel); border: 1px solid #243a2c; border-radius: var(--radius);
  padding: 14px 10px; text-align: center; }
.coin .face { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  background: radial-gradient(circle at 35% 30%, #3a5c44, #1b2c22 70%);
  border: 3px solid #2f4a38; filter: grayscale(1) brightness(.55); }
.coin.scanned .face { filter: none; border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 211, 78, .35); }
.coin .nm { font-size: 13px; font-weight: 700; }
.coin .st { font-size: 11px; color: var(--dim); margin-top: 2px; }
.coin.scanned .st { color: var(--gold); }
.coin .addr { white-space: pre-line; font-size: 11px; color: var(--dim); margin-top: 8px;
  border-top: 1px dashed #2f4a38; padding-top: 6px; }
.coin button.share { margin-top: 8px; font-size: 12px; background: var(--panel2);
  border: 1px solid #2f4a38; color: var(--ink); border-radius: 8px; padding: 5px 12px; cursor: pointer; }
.coin.me .nm::after { content: " (you)"; color: var(--toxic); }

.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.sound-btn { background: var(--panel2); border: 2px solid #2f4a38; color: var(--ink);
  border-radius: var(--radius); padding: 16px 6px; font-size: 14px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sound-btn span { font-size: 30px; }
.sound-btn:active { transform: scale(.94); background: #24402e; }
.sound-btn.locked, .game-tile.locked { opacity: .35; filter: grayscale(1); }

.game-tile { background: var(--panel); border: 1px solid #243a2c; border-radius: var(--radius);
  padding: 18px 14px; margin-bottom: 12px; display: flex; gap: 14px; align-items: center; cursor: pointer; }
.game-tile .ico { font-size: 38px; }
.game-tile h3 { margin: 0; } .game-tile p { margin: 2px 0 0; font-size: 13px; color: var(--dim); }
.game-tile .best { margin-left: auto; font-size: 12px; color: var(--gold); white-space: nowrap; }

#game-stage { position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column; }
#game-stage header { display: flex; align-items: center; padding: 10px 14px; gap: 12px; }
#game-stage header .score { font-size: 16px; font-weight: 700; color: var(--toxic); }
#game-stage header button { margin-left: auto; background: var(--panel2); color: var(--ink);
  border: 1px solid #2f4a38; border-radius: 8px; padding: 6px 14px; font-size: 14px; cursor: pointer; }
#game-canvas-wrap { flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 8px; overflow: auto; }
/* keep a centered child reachable even if it's taller than the wrap (flex+overflow) */
#game-canvas-wrap > * { margin: auto; }
canvas#game-canvas { background: #0a130e; border: 2px solid #2f4a38; border-radius: 10px;
  touch-action: none; max-width: 100%; max-height: 100%; }
/* DOM-grid games (whack/simon/memory): shrink to fit short landscape viewports
   so the bottom row of tap targets never falls below the fold */
.gpad { width: 100%; max-width: min(440px, 86vh); }

#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 10, 7, .9);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  overflow-y: auto; }            /* short/landscape + soft-keyboard: never trap the buttons */
.unlock-card { background: var(--panel); border: 2px solid var(--gold); border-radius: 18px;
  text-align: center; padding: 28px 22px; max-width: 340px; margin: auto;
  max-height: calc(100dvh - 32px); overflow-y: auto;
  animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.unlock-card .big { font-size: 60px; animation: spin .8s ease; display: inline-block; }
.unlock-card h2 { color: var(--gold); margin: 10px 0 4px; }
.unlock-card p { color: var(--dim); font-size: 14px; margin: 4px 0; }
.unlock-card ul { text-align: left; font-size: 14px; color: var(--ink); padding-left: 20px; }
.unlock-card button { margin-top: 12px; background: var(--gold); color: #221a00; font-weight: 800;
  border: none; border-radius: 10px; padding: 10px 26px; font-size: 15px; cursor: pointer; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes spin { from { transform: rotateY(0); } to { transform: rotateY(720deg); } }

#lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.95);
  display: flex; align-items: center; justify-content: center; }
#lightbox img { max-width: 100%; max-height: 100%; }
#lightbox button { position: absolute; top: 12px; background: rgba(20,33,26,.9); color: var(--ink);
  border: 1px solid #2f4a38; border-radius: 999px; padding: 8px 16px; font-size: 15px; cursor: pointer; z-index: 2; }
#lb-close { right: 12px; }
#lb-flip { left: 12px; }

.lore li { margin: 8px 0; font-size: 15px; }
.lore .plague-li { color: #c97e7e; letter-spacing: 2px; font-weight: 700; }
.tiny { font-size: 11px; color: var(--dim); }
.center { text-align: center; }
.gold { color: var(--gold); }
.toxic { color: var(--toxic); }

.fame-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0;
  border-bottom: 1px dashed #2f4a38; }
.fame-row:last-child { border-bottom: none; }
.fame-who { font-size: 14px; }
.fame-msg { font-size: 13px; color: var(--gold); font-style: italic; }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti span { position: absolute; top: -30px; animation: confetti-fall 2.6s linear infinite; }
@keyframes confetti-fall {
  to { transform: translateY(420px) rotate(540deg); opacity: 0; }
}
/* contain confetti horizontally but still allow vertical scroll when the card
   is taller than a short/landscape viewport (overrides the base overflow-y) */
.unlock-card { position: relative; overflow-x: hidden; overflow-y: auto; }
.horde-card { border-color: var(--toxic); box-shadow: 0 0 30px rgba(154, 255, 94, .35); }

/* FULL HORDE golden theme */
body.horde #topbar { border-bottom-color: var(--gold); }
body.horde .brand span { color: var(--gold); }
body.horde #tabs button.active { color: var(--gold); }
body.horde .meter > div { background: linear-gradient(90deg, #c89b2c, var(--gold)); }
body.horde h2.year-head { color: var(--gold); }
.horde-banner { border-color: var(--gold); }

#toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--zombie); color: var(--ink);
  border-radius: 999px; padding: 8px 18px; font-size: 14px; z-index: 70;
  opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }
