@font-face {
  font-family: "Bangers";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/bangers-400.woff2") format("woff2");
}

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/fredoka.woff2") format("woff2");
}

:root {
  --sky-0: #07061a;
  --sky-1: #121033;
  --gold: #f0c14b;
  --gold-soft: #f8e3a1;
  --cream: #f7f1e4;
  --ink: #16132a;
  --muted: #c9c3de;
  --line: rgba(247, 241, 228, 0.14);
  --font-display: "Bangers", "Impact", "Haettenschweiler", "Arial Black", cursive;
  --font-ui: "Fredoka", "Segoe UI", "Trebuchet MS", sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--sky-0);
  color: var(--cream);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(123, 63, 184, 0.35), transparent 60%),
    radial-gradient(700px 400px at -10% 20%, rgba(62, 200, 200, 0.12), transparent 55%),
    var(--sky-0);
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(8px, var(--safe-t)) max(8px, var(--safe-r)) max(8px, var(--safe-b)) max(8px, var(--safe-l));
}

#stage {
  position: relative;
  width: min(100%, calc((100dvh - 16px) * 1080 / 1920));
  height: min(100%, 100dvh - 16px);
  aspect-ratio: 1080 / 1920;
  max-height: 100%;
  background: #050414;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(4, 3, 16, 0.45);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #07061a;
}

#hud-bar {
  position: absolute;
  top: auto;
  bottom: 52px;
  right: 8px;
  z-index: 5;
  display: flex;
  gap: 6px;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
#overlay:not(.is-play),
#overlay .panel {
  pointer-events: auto;
}
#overlay.is-play #title-screen { display: none; }

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px 18px 28px;
  background:
    linear-gradient(180deg, rgba(7, 6, 26, 0.15) 20%, rgba(7, 6, 26, 0.82) 58%, rgba(7, 6, 26, 0.94) 100%);
  overflow: auto;
}

#endcard.panel {
  justify-content: center;
  background: rgba(7, 6, 26, 0.78);
}

.kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  line-height: 0.92;
  margin: 0 0 8px;
  color: var(--cream);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.lede {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.02rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}

.lesson-btn {
  text-align: left;
  background: rgba(18, 16, 51, 0.9);
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  cursor: pointer;
}
.lesson-btn strong {
  display: block;
  font-size: 0.95rem;
}
.lesson-btn span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}
.lesson-btn.is-on,
.lesson-btn:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240, 193, 75, 0.35);
  background: rgba(42, 32, 80, 0.95);
}

#lesson-fact {
  margin: 0 0 14px;
  color: var(--gold-soft);
  font-size: 0.95rem;
  line-height: 1.4;
  min-height: 3.2em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--gold);
  background: var(--gold);
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-ghost {
  background: transparent;
  color: var(--cream);
  border-color: rgba(247, 241, 228, 0.35);
}
.btn-tiny {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: rgba(7, 6, 26, 0.7);
  color: var(--cream);
  border-color: rgba(247, 241, 228, 0.3);
}

.nfa, .handle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.handle {
  color: var(--gold);
  font-weight: 700;
  margin-top: 4px;
}

#end-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.2rem);
  margin: 0 0 8px;
  line-height: 0.95;
}
#end-score { margin: 0 0 12px; color: var(--gold-soft); font-weight: 700; }
#end-fact { margin: 0 0 14px; color: var(--cream); }
#end-share {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(18, 16, 51, 0.9);
  border: 1px solid var(--line);
  color: var(--cream);
}

body.is-record #overlay,
body.is-record #hud-bar { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
