:root {
  --bg: #0b0d1a;
  --panel: #151933;
  --line: #2a3060;
  --text: #e8e9f5;
  --muted: #8b90b8;
  --accent: #f3d27a;
  --good: #7ee0a1;
  --bad: #ff6b81;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
}

main {
  width: 100%;
  max-width: 560px;
  padding: 24px 16px 48px;
  text-align: center;
}

h1 {
  margin: 0 0 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

#stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

#card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  /* Tall enough for the reveal so the answer grid never shifts mid-game. */
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#birthday {
  margin: 4px 0 0;
  font-size: 1.75rem;
  font-weight: 600;
}

#reveal { margin-top: 12px; }
#reveal:not([hidden]) #reveal-glyph { animation: reveal 0.6s cubic-bezier(.2, 1.4, .4, 1) both; }
#reveal:not([hidden]) #reveal-name,
#reveal:not([hidden]) #reveal-range { animation: fade-up 0.4s 0.15s ease-out both; }
#reveal-glyph {
  font-size: 4rem;
  line-height: 1;
  color: var(--glow, var(--accent));
  text-shadow: 0 0 18px var(--glow, var(--accent)), 0 0 42px var(--glow, var(--accent));
}
#reveal-name { font-size: 1.25rem; font-weight: 600; margin-top: 4px; }
#reveal-range { color: var(--muted); font-size: 0.9rem; }

#prompt {
  min-height: 1.5em;
  color: var(--muted);
  margin: 16px 0;
}
#prompt.good { color: var(--good); }
#prompt.bad { color: var(--bad); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
#elements { grid-template-columns: repeat(4, 1fr); }

.grid button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 4px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.grid button .glyph { display: block; font-size: 1.4rem; margin-bottom: 2px; }
.grid button:hover:not(:disabled) { border-color: var(--accent); }
.grid button:active:not(:disabled) { transform: scale(0.96); }
.grid button:disabled { cursor: default; opacity: 0.45; }
.grid button.wrong { border-color: var(--bad); color: var(--bad); animation: shake 0.3s; }
.grid button.right { border-color: var(--good); color: var(--good); opacity: 1; }

#modes {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}
#modes button {
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 16px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
#modes button.active { background: var(--line); color: var(--text); }

#timebar {
  height: 4px;
  margin: -4px 0 16px;
  background: var(--panel);
  border-radius: 2px;
  overflow: hidden;
}
#timebar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 1s linear;
}
#timebar-fill.low { background: var(--bad); }

[hidden] { display: none !important; }

#next, #start {
  margin-top: 20px;
  background: var(--accent);
  color: var(--bg);
  border: 0;
  border-radius: 999px;
  padding: 10px 24px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Two tiled layers of tiny stars, offset so the pattern doesn't read as a grid. */
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 140px 90px, #cfd4ff, transparent),
    radial-gradient(1.5px 1.5px at 260px 170px, #fff, transparent),
    radial-gradient(1px 1px at 80px 220px, #fff, transparent),
    radial-gradient(1px 1px at 200px 260px, #ffe9b0, transparent);
  background-size: 300px 300px;
  opacity: 0.5;
}
body::after {
  background-position: 150px 110px;
  animation: twinkle 5s ease-in-out infinite alternate;
}
main { position: relative; }

@keyframes twinkle { from { opacity: 0.15; } to { opacity: 0.6; } }
@keyframes reveal {
  from { opacity: 0; transform: scale(0.3) rotate(-90deg); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  #elements { grid-template-columns: repeat(2, 1fr); }
}
