:root {
  --bg: #0E1526;
  --card: #18223A;
  --line: #2C3A5C;
  --text: #F4F1E8;
  --soft: #C9D2E3;
  --muted: #A9B3C7;
  --red: #FF5A5F;
  --green: #3DDC84;
  --blue: #4DA3FF;
  --yellow: #FFD23F;
  --display: "Fredoka", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

header { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 22px var(--display); }
.logo { width: 30px; height: 30px; flex-shrink: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card); color: var(--soft);
  font-size: 13px; font-weight: 700;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.pill.closed .dot { background: var(--muted); }
.pill.offline .dot { background: var(--red); }

section { display: flex; flex-direction: column; gap: 16px; }
[hidden] { display: none !important; }
.center { flex-grow: 1; align-items: center; justify-content: center; text-align: center; }

h1 { margin: 0; font: 600 32px/1.1 var(--display); }
h1.big { font-size: 40px; }
p { margin: 0; font-size: 16px; line-height: 1.45; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

button {
  font: inherit; cursor: pointer; border: 0; border-radius: 18px;
  min-height: 52px; padding: 0 20px;
}
button:focus-visible, .zone:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.primary { background: var(--yellow); color: #1A1405; font: 600 22px var(--display); min-height: 60px; }
.primary:disabled { background: var(--card); color: var(--muted); cursor: not-allowed; }
.secondary { background: transparent; color: var(--text); border: 2px solid var(--line); font-weight: 700; font-size: 17px; }
.link { background: transparent; color: var(--soft); font-weight: 700; }
.blue { background: var(--blue); color: #07162B; font-weight: 700; font-size: 17px; border-radius: 14px; }

.card { background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-size: 13px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.scores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: rank; }
.scores li { display: flex; gap: 12px; font-size: 16px; font-weight: 700; counter-increment: rank; }
.scores li::before { content: counter(rank); width: 18px; color: var(--muted); }
.scores .who { flex-grow: 1; letter-spacing: 1px; }
.scores .n { font: 600 16px var(--display); color: var(--yellow); }
.scores .empty { color: var(--muted); font-weight: 600; }
.scores .empty::before { content: none; }

.notice { background: var(--card); border-radius: 14px; padding: 12px 14px; color: var(--soft); font-weight: 600; }

/* The house and its zones */
.house { position: relative; border-radius: 22px; overflow: visible; user-select: none; touch-action: manipulation; }
.house img { display: block; width: 100%; height: auto; border-radius: 22px; }
.house svg.zones { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.zone {
  fill: transparent;
  stroke: rgba(244, 241, 232, 0.25);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  stroke-linejoin: round;
  transition: fill 80ms, stroke 80ms;
}
.house.active .zone { stroke: var(--c); cursor: pointer; }
.zone.lit {
  fill: var(--c);
  fill-opacity: 0.45;
  stroke: var(--c);
  stroke-dasharray: none;
  filter: drop-shadow(0 0 10px var(--c));
}
.zone-tag {
  position: absolute; transform: translate(-50%, -50%);
  padding: 3px 9px; border-radius: 999px;
  background: rgba(14, 21, 38, 0.88);
  font-size: 12px; font-weight: 700; white-space: nowrap; pointer-events: none;
}

/* Progress dots */
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--yellow); }
.dots span.done { background: var(--yellow); }
.dots.watch span { width: 16px; height: 16px; border-color: var(--text); }
.dots.watch span.done { background: var(--text); }

.timer { height: 10px; border-radius: 999px; background: var(--card); overflow: hidden; }
.timer div { height: 100%; width: 100%; background: var(--yellow); border-radius: 999px; }
.timer.low div { background: var(--red); }

.big-number { font: 600 88px/1 var(--display); color: var(--yellow); }
.line-card { width: 100%; background: var(--card); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; align-items: center; }
.line-card .big-number { font-size: 72px; }
.nice { font: 600 30px var(--display); color: var(--green); text-align: center; }

.save-row { display: flex; gap: 10px; }
.save-row input {
  flex-grow: 1; min-width: 0; height: 52px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text);
  padding: 0 16px; font: 600 22px var(--display); letter-spacing: 4px; text-transform: uppercase;
}
label { font-size: 14px; font-weight: 700; color: var(--soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); font-weight: 700;
  padding: 12px 18px; border-radius: 14px;
}
.icon { width: 72px; height: 72px; }

/* Tonight's top score */
#s-over.top #over-title {
  color: var(--yellow);
  text-shadow: 0 0 24px rgba(255, 210, 63, 0.55);
  animation: top-pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
#s-over.top #over-score { animation: top-glow 1.2s ease-in-out 0.4s 3 alternate; }
@keyframes top-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes top-glow {
  to { text-shadow: 0 0 28px rgba(255, 210, 63, 0.9); transform: scale(1.08); }
}

.celebrate { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 20; }
.celebrate span {
  position: absolute; top: -40px; left: var(--x);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--c);
  box-shadow: 0 0 12px 3px var(--c);
  opacity: 0;
  animation: bulb-fall linear forwards;
}
@keyframes bulb-fall {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  8% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), 110vh) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  #s-over.top #over-title, #s-over.top #over-score { animation: none; }
}
