/* game.css — the cartridge (full-screen game modal) and the games hub.
   Games live OVER the console so the decoder underneath is never disturbed. */

.cartridge {
  position: fixed; inset: 0; z-index: 70; display: none;
  background: rgba(2,6,11,0.86);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.cartridge.show { display: flex; }
.cartridge-bar {
  width: min(680px, 100%); display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; gap: 12px;
}
.cartridge-title { font-family: var(--display); color: var(--green); font-size: 22px; letter-spacing: 1px; }
.cartridge-hud { color: var(--muted); font: 600 13px/1 var(--mono); letter-spacing: .5px; }
.cartridge-close {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; flex: 0 0 auto;
  background: rgba(37,245,154,0.06); border: 1px solid var(--line); color: var(--ink); font-size: 18px;
}
.cartridge-body { position: relative; width: min(680px, 100%); flex: 1 1 auto; overflow: hidden; }

/* ---- games hub ---- */
.hub { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 16px; width: min(560px, 100%); margin: 0 auto; }
.hub-card {
  display: flex; align-items: center; gap: 14px; cursor: pointer; text-align: left;
  background: rgba(6,18,14,0.6); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  color: var(--ink); transition: .15s;
}
.hub-card:hover { border-color: rgba(37,245,154,0.45); transform: translateY(-1px); }
.hub-card img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; flex: 0 0 auto; }
.hub-card .hub-glyph { width: 64px; height: 64px; display: grid; place-items: center; font-family: var(--display); font-size: 30px; color: var(--green); background: rgba(37,245,154,0.06); border-radius: 10px; }
.hub-name { font-family: var(--display); font-size: 19px; color: var(--ink); }
.hub-desc { color: var(--muted); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.hub-card.soon { opacity: .6; }
.hub-card.soon .hub-name::after { content: " · soon"; color: var(--gold); font-size: 12px; }

/* ---- 589 Hunt (v2) — grid hunt + clock + leaderboard ---- */
.hunt { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* gameplay HUD */
.hunt-hud { padding: 10px 14px 8px; display: flex; flex-direction: column; gap: 7px; flex: 0 0 auto; }
.hh-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hh-level, .hh-scorebox { font: 800 12px/1 var(--mono); letter-spacing: 1.5px; color: var(--muted); }
.hh-level b { font-family: var(--display); font-size: 26px; color: var(--green); margin-left: 5px; text-shadow: 0 0 16px rgba(37,245,154,0.55); vertical-align: -2px; }
.hh-scorebox b { font-family: var(--display); font-size: 22px; color: var(--ink); margin-left: 5px; vertical-align: -2px; }
.hh-mid { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hh-target { font: 700 13px/1 var(--mono); color: var(--muted); letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.hh-target .hh-find {
  font-family: var(--display); font-size: 30px; color: var(--gold);
  text-shadow: 0 0 16px rgba(255,210,58,0.7); line-height: 1;
}
.hh-seq { display: flex; gap: 7px; font-family: var(--display); font-size: 22px; letter-spacing: 2px; }
.hh-seq .done { color: var(--green); } .hh-seq .now { color: var(--gold); text-shadow: 0 0 12px rgba(255,210,58,0.6); } .hh-seq .todo { color: var(--muted); opacity: .45; }
.hh-combo { font: 800 11px/1 var(--mono); letter-spacing: 1px; color: var(--gold); min-width: 70px; text-align: right; opacity: 0; transition: opacity .15s; }
.hh-combo.on { opacity: 1; text-shadow: 0 0 10px rgba(255,210,58,0.5); }
.hh-timebar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.hh-timebar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), #6bffc0); transition: width .1s linear; }
.hh-timebar.low i { background: linear-gradient(90deg, #ff5470, var(--gold)); }

/* the number grid */
.hunt-grid {
  flex: 1 1 auto; min-height: 0; display: grid; gap: 6px;
  grid-template-columns: repeat(var(--cols, 5), 1fr); grid-auto-rows: 1fr;
  padding: 4px 14px 16px;
}
.htile {
  appearance: none; cursor: pointer; min-height: 0;
  font-family: var(--display); font-size: clamp(18px, 6.4vmin, 34px); color: var(--ink);
  background: rgba(8,22,16,0.7); border: 1px solid var(--line); border-radius: 12px;
  display: grid; place-items: center; user-select: none; transition: transform .06s, background .12s, color .12s, border-color .12s;
}
.htile:active { transform: scale(0.94); }
.htile.good { background: rgba(37,245,154,0.85); color: #02140c; border-color: var(--green); transform: scale(1.06); box-shadow: 0 0 18px rgba(37,245,154,0.6); }
.htile.bad { background: rgba(255,84,112,0.8); color: #fff; border-color: #ff5470; }

/* distractions */
.htile.churn { animation: tileChurn .38s ease; }
@keyframes tileChurn { 0% { transform: rotateX(0) scale(1); } 45% { transform: rotateX(88deg) scale(.9); opacity: .45; } 100% { transform: rotateX(0) scale(1); } }
.htile.glow {
  border-color: hsl(var(--hue, 160) 90% 60%);
  color: hsl(var(--hue, 160) 95% 80%);
  box-shadow: 0 0 16px hsl(var(--hue, 160) 90% 55% / 0.7), inset 0 0 12px hsl(var(--hue, 160) 90% 55% / 0.3);
  animation: tileGlow .62s ease;
}
@keyframes tileGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.45); } }

/* hue sheen washing over the whole board at high levels */
.hunt-grid.hot { position: relative; }
.hunt-grid.hot::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 10px;
  mix-blend-mode: screen; opacity: .1;
  background: linear-gradient(120deg, #ffec3d, #3dffd0, #c03dff, #3dff6e, #ff3d6e, #ffec3d);
  background-size: 320% 320%; animation: gridHue 6s linear infinite;
}
.hunt-grid.hotter::after { opacity: .16; animation-duration: 3.4s; }
@keyframes gridHue { to { background-position: 320% 0; } }

.hunt-flash2 {
  position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none;
  font-family: var(--display); font-size: 34px; color: var(--green); opacity: 0;
}
.hunt-flash2.show { animation: huntflash2 .8s ease; }
.hunt-flash2.good { color: var(--green); } .hunt-flash2.bad { color: #ff5470; } .hunt-flash2.level { color: var(--gold); font-size: 44px; }
@keyframes huntflash2 { 0% { opacity: 0; transform: translateY(8px) scale(.9); } 25% { opacity: 1; transform: translateY(0) scale(1.04); } 100% { opacity: 0; transform: translateY(-10px) scale(1.1); } }

/* start / game-over screens */
.hunt-screen {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 20px 18px 28px; gap: 12px;
}
.hunt-h { font-family: var(--display); color: var(--green); font-size: 34px; letter-spacing: 1px; margin: 6px 0 0; }
.hunt-h.best { color: var(--gold); text-shadow: 0 0 22px rgba(255,210,58,0.5); }
.hunt-sub { color: var(--muted); font: 400 13.5px/1.55 var(--mono); max-width: 440px; }
.hunt-sub b { color: var(--green); }
.hunt-play {
  font-family: var(--display); font-size: 22px; color: #02120c; background: var(--green);
  border: none; border-radius: 14px; padding: 13px 30px; cursor: pointer; letter-spacing: 1px;
  box-shadow: 0 10px 26px rgba(37,245,154,0.3);
}
.hunt-play:active { transform: translateY(1px); }
.hunt-final { font-family: var(--display); font-size: 64px; line-height: 1; color: var(--ink); text-shadow: 0 0 30px rgba(37,245,154,0.25); }
.hunt-final-label { color: var(--muted); font: 600 12.5px/1.3 var(--mono); letter-spacing: .5px; margin-top: -4px; }

.hunt-submit { display: flex; gap: 8px; width: min(360px, 100%); }
.hunt-name {
  flex: 1 1 auto; background: rgba(2,8,6,0.9); border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); font: 800 16px/1 var(--mono); letter-spacing: 3px; text-transform: uppercase;
  padding: 12px 13px; outline: none; text-align: center;
}
.hunt-name:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(37,245,154,0.2); }
.hunt-send {
  flex: 0 0 auto; appearance: none; border: none; cursor: pointer; border-radius: 11px;
  background: linear-gradient(90deg, var(--green), #6bffc0); color: #02140c; font: 800 13px/1 var(--mono); padding: 0 16px; letter-spacing: 1px;
}
.hunt-send:disabled { opacity: .7; }
.hunt-note { color: var(--gold); font: 600 12px/1.3 var(--mono); min-height: 14px; }

/* leaderboard list */
.hunt-board-wrap { width: min(420px, 100%); margin-top: 4px; }
.hunt-board-title { font: 800 12px/1 var(--mono); color: var(--muted); letter-spacing: 1.5px; margin-bottom: 8px; }
.hunt-board { display: flex; flex-direction: column; gap: 4px; }
.hb-row {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px;
  padding: 8px 11px; border-radius: 10px; background: rgba(6,18,14,0.55); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 13.5px;
}
.hb-row.me { border-color: var(--green); background: rgba(37,245,154,0.1); }
.hb-rank { color: var(--muted); font-weight: 800; font-size: 12px; }
.hb-name { color: var(--ink); font-weight: 700; letter-spacing: 1px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-score { color: var(--green); font-weight: 800; }
.hb-empty { color: var(--muted); font: 400 12.5px/1.5 var(--mono); padding: 10px; }

@media (prefers-reduced-motion: reduce) {
  .hunt-flash2.show, .htile.churn, .htile.glow, .hunt-grid.hot::after { animation: none; }
  .htile.good { transform: none; }
}

/* ---- level-up celebration (BG pops up + bling) ---- */
.lvlup {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(37,245,154,0.16), rgba(2,6,11,0.86) 70%);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: lvlIn .25s ease; cursor: pointer;
}
.lvlup.out { animation: lvlOut .22s ease forwards; }
@keyframes lvlIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lvlOut { to { opacity: 0; } }

.lvlup-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 18px; max-width: 92%; }
.lvlup-badge {
  font-family: var(--display); font-size: clamp(34px, 11vw, 58px); letter-spacing: 2px;
  color: var(--gold); text-shadow: 0 0 26px rgba(255,210,58,0.6), 0 0 60px rgba(255,210,58,0.3);
  animation: lvlPop .5s cubic-bezier(.2,.9,.3,1.4);
}
@keyframes lvlPop { 0% { transform: scale(.4) rotate(-6deg); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }

.lvlup-bear {
  position: relative; width: clamp(110px, 34vw, 150px); height: clamp(110px, 34vw, 150px);
  border-radius: 50%; overflow: hidden; border: 3px solid var(--green);
  box-shadow: 0 0 0 6px rgba(37,245,154,0.18), 0 14px 40px rgba(0,0,0,0.5), 0 0 36px rgba(37,245,154,0.5);
  animation: bearPop .45s cubic-bezier(.2,.9,.3,1.5) .08s both;
}
.lvlup-bear video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lvlup-bear-fallback { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(2,12,8,0.9); }
.lvlup-bear-fallback::before {
  content: ""; width: 46px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--green) 0 24%, #06351f 26% 48%, transparent 54%);
  box-shadow: 0 0 14px rgba(37,245,154,0.7);
}
@keyframes bearPop { 0% { transform: scale(0) translateY(20px); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }

.lvlup-bubble {
  min-height: 1.4em; max-width: 380px;
  background: rgba(4,12,10,0.96); border: 1px solid rgba(37,245,154,0.4); border-radius: 14px;
  padding: 11px 14px; color: var(--ink); font: 600 14px/1.5 var(--mono);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.lvlup-cont { color: var(--muted); font: 700 11px/1 var(--mono); letter-spacing: 1.5px; opacity: .85; animation: contPulse 1.2s ease-in-out infinite; }
@keyframes contPulse { 0%,100% { opacity: .45; } 50% { opacity: .95; } }

.lvlup-spark { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lvlup-spark i {
  position: absolute; width: 9px; height: 9px; border-radius: 2px;
  background: var(--gold); box-shadow: 0 0 10px var(--gold);
  transform: translate(0,0) scale(1); opacity: 0;
  animation: sparkFly .9s ease-out var(--dl, 0s) forwards;
}
.lvlup-spark i:nth-child(even) { background: var(--green); box-shadow: 0 0 10px var(--green); }
@keyframes sparkFly {
  0% { transform: translate(0,0) scale(.4); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx,0), var(--dy,-140px)) scale(.2) rotate(160deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lvlup, .lvlup-badge, .lvlup-bear, .lvlup-spark i, .lvlup-cont { animation: none !important; }
  .lvlup-spark { display: none; }
}
