/* ============================================
   Number Snake — Visual Design System
   Glassmorphism + Mesh Gradient + Spring motion
   ============================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  color: #1a1530;
  overflow: hidden;
}

/* --- Mesh Gradient Background ---------------------------- */
body {
  background-color: #fafafa;
  background-image:
    radial-gradient(at 18% 28%, var(--mesh-1, #c084fc) 0px, transparent 55%),
    radial-gradient(at 78% 14%, var(--mesh-2, #67e8f9) 0px, transparent 50%),
    radial-gradient(at 48% 82%, var(--mesh-3, #fde68a) 0px, transparent 50%),
    radial-gradient(at 86% 66%, var(--mesh-4, #f9a8d4) 0px, transparent 45%);
  background-attachment: fixed;
}

/* Noise grain overlay */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

#root { position: relative; z-index: 1; zoom: var(--shell-zoom, 1); }

/* --- Type ------------------------------------------------- */
.font-display { font-family: 'Space Grotesk', sans-serif; font-weight: 900; letter-spacing: -0.03em; }
.font-mono { font-family: 'Space Mono', ui-monospace, monospace; }
.tabular { font-variant-numeric: tabular-nums; }

.grad-text {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 45%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* --- Glass surfaces -------------------------------------- */
.glass {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  box-shadow:
    0 10px 36px rgba(40, 25, 80, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.glass-tight {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  box-shadow:
    0 4px 18px rgba(40, 25, 80, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.glass-deep {
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow:
    0 24px 80px rgba(40, 25, 80, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* --- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 18px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 180ms ease,
              background-color 180ms ease;
  border: 1px solid rgba(255,255,255,0.7);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  color: #1a1530;
  font-size: 15px;
}
.btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 28px rgba(40,25,80,0.14); background: rgba(255,255,255,0.75); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.45);
  box-shadow: 0 10px 28px rgba(168, 85, 247, 0.4);
}
.btn-primary:hover { background: linear-gradient(135deg, #b465ff, #ff5cad); box-shadow: 0 14px 34px rgba(168, 85, 247, 0.5); }
.btn-ghost { background: rgba(255,255,255,0.3); }

/* Preset duration buttons – different gradient backgrounds */
.preset {
  position: relative;
  border-radius: 22px;
  padding: 18px 14px 16px;
  border: 1px solid rgba(255,255,255,0.7);
  color: #1a1530;
  cursor: pointer;
  text-align: left;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 220ms ease;
  overflow: hidden;
  isolation: isolate;
}
.preset::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  opacity: 0.85;
}
.preset:hover { transform: translateY(-6px) scale(1.04); box-shadow: 0 18px 44px rgba(40,25,80,0.16); }
.preset:active { transform: translateY(-1px) scale(0.98); }
.preset .preset-num { font-family: 'Space Grotesk'; font-weight: 900; font-size: 38px; line-height: 1; letter-spacing: -0.03em; }
.preset .preset-unit { font-family: 'Space Mono'; font-size: 11px; opacity: 0.75; margin-top: 4px; }
.preset .preset-icon { width: 26px; height: 26px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.45); margin-bottom: 14px; font-size: 14px; }

.preset.p1::before { background: linear-gradient(135deg, #a5f3fc, #67e8f9); }
.preset.p3::before { background: linear-gradient(135deg, #ddd6fe, #c4b5fd); }
.preset.p5::before { background: linear-gradient(135deg, #fde68a, #fcd34d); }
.preset.p10::before { background: linear-gradient(135deg, #fbcfe8, #f9a8d4); }

/* --- Bento HUD layout ----------------------------------- */
.bento {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 1.1fr 0.9fr 1.1fr 0.5fr;
  gap: 12px;
}
.hud-card {
  border-radius: 22px;
  padding: 14px 18px;
  position: relative;
  overflow: hidden;
}
.hud-label {
  font-family: 'Space Mono';
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(26,21,48,0.55);
  display: flex; align-items: center; gap: 6px;
}
.hud-value-xl { font-family: 'Space Grotesk'; font-weight: 900; font-size: 56px; line-height: 1; letter-spacing: -0.04em; }
.hud-value-l  { font-family: 'Space Grotesk'; font-weight: 900; font-size: 38px; line-height: 1; letter-spacing: -0.03em; }
.hud-value-m  { font-family: 'Space Grotesk'; font-weight: 900; font-size: 28px; line-height: 1; letter-spacing: -0.02em; }
.hud-value-mono { font-family: 'Space Mono'; font-weight: 700; font-size: 30px; }

/* --- Pill / chip ---------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(168, 85, 247, 0.14);
  color: #7c3aed;
  border: 1px solid rgba(168, 85, 247, 0.22);
}
.pill-amber { background: rgba(245, 158, 11, 0.16); color: #b45309; border-color: rgba(245, 158, 11, 0.3); }
.pill-emerald { background: rgba(16,185,129,0.16); color: #047857; border-color: rgba(16,185,129,0.3); }

/* --- Collected slots ------------------------------------ */
.slot {
  width: 68px; height: 68px;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk'; font-weight: 900;
  font-size: 30px;
  position: relative;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.slot.empty {
  border: 2px dashed rgba(124, 58, 237, 0.35);
  color: rgba(124, 58, 237, 0.4);
  background: rgba(255,255,255,0.4);
}
.slot.filled {
  color: #fff;
  background: radial-gradient(circle at 32% 28%, #fff8 0%, transparent 38%),
              radial-gradient(circle at 50% 50%, var(--slot-c, #a855f7), color-mix(in oklab, var(--slot-c, #a855f7) 60%, #000));
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.6),
    0 18px 30px -8px var(--slot-c-shadow, rgba(168,85,247,0.55)),
    inset 0 -8px 16px rgba(0,0,0,0.18);
  animation: pop 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}

.op-big {
  font-family: 'Space Grotesk'; font-weight: 900;
  font-size: 56px; line-height: 1;
  color: rgba(124, 58, 237, 0.55);
}

/* --- Sticky note ---------------------------------------- */
.sticky {
  background: linear-gradient(180deg, #fff5b8 0%, #ffe981 100%);
  border-radius: 6px;
  padding: 16px 18px;
  transform: rotate(-1.3deg);
  box-shadow:
    0 1px 0 rgba(0,0,0,0.05),
    0 14px 24px -8px rgba(180, 140, 0, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.7);
  position: relative;
}
.sticky::before {
  content: "";
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%) rotate(2deg);
  width: 64px; height: 16px;
  background: rgba(255,255,255,0.5);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.sticky h4 { font-family: 'Space Grotesk'; font-weight: 700; font-size: 14px; margin: 0 0 10px; color: #6b4f00; }
.sticky kbd {
  font-family: 'Space Mono'; font-size: 11px;
  background: #fff; border: 1px solid rgba(0,0,0,0.1);
  border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px;
  color: #1a1530;
  display: inline-block;
}
.sticky ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sticky li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #5b4200; }

/* --- Canvas wrapper ------------------------------------- */
.canvas-wrap {
  border-radius: 24px;
  padding: 12px;
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(18px) saturate(170%);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow:
    0 16px 50px rgba(40,25,80,0.12),
    inset 0 1px 0 rgba(255,255,255,0.8);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-wrap canvas {
  display: block;
  border-radius: 16px;
  background: rgba(255,255,255,0.35);
  box-shadow: inset 0 0 60px rgba(255,255,255,0.4);
}

/* --- Overlays ------------------------------------------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  border-radius: 16px;
  background: rgba(20, 12, 40, 0.18);
  backdrop-filter: blur(8px);
  animation: fadeIn 260ms ease;
}
.modal-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  background: rgba(20, 12, 40, 0.32);
  backdrop-filter: blur(16px);
  animation: fadeIn 260ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes springIn {
  0%   { transform: scale(0.7) translateY(20px); opacity: 0; }
  60%  { transform: scale(1.04) translateY(-2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.spring-in { animation: springIn 380ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.overlay, .modal-overlay { animation-fill-mode: both !important; }

/* --- Result toast --------------------------------------- */
.result-toast {
  padding: 22px 36px;
  border-radius: 22px;
  font-family: 'Space Grotesk';
  font-weight: 900;
  font-size: 64px;
  letter-spacing: -0.03em;
  color: #fff;
  display: flex; align-items: center; gap: 18px;
}
.result-toast.correct {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 30px 60px rgba(16,185,129,0.45);
}
.result-toast.wrong {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  box-shadow: 0 30px 60px rgba(244, 63, 94, 0.4);
}
.result-toast .eq-tag {
  font-family: 'Space Mono'; font-size: 13px;
  background: rgba(255,255,255,0.28);
  padding: 4px 10px; border-radius: 999px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

/* --- Keyboard footer ----------------------------------- */
.kbd-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: 'Space Mono'; font-size: 12px; color: rgba(26,21,48,0.6);
}
.kbd-row kbd {
  font-family: 'Space Mono'; font-size: 11px;
  background: rgba(255,255,255,0.7); border: 1px solid rgba(0,0,0,0.08);
  border-bottom-width: 2px;
  border-radius: 6px; padding: 2px 7px;
  color: #1a1530;
}

/* --- Input ---------------------------------------------- */
.glass-input {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 12px 16px;
  font-family: 'Space Mono'; font-size: 15px;
  width: 100%;
  outline: none;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.glass-input:focus {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 0 0 4px rgba(168,85,247,0.18);
}

/* --- Score bump animation -------------------------------- */
@keyframes scoreBump {
  0% { transform: translateY(6px) scale(0.85); }
  50% { transform: translateY(-3px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}
.score-bump { animation: scoreBump 380ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* --- Float (e.g. hud icons) --------------------------- */
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }
.float-anim { animation: floaty 4s ease-in-out infinite; }

/* --- Layout shell --------------------------------------- */
.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  container-type: inline-size;
  container-name: shell;
}
.game-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

/* Use container query so the breakpoint checks the shell's own CSS width
   (stable in zoom-coordinate space) instead of the viewport width. */
@container shell (max-width: 900px) {
  .game-row { grid-template-columns: 1fr; }
  .bento { grid-template-columns: repeat(3, 1fr); }
}

/* --- Misc ----------------------------------------------- */
.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.08), transparent);
  margin: 12px 0;
}

/* progress bar */
.progress {
  height: 10px; border-radius: 999px;
  background: rgba(124, 58, 237, 0.12);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.5);
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(to right, #34d399, #facc15, #fb7185);
  border-radius: 999px;
  transition: width 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* sound toggle */
.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.7);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), background 160ms;
}
.icon-btn:hover { transform: scale(1.08); background: rgba(255,255,255,0.78); }
.icon-btn:active { transform: scale(0.92); }

/* number ticker */
.ticker {
  display: inline-block;
  position: relative;
}
