@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("../fonts/fredoka-latin.woff2") format("woff2");
}

@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}

:root {
  --ink: #fff6e8;
  --gold: #f0c14a;
  --gold-deep: #b86a12;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: Nunito, "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 80% 38% at 50% -6%, rgba(255, 186, 84, .45), transparent 54%),
    radial-gradient(ellipse 34% 28% at 4% 92%, rgba(226, 61, 140, .22), transparent 62%),
    radial-gradient(ellipse 30% 26% at 98% 78%, rgba(46, 196, 182, .18), transparent 64%),
    linear-gradient(180deg, #3c1c12 0%, #180d0a 42%, #0b1a16 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.flags {
  width: min(520px, calc(100% - 140px));
  margin: 10px auto 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  position: relative;
  height: 30px;
}

.flags::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 0;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 236, 214, .8);
}

.flags span {
  width: 15px;
  height: 22px;
  margin-top: 2px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  animation: sway 2.8s ease-in-out infinite;
}

.flags span:nth-child(odd) { animation-delay: -1.4s; }
.flags span:nth-child(6n+1) { background: #2f9e44; }
.flags span:nth-child(6n+2) { background: #f5c518; }
.flags span:nth-child(6n+3) { background: #e23d8c; }
.flags span:nth-child(6n+4) { background: #4da3ff; }
.flags span:nth-child(6n+5) { background: #ff6b4a; }
.flags span:nth-child(6n+6) { background: #7b5cff; }

@keyframes sway {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.home, .iconbtn {
  position: fixed;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top));
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(240, 193, 74, .5);
  background: rgba(28, 14, 10, .55);
  color: #fff6e8;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.home { left: max(12px, env(safe-area-inset-left)); }
.iconbtn { right: max(12px, env(safe-area-inset-right)); }
.home:active, .iconbtn:active { transform: translateY(1px) scale(.98); }
.iconbtn .slash { display: none; }
.iconbtn.is-muted .wave { display: none; }
.iconbtn.is-muted .slash { display: block; }

.home:focus-visible, .iconbtn:focus-visible, .btn:focus-visible, .textbtn:focus-visible {
  outline: 3px solid #fff6e8;
  outline-offset: 3px;
}

.btn {
  appearance: none;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: #3d2408;
  background: linear-gradient(180deg, #ffe7a3 0%, #ffc83d 48%, #f0a31a 100%);
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  min-width: 180px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .75),
    0 5px 0 var(--gold-deep),
    0 14px 22px rgba(0, 0, 0, .28);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .75), 0 1px 0 var(--gold-deep);
}

.textbtn {
  appearance: none;
  font-family: Nunito, "Trebuchet MS", sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: #f6e6d2;
  background: transparent;
  border: 1px solid rgba(240, 193, 74, .35);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
}

.phrase {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.phrase b {
  display: block;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-size: clamp(34px, 8vw, 58px);
  line-height: .92;
  color: #fff8ee;
  text-shadow: 0 3px 0 #b86a12, 0 10px 18px rgba(0, 0, 0, .35);
}

.phrase small {
  display: block;
  margin-top: 2px;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-size: 24px;
  color: #ffe08a;
  text-shadow: 0 2px 0 #7a4510;
}

.phrase.show { animation: phrase 1.15s cubic-bezier(.18, 1.2, .32, 1) forwards; }

@keyframes phrase {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.72); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  74% { opacity: 1; transform: translate(-50%, -56%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(.98); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 6, 4, .58);
  backdrop-filter: blur(8px);
}

.card {
  width: min(92vw, 400px);
  text-align: center;
  padding: 26px 20px 22px;
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 196, 87, .22), transparent 56%),
    linear-gradient(180deg, #4a2b1c, #26140e);
  border: 1px solid rgba(240, 193, 74, .55);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .22);
  animation: popin .34s cubic-bezier(.2, 1.25, .36, 1);
}

@keyframes popin {
  from { opacity: 0; transform: translateY(10px) scale(.92); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}

.card h2 {
  margin: 4px 0 0;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-size: 32px;
  font-weight: 700;
}

.final-score {
  margin: 6px 0 0;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-size: 64px;
  line-height: .95;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 #c4842a;
}

@media (prefers-reduced-motion: reduce) {
  .flags span { animation: none; }
}
