:root {
  --sky: #9ed6f5;
  --ink: #3a2652;
  --pink: #f24b8a;
  --mint: #3dd6b5;
  --lilac: #b388ff;
  --cream: #fff7fb;
  --shadow: 0 16px 40px rgba(80, 40, 90, 0.18);
  color-scheme: light;
}

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

html, body, #app, .screen {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Nunito", "Fredoka", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: var(--sky);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
}

#home {
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 5;
}

.home-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(158, 214, 245, 0.28), rgba(255, 247, 251, 0.72)),
    url("../assets/hero.jpg") center / cover no-repeat;
  filter: saturate(1.05);
}

.home-card, .lobby-card, .results-card {
  position: relative;
  width: min(440px, 100%);
  background: rgba(255, 247, 251, 0.88);
  backdrop-filter: blur(16px);
  border: 3px solid #fff;
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 28px 26px 22px;
  text-align: center;
}

.mascot {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 10px 24px rgba(242, 75, 138, 0.25);
  margin: -72px auto 8px;
  background: #c9ebff;
}

h1, h2 {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(2.1rem, 6vw, 3rem); color: #e23d7e; }
.tag { color: #6b4b7a; margin: 6px 0 10px; }
.live { font-size: 0.85rem; color: #7a6288; margin-bottom: 16px; }

.field {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 0.82rem;
  color: #7a6288;
  font-weight: 800;
}

input {
  width: 100%;
  border: 0;
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  font: 700 1.05rem "Nunito", sans-serif;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px #f3d7e6;
  outline: none;
}

input:focus { box-shadow: inset 0 0 0 2px var(--pink); }

#code {
  text-align: center;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.btn {
  flex: 1;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 16px;
  font: 800 1rem "Fredoka", sans-serif;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active { transform: translateY(2px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08); }
.btn.pink { background: linear-gradient(#ff6ea4, var(--pink)); }
.btn.mint { background: linear-gradient(#62e8cb, #22c3a4); }
.btn.lilac { background: linear-gradient(#c9a6ff, #9b6cff); }
.btn.tiny { flex: 0; padding: 8px 12px; font-size: 0.85rem; background: #fff; color: var(--pink); box-shadow: inset 0 0 0 2px #ffd0e2; }
.btn:disabled { filter: grayscale(0.3) brightness(0.95); cursor: default; }

.hint {
  margin-top: 14px;
  font-size: 0.78rem;
  color: #8a7396;
}

#lobby {
  display: grid;
  place-items: center;
  background: rgba(158, 214, 245, 0.28);
  pointer-events: none;
  z-index: 20;
}
#lobby .lobby-card { pointer-events: auto; }
#game { z-index: 1; }
.kicker { font-size: 0.78rem; letter-spacing: 0.16em; font-weight: 800; color: #8a7396; }
.code-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0 16px; }
#lobby-code { font-size: 2.6rem; letter-spacing: 0.18em; color: #e23d7e; }

.player-list {
  list-style: none;
  display: grid;
  gap: 8px;
  text-align: left;
  margin-bottom: 8px;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 800;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}

.you { margin-left: auto; font-size: 0.75rem; color: #8a7396; }
.ready-dot { margin-left: auto; color: #22c3a4; font-size: 0.85rem; }
.text-btn {
  margin-top: 12px;
  background: none;
  border: 0;
  color: #8a7396;
  font: 800 0.9rem "Nunito", sans-serif;
  cursor: pointer;
}

#game { background: #8ec8ea; }
#c { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  pointer-events: none;
}

.pill, .course-wrap {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 22px;
  box-shadow: 0 10px 24px rgba(40, 50, 80, 0.12);
  padding: 10px 14px;
}

.time-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 800 1.35rem "Fredoka", sans-serif;
  min-width: 118px;
}

.course-wrap { text-align: center; padding: 8px 18px 10px; }
.course-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: #8a7396;
}
.course-bar {
  height: 10px;
  border-radius: 999px;
  background: #efe4f3;
  overflow: hidden;
  margin: 6px 0 8px;
}
.course-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8ab8, #ffd36b, #7ee081, #7ecbff, #c9a6ff);
}
.section-chip {
  display: inline-block;
  background: linear-gradient(#ff7eae, #f24b8a);
  color: #fff;
  font: 700 0.82rem "Fredoka", sans-serif;
  padding: 4px 12px;
  border-radius: 999px;
}

.check-pill { min-width: 132px; text-align: right; }
.check-kicker { font-size: 0.66rem; letter-spacing: 0.14em; font-weight: 800; color: #8a7396; }
#hud-check { font: 800 1.15rem "Fredoka", sans-serif; }
.best-row { font-size: 0.72rem; font-weight: 800; color: #8a7396; }

.toast {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(#ff7eae, #f24b8a);
  color: #fff;
  font: 700 1rem "Fredoka", sans-serif;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(242, 75, 138, 0.3);
  pointer-events: none;
}

.controls-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.controls-hint span {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #6b4b7a;
}

.sound-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 8px 12px;
  font: 800 0.75rem "Fredoka", sans-serif;
  color: #6b4b7a;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(120, 190, 230, 0.18);
}

#countdown {
  font: 800 7rem "Fredoka", sans-serif;
  color: #fff;
  text-shadow: 0 10px 0 rgba(226, 61, 126, 0.35);
}

.results-card { text-align: left; }
.results-card h2 { text-align: center; color: #e23d7e; margin-bottom: 12px; }
#results-list { list-style: none; display: grid; gap: 8px; margin-bottom: 8px; }
#results-list li {
  display: flex;
  justify-content: space-between;
  background: #fff;
  border-radius: 14px;
  padding: 8px 12px;
  font-weight: 800;
}

.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stick {
  position: absolute;
  left: 28px;
  bottom: 28px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: auto;
  touch-action: none;
}

.stick i {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}

#jump {
  position: absolute;
  right: 28px;
  bottom: 36px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(#ff6ea4, var(--pink));
  color: #fff;
  font: 800 0.95rem "Fredoka", sans-serif;
  pointer-events: auto;
  box-shadow: 0 8px 0 rgba(180, 40, 90, 0.25);
}

@media (max-width: 720px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .course-wrap { grid-column: 1 / -1; order: -1; }
  .controls-hint { display: none; }
  .mascot { width: 108px; height: 108px; margin-top: -58px; }
}

@media (pointer: coarse) {
  .controls-hint { display: none; }
}
