/* Karina to the Moon — Duolingo night look: dark navy, chunky rounded
   buttons with a hard bottom border, Nunito-style rounded type, green accent. */

:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-light: #2d4a1a;
  --green-border: #58cc02;
  --green-text: #8ee55b;
  --red: #ff4b4b;
  --red-light: #4a1f24;
  --red-border: #ff4b4b;
  --red-text: #ff8a8a;
  --blue: #1cb0f6;
  --text: #f1f7fb;
  --muted: #a5b3c7;
  --border: #3a4a66;
  --card-bg: #17233c;
  --panel-bg: rgba(15, 23, 42, 0.92);
  --page-bg: #060d1f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* Fullscreen on desktop/landscape; the canvas adapts its logical width in JS. */
.wrap {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1430;
}

/* Portrait phones: letterboxed 9:16-ish card — vertical game, portrait is
   actually the natural shape, so give it the full height instead. */
@media (orientation: portrait) {
  .wrap { padding: 0; }
  .stage { border-radius: 0; }
}

canvas { display: block; width: 100%; height: 100%; }

/* ---------- HUD ---------- */

#hud { position: absolute; top: 0.6rem; left: 0.6rem; pointer-events: none; z-index: 2; }

.chip {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 0.75rem;
  padding: 0.25rem 0.75rem;
  font-weight: 900;
  font-size: 1rem;
  color: var(--text);
}

/* ---------- Quiz ---------- */

#quiz {
  position: absolute;
  top: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 30rem);
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 1rem;
  padding: 0.6rem 0.75rem;
  text-align: center;
  z-index: 3;
}

.q-text {
  font-size: 1rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.answers { display: flex; flex-direction: column; gap: 0.4rem; }

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 0.75rem;
  padding: 0.5rem 0.9rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background 0.1s, transform 0.05s, border-color 0.1s;
  touch-action: manipulation;
  line-height: 1.25;
}
.btn:hover { background: #1e2d4d; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn:disabled { cursor: default; }

.btn.correct {
  background: var(--green-light);
  border-color: var(--green-border);
  color: var(--green-text);
}
.btn.wrong {
  background: var(--red-light);
  border-color: var(--red-border);
  color: var(--red-text);
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.timerbar {
  height: 0.4rem;
  background: var(--border);
  border-radius: 0.2rem;
  margin-top: 0.5rem;
  overflow: hidden;
}
.timerbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--green);
  border-radius: 0.2rem;
  transition: width 0.1s linear, background 0.2s;
}
.timerbar i.low { background: var(--red); }

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 4;
}

.card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
  text-align: center;
  max-width: 24rem;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.5);
}

.mascot { height: 7rem; width: auto; margin-bottom: 0.25rem; }

.card h1 { font-size: 1.5rem; font-weight: 900; color: var(--text); margin-bottom: 0.5rem; }

.rules { font-size: 0.9rem; line-height: 1.45; color: var(--muted); margin-bottom: 1rem; }

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  border-bottom: 4px solid var(--green-dark);
  color: #0b1d0b;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.65rem 1.75rem;
}
.btn-primary:hover { background: #61e002; }
.btn-primary:disabled { background: #3a6620; border-color: #3a6620; color: #7d9b6c; }

.score-big { font-size: 3rem; font-weight: 900; color: var(--green); line-height: 1.1; }
.score-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.best { font-size: 0.9rem; font-weight: 800; color: var(--blue); margin-bottom: 0.35rem; }
.last-word { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; line-height: 1.35; }
.last-word b { color: var(--text); }

/* ---------- Player name + leaderboard ---------- */

.name-input {
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  background: #0f1a30;
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 0.75rem;
  padding: 0.5rem 0.9rem;
  width: 100%;
  text-align: center;
  margin-bottom: 0.75rem;
}
.name-input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.name-input::placeholder { color: var(--muted); font-weight: 700; }

.lb { margin-bottom: 1rem; }
.lb-place { font-size: 0.95rem; font-weight: 800; color: var(--blue); margin-bottom: 0.4rem; }
.lb-top { list-style: none; counter-reset: lb; }
.lb-top li {
  counter-increment: lb;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #0f1a30;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.3rem;
  font-weight: 800;
  font-size: 0.9rem;
}
.lb-top li::before {
  content: counter(lb);
  color: var(--muted);
  min-width: 1.1rem;
  text-align: center;
}
.lb-top li.me { border-color: var(--green); background: var(--green-light); }
.lb-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: var(--green-text); }

/* ---------- Fullscreen button ---------- */

.fs-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 5;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 0.75rem;
  cursor: pointer;
  touch-action: manipulation;
}
.fs-btn:hover { background: #1e2d4d; }
.fs-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.fs-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.fs-btn svg { width: 1.25rem; height: 1.25rem; }

.hidden { display: none !important; }

/* ---------- Small screens ---------- */

@media (max-width: 30rem) {
  #hud { top: auto; bottom: 0.6rem; }
  /* Keep the corner button clear of the full-width quiz card */
  .fs-btn { top: auto; bottom: 0.6rem; }
  .q-text { font-size: 0.9rem; }
  .btn { font-size: 0.85rem; padding: 0.45rem 0.6rem; }
  .card h1 { font-size: 1.25rem; }
  .mascot { height: 5rem; }
}
