@font-face {
  font-family: Inter;
  src: url(assets/inter.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url(assets/space-grotesk.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --cream: #fbf3e4;
  --surface: #fffcf6;
  --ink: #15130f;
  --muted: #4a4337;
  --nav: #1f2120;
  --coral: #ee5e24;
  --cobalt: #3255d8;
  --line: #e7d9be;
}

* {
  box-sizing: border-box;
}

html,body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #719a9d;
  color: var(--ink);
  font-family: Inter,system-ui,sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: fixed;
  top: max(12px,env(safe-area-inset-top));
  left: max(12px,env(safe-area-inset-left));
  right: 70px;
  display: flex;
  gap: 0;
  align-items: center;
  flex-wrap: wrap;
  pointer-events: none;
  width: fit-content;
  max-width: calc(100% - 82px);
  border-radius: 17px;
  background: var(--nav);
  color: var(--cream);
  padding: 10px 0;
  border: 1px solid #56564e;
  box-shadow: 0 4px 16px #15130f26;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 20px;
  min-width: 84px;
  border-right: 1px solid #ffffff29;
  line-height: 1.1;
}

.stat:nth-child(3) {
  border-right: 0;
}

.stat .label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #d9cfbd;
}

.stat strong {
  font: 700 25px/1 "Space Grotesk",system-ui,sans-serif;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
}

#hud-time {
  color: #ffc857;
}

#streak-box.fire strong {
  color: #ffc857;
}

.fire-badge {
  width: 100%;
  margin: 9px 8px -2px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #ffc857;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  letter-spacing: .5px;
}

.icon-btn {
  position: fixed;
  top: max(12px,env(safe-area-inset-top));
  right: max(12px,env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  border: 1px solid #ffffffb3;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 3px 15px #15130f26;
}

.pause-glyph {
  width: 14px;
  height: 16px;
  border-left: 5px solid currentColor;
  border-right: 5px solid currentColor;
}

button:focus-visible,summary:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 3px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18px;
  text-align: center;
  background: #1f21203b;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(400px,100%);
  flex-shrink: 0;
  margin: auto;
  padding: 24px 28px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid white;
  box-shadow: 0 24px 70px #15130f40;
}

.badge {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 27%,#ffda9f,transparent 45%),linear-gradient(90deg,transparent 47%,#783915 47% 53%,transparent 53%),linear-gradient(0deg,transparent 47%,#783915 47% 53%,transparent 53%),#ee792b;
  box-shadow: 0 3px 0 #c45b21,inset -4px -5px 8px #a4431859;
}

.overlay .eyebrow {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #a8390c;
}

.overlay h1,.overlay h2 {
  margin: 0;
  font: 700 clamp(28px,7vmin,38px)/1.06 "Space Grotesk",system-ui,sans-serif;
  letter-spacing: -1.1px;
  color: var(--ink);
}

.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.overlay .goal {
  max-width: 30ch;
}

.overlay .hint {
  font-size: 12px;
  line-height: 1.6;
}

.overlay .result {
  font-size: 22px;
  color: var(--ink);
  font-weight: 700;
}

.overlay .result strong {
  display: block;
  font: 700 60px/1.1 "Space Grotesk",system-ui,sans-serif;
  color: var(--ink);
  letter-spacing: -2px;
}

.overlay .best strong,.overlay .best-line strong {
  color: var(--cobalt);
}

.overlay .stats {
  font-size: 12px;
}

.court-hint {
  position: fixed;
  right: max(12px,env(safe-area-inset-right));
  bottom: max(12px,env(safe-area-inset-bottom));
  max-width: min(310px,calc(100% - 112px));
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #ffffff80;
  border-radius: 12px;
  background: var(--nav);
  color: var(--cream);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}

.overlay .timer-note {
  font-size: 11px;
}

.court-options {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--line);
}

.court-options summary {
  padding: 12px 0;
  min-height: 44px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.court-options .skins {
  margin-top: 12px;
  justify-content: center;
}

.overlay .next-target {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: #f5ecda;
  color: var(--ink);
  font-weight: 600;
}

.hidden {
  display: none!important;
}

.btn {
  width: 100%;
  min-height: 52px;
  margin: 4px 0 7px;
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--coral);
  color: var(--ink);
  font: 700 19px/1.2 "Space Grotesk",system-ui,sans-serif;
  cursor: pointer;
  box-shadow: 0 5px 0 #bb4015;
  transition: transform .08s ease,background .12s ease;
}

.btn:hover {
  background: #f8753e;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #bb4015;
}

.goals-box {
  width: 100%;
  padding: 11px 13px;
  border-radius: 16px;
  background: #f5ecda;
  border: 1px solid var(--line);
}

.overlay .goals-title {
  margin-bottom: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.goals {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
  width: 100%;
  text-align: left;
}

.goals li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.goals .tick {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #978b72;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.goals li.done .tick {
  background: #a9d8b4;
  border-color: #477752;
}

.goals li.done span:last-child {
  color: var(--muted);
}

.unlock {
  padding: 7px 12px;
  border-radius: 12px;
  background: #f5ecda;
  border: 1px solid var(--line);
}

.overlay .unlock {
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
}

.skins {
  display: flex;
  align-items: center;
  gap: 9px;
}

.skin-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.skin-row {
  display: flex;
  gap: 7px;
}

.skin {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f5ecda;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.skin .dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,var(--hi) 0 18%,var(--mid) 45%,var(--lo));
  box-shadow: inset 0 0 0 2px var(--seam);
}

.skin[aria-pressed="true"] {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
  background: white;
}

.skin:disabled {
  cursor: not-allowed;
}

.skin:disabled .dot {
  opacity: .28;
}

.skin .lock {
  position: absolute;
  inset: auto 0 1px;
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
}

@media(max-width:400px) {
  .hud {
    top: 10px;
    left: 10px;
    max-width: calc(100% - 76px);
    border-radius: 14px;
    padding: 10px 0;
  }
  .stat {
    padding: 0 12px;
    min-width: 62px;
  }
  .stat .label {
    font-size: 8px;
    letter-spacing: 1px;
  }
  .stat strong {
    font-size: 22px;
  }
  .icon-btn {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
  }
  .card {
    padding: 22px 18px;
  }
  .skins {
    gap: 7px;
  }
  .skin-row {
    gap: 6px;
  }
}

@media(max-width:340px) {
  .stat {
    min-width: 58px;
    padding: 0 10px;
  }
  .overlay {
    padding: 14px;
  }
  .card {
    padding: 18px 14px;
  }
  .skin-row {
    gap: 5px;
  }
  .skins {
    gap: 5px;
  }
  .skin-label {
    font-size: 10px;
  }
}

@media(max-height:560px) {
  .card {
    gap: 8px;
    padding: 20px 24px;
  }
  .badge {
    width: 36px;
    height: 36px;
  }
}

@media(max-height:420px) {
  .badge {
    display: none;
  }
  .card {
    gap: 6px;
    padding: 16px 20px;
  }
  .overlay h1,.overlay h2 {
    font-size: 28px;
  }
  .btn {
    min-height: 46px;
    font-size: 18px;
  }
  .overlay .result strong {
    font-size: 44px;
  }
}

@media(prefers-reduced-motion:reduce) {
  .btn {
    transition: none;
  }
}
