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

:root {
  --deep: #2a1a5e;     /* headings */
  --ink: #23213a;
  --gold: #ffc233;
  --pink: #ff3d77;
  --cyan: #18b6c4;
  --muted: #5a5478;
}

body {
  font-family: "Fredoka", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: linear-gradient(180deg, #3a1d6e 0%, #c01f8a 52%, #ff7a3c 100%);
  background-attachment: fixed;
}

/* ---- screens ---- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ---- shared bits ---- */
h1 { font-size: clamp(1.9rem, 6vw, 3.2rem); font-weight: 700; color: var(--deep); line-height: 1.05; }
h1 span { color: var(--pink); }
.tagline { font-size: clamp(1rem, 3vw, 1.3rem); color: var(--deep); font-weight: 500; }
.mini { font-size: .9rem; color: var(--muted); }

.brand {
  font-weight: 700; font-size: clamp(2.6rem, 9vw, 4rem);
  letter-spacing: 1px; line-height: 1; color: var(--deep);
  margin-bottom: 2px;
}
.brand span { color: var(--gold); -webkit-text-stroke: 1.5px var(--pink); }

.big-btn {
  font-family: inherit; font-size: 1.3rem; font-weight: 600;
  color: var(--deep);
  background: linear-gradient(180deg, #ffd76b, var(--gold));
  border: 3px solid #fff; border-radius: 999px;
  padding: 15px 46px; cursor: pointer;
  box-shadow: 0 8px 0 #d99300, 0 12px 24px rgba(0,0,0,.28);
  transition: transform .08s ease, box-shadow .08s ease;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #d99300, 0 6px 12px rgba(0,0,0,.25); }

.ghost-btn {
  font-family: inherit; font-size: 1rem; font-weight: 500;
  color: var(--deep); background: rgba(255,255,255,.78);
  border: 2px solid var(--deep); border-radius: 999px;
  padding: 10px 24px; cursor: pointer;
}
.ghost-btn:hover { background: #fff; }
.ghost-btn.small { font-size: .92rem; padding: 8px 18px; }
.ghost-btn:disabled { opacity: .4; cursor: default; }

/* ---- welcome / loading panel ---- */
.panel {
  background: rgba(255,255,255,.95);
  border-radius: 28px;
  padding: 36px clamp(22px, 5vw, 52px);
  margin: auto;
  max-width: 560px; text-align: center;
  box-shadow: 0 20px 50px rgba(20,10,50,.4);
}
.skyline { font-size: 2.4rem; margin-bottom: 6px; }
.panel h1 { margin-bottom: 12px; }
.panel .tagline { margin-bottom: 22px; }

.how { list-style: none; text-align: left; margin: 0 auto 26px; max-width: 400px; }
.how li {
  background: #f4f0ff; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 10px;
  font-size: 1rem; font-weight: 500;
}
.how li b { margin-right: 8px; font-size: 1.2rem; }

.save-note {
  background: #fff3da; border: 2px solid var(--gold);
  border-radius: 14px; padding: 12px 18px; margin-bottom: 20px;
  font-size: .98rem; font-weight: 500; color: var(--deep);
}

.panel .big-btn { display: block; width: 100%; max-width: 360px; margin: 0 auto; }
.panel #continue-btn { margin-bottom: 14px; }
.panel #clear-btn { margin-top: 16px; }
.hidden { display: none !important; }
.panel .mini { margin-top: 16px; }

.loader {
  width: 64px; height: 64px; margin: 0 auto 22px;
  border: 7px solid #e7ddff; border-top-color: var(--pink);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- name field ---- */
.name-field { margin: 0 auto 22px; max-width: 380px; text-align: left; }
.name-field label {
  display: block; font-weight: 600; color: var(--deep);
  margin-bottom: 8px; font-size: 1.05rem;
}
.name-field input {
  font-family: inherit; font-size: 1.15rem; font-weight: 500;
  width: 100%; padding: 12px 16px; color: var(--ink);
  background: #f4f0ff; border: 2px solid #d9cdf3; border-radius: 14px;
}
.name-field input:focus { outline: none; border-color: var(--pink); background: #fff; }
.name-error { margin-top: 8px; font-size: .92rem; font-weight: 600; color: var(--pink); }

/* ---- game / rating ---- */
#game.active { padding: 18px 16px 36px; }
.game-head { width: 100%; max-width: 540px; margin-bottom: 16px; }
.progress {
  height: 16px; background: rgba(255,255,255,.55);
  border: 2px solid #fff; border-radius: 999px; overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  transition: width .4s ease;
}
.round-label { text-align: center; margin-top: 10px; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.round-label strong { color: #fff; }

.arena { width: 100%; max-width: 520px; display: flex; justify-content: center; }

.card {
  width: 100%; background: #fff; border: 4px solid #fff;
  border-radius: 22px; overflow: hidden; text-align: left; padding: 0;
  box-shadow: 0 14px 34px rgba(20,10,50,.34);
  transition: transform .14s ease, box-shadow .14s ease, opacity .2s ease;
}
.card-img {
  position: relative; height: 300px;
  background-size: cover; background-position: center;
  background-color: #e7ddff;
  display: flex; align-items: center; justify-content: center;
}
.card-img .emoji {
  position: absolute; top: 10px; left: 10px;
  width: 46px; height: 46px; font-size: 1.6rem;
  background: rgba(255,255,255,.94); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.venue-chip {
  position: absolute; left: 10px; bottom: 10px;
  max-width: calc(100% - 20px);
  background: rgba(30,12,60,.82); color: #fff;
  font-size: .82rem; font-weight: 500;
  padding: 6px 12px; border-radius: 999px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-img.no-img { background: linear-gradient(135deg, var(--gold), var(--pink)); }
.card-img.no-img .emoji {
  position: static; width: auto; height: auto;
  font-size: 6rem; background: none; box-shadow: none;
}
.card-body { padding: 16px 20px 20px; }
.card-body h2 { font-size: 1.5rem; color: var(--deep); font-weight: 700; margin-bottom: 6px; }
.card-body p { font-size: 1rem; line-height: 1.45; color: #463f63; font-weight: 400; }

/* ---- "Why see it live?" disclosure on the rating card ---- */
.card-more { margin-top: 14px; }
.card-more-toggle {
  font-family: inherit; font-size: 1rem; font-weight: 600; color: var(--deep);
  background: #f4f0ff; border: 2px solid #e2d8f7; border-radius: 999px;
  padding: 9px 18px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.card-more-toggle:hover { background: #ece4ff; }
.card-more-toggle:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; }
.card-more-toggle .more-caret { font-size: .85em; transition: transform .15s ease; }
.card-more-toggle.open .more-caret { transform: rotate(180deg); }
.card-more-content[hidden] { display: none; }
.card-more-content { margin-top: 12px; }
.card-hype { font-size: .98rem; line-height: 1.55; color: #463f63; font-weight: 400; margin-bottom: 12px; }
.card-links { display: flex; flex-wrap: wrap; gap: 10px; }
.card-link {
  font-family: inherit; font-size: .92rem; font-weight: 600; color: var(--deep);
  text-decoration: none; background: #f4f0ff; border: 2px solid #d9cdf3;
  padding: 8px 14px; border-radius: 999px;
  transition: background-color .1s ease, border-color .1s ease;
}
.card-link:hover { background: #fff; border-color: var(--deep); }

.card.rated { animation: pop .42s ease; }
.card.skipped { opacity: .35; transform: scale(.97); }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.035); box-shadow: 0 0 0 6px var(--gold), 0 18px 40px rgba(20,10,50,.4); }
  100% { transform: scale(1.01); }
}

/* ---- star rating bar ---- */
.rate-bar { width: 100%; max-width: 520px; text-align: center; margin-top: 16px; }
.stars { display: flex; justify-content: center; gap: clamp(6px, 2.5vw, 14px); }
.star {
  font-family: inherit;
  font-size: clamp(40px, 11vw, 56px); line-height: 1;
  color: rgba(255,255,255,.55);
  background: none; border: none; cursor: pointer;
  padding: 2px 2px 0; text-shadow: 0 2px 6px rgba(0,0,0,.18);
  transition: transform .08s ease, color .08s ease;
  -webkit-tap-highlight-color: transparent;
}
.star:hover { transform: translateY(-3px) scale(1.08); }
.star:active { transform: scale(.92); }
.star.on { color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.32); }
.star:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 8px; }

.star-label {
  min-height: 1.5em; margin: 8px 0 4px;
  font-size: 1.25rem; font-weight: 600; color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.35);
}
.star-label.set { color: #fff; }

.rate-actions { display: flex; justify-content: center; gap: 12px; margin-top: 6px; }
.hint { margin-top: 12px; color: #fff; font-size: .9rem; opacity: .85; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.hint b { font-weight: 700; }

/* ---- player results ---- */
#results.active { padding: 30px 16px 50px; }
.results-inner { width: 100%; max-width: 620px; text-align: center; }
.results-inner > h1 { margin-bottom: 6px; }
.results-inner > .tagline { margin-bottom: 18px; }

.podium { margin-bottom: 10px; }
.mustsee-head {
  display: inline-block; background: var(--deep); color: var(--gold);
  font-weight: 600; font-size: 1.05rem;
  padding: 8px 22px; border-radius: 999px; margin-bottom: 14px;
}

.rest, .full { list-style: none; }
.full.hidden { display: none; }
.full { margin-top: 14px; }

.row {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.96);
  border-radius: 16px; padding: 10px 14px; margin-bottom: 10px;
  text-align: left;
}
.row-img {
  flex: none; width: 60px; height: 60px; border-radius: 12px;
  background-size: cover; background-position: center;
  background-color: #e7ddff;
  display: flex; align-items: center; justify-content: center;
}
.row-img.no-img { background: linear-gradient(135deg, var(--gold), var(--pink)); }
.row-img .emoji { font-size: 1.8rem; }
.row-info { display: flex; flex-direction: column; gap: 2px; }
.row-info strong { font-size: 1.1rem; color: var(--deep); font-weight: 600; }
.row-stars { font-size: 1.05rem; color: var(--gold); letter-spacing: 1px; }
.row-stars .dim { color: #d8d2e8; }
.row-stars.skipped { color: var(--muted); font-size: .9rem; letter-spacing: 0; }

.results-inner .ghost-btn { margin: 8px 0 20px; }
.results-inner .big-btn { margin-top: 6px; }
.credit { margin-top: 18px; color: rgba(255,255,255,.9); }

/* ---- results submission status ---- */
.submit-status { min-height: 1.2em; margin-bottom: 16px; font-size: 1rem; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.submit-status.ok { color: #d7ffe6; }
.submit-status.err { color: #ffe0e0; }
.link-btn {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  color: #fff; background: none; border: none; padding: 0;
  cursor: pointer; text-decoration: underline;
}

/* ---- parent results viewer ---- */
.results-inner.viewer { max-width: 720px; padding-top: 10px; }
.results-inner.viewer > h1 { color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
.results-inner.viewer > .tagline { color: #fff; margin-bottom: 22px; text-shadow: 0 1px 6px rgba(0,0,0,.3); }
.empty, .loading-note {
  background: rgba(255,255,255,.96); border-radius: 16px;
  padding: 24px 18px; font-size: 1.05rem; font-weight: 500;
  color: var(--deep); line-height: 1.5;
}
.player-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px; padding: 18px 18px 20px;
  margin-bottom: 18px; text-align: left;
  box-shadow: 0 12px 30px rgba(20,10,50,.3);
}
.player-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.player-head h2 { font-size: 1.5rem; color: var(--deep); font-weight: 700; }
.player-when { font-size: .9rem; color: var(--muted); font-weight: 500; }
.player-sub { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
.player-card .rest, .player-card .full { margin-top: 0; }
.player-card .ghost-btn { margin-top: 4px; }
.results-inner.viewer #refresh { margin: 6px 0 14px; background: rgba(255,255,255,.92); }

/* ---- family summary table ---- */
.summary {
  background: rgba(255,255,255,.97);
  border-radius: 20px; padding: 20px 18px 22px;
  margin-bottom: 22px; text-align: left;
  box-shadow: 0 12px 30px rgba(20,10,50,.3);
}
.summary h2 { font-size: 1.45rem; color: var(--deep); font-weight: 700; margin-bottom: 4px; }
.summary-note { font-size: .95rem; color: #463f63; font-weight: 500; margin-bottom: 14px; line-height: 1.4; }
.summary-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.summary-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .95rem; }
.summary-table th, .summary-table td {
  padding: 8px 10px; border-bottom: 1px solid #ece6f7;
  vertical-align: middle; white-space: nowrap;
}
.summary-table thead th {
  font-weight: 700; color: var(--deep); background: #f4f0ff;
  position: sticky; top: 0; text-align: center; font-size: .92rem;
}
.summary-table .num-th, .summary-table .spot-th { text-align: left; }
.summary-table .num-cell { width: 50px; font-weight: 700; color: var(--deep); text-align: left; }
.summary-table .spot-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; white-space: normal; }
.summary-table .spot-thumb {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  background-size: cover; background-position: center; background-color: #e7ddff;
  display: flex; align-items: center; justify-content: center;
}
.summary-table .spot-thumb.no-img { background: linear-gradient(135deg, var(--gold), var(--pink)); }
.summary-table .spot-thumb .emoji { font-size: 1.1rem; }
.summary-table .spot-name { font-weight: 600; color: var(--deep); line-height: 1.25; }
.summary-table .kid-th, .summary-table .avg-th { min-width: 58px; }
.summary-table .star-cell, .summary-table .avg-cell {
  text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; color: #463f63;
}
.summary-table .avg-cell { color: var(--deep); }
.summary-table .star-cell.s5 { background: #fff0c2; color: #8a5a00; border-radius: 8px; }
.summary-table .star-cell.s4 { background: #d9f2d2; color: #2c6b22; border-radius: 8px; }
.summary-table .star-cell.s3 { background: #eef0f6; color: #4a567a; border-radius: 8px; }
.summary-table .star-cell.s2 { background: #f4f1f6; color: #8a90a6; border-radius: 8px; font-weight: 600; }
.summary-table .star-cell.s1 { background: #f9eef1; color: #b56079; border-radius: 8px; font-weight: 600; }
.summary-table .star-cell.empty { color: #c2bcd2; font-weight: 500; }
.summary-table tbody tr:hover td { background: #faf7ff; }
.summary.one-player .avg-th, .summary.one-player .avg-cell { display: none; }

/* ---- clickable rows ---- */
.row.clickable { cursor: pointer; position: relative; transition: transform .08s ease, box-shadow .08s ease, background-color .08s ease; }
.row.clickable:hover { background: #fff; transform: translateX(2px); box-shadow: 0 4px 14px rgba(20,10,50,.18); }
.row.clickable:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; }
.row .row-arrow { margin-left: auto; color: var(--deep); opacity: .35; font-size: 1.6rem; line-height: 1; padding-right: 4px; transition: opacity .12s ease, transform .12s ease; }
.row.clickable:hover .row-arrow { opacity: 1; transform: translateX(2px); }
.summary-table tbody tr.clickable { cursor: pointer; }
.summary-table tbody tr.clickable:hover td { background: #f4f0ff; }
.summary-table tbody tr.clickable:hover .spot-name { color: var(--pink); }

/* ---- detail modal ---- */
body.modal-open, html:has(body.modal-open) { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: modal-fade .18s ease; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,8,40,.66); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-panel {
  position: relative; width: 100%; max-width: 540px; max-height: calc(100vh - 32px);
  background: #fff; border-radius: 24px; overflow: hidden; overflow-y: auto;
  box-shadow: 0 28px 64px rgba(10,4,30,.55); display: flex; flex-direction: column;
  animation: modal-pop .22s cubic-bezier(.2,.9,.4,1.2);
}
.modal-panel:focus { outline: none; }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px;
  background: rgba(255,255,255,.94); color: var(--deep); border: none; border-radius: 50%;
  font-family: inherit; font-size: 1.6rem; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(10,4,30,.3); z-index: 2;
}
.modal-close:hover { transform: scale(1.05); }
.modal-img { width: 100%; height: 280px; background-size: cover; background-position: center; background-color: #e7ddff; flex: none; display: flex; align-items: center; justify-content: center; }
.modal-img.no-img { background: linear-gradient(135deg, var(--gold), var(--pink)); }
.modal-img .emoji { font-size: 5rem; }
.modal-body { padding: 20px 24px 26px; }
.modal-rank-tag { display: inline-block; background: var(--gold); color: var(--deep); font-weight: 700; font-size: .9rem; padding: 4px 14px; border-radius: 999px; margin-bottom: 8px; }
.modal-rank-tag.hidden { display: none; }
.modal-body h2 { font-size: 1.8rem; font-weight: 700; color: var(--deep); line-height: 1.15; margin-bottom: 6px; }
.modal-venue { font-size: .95rem; font-weight: 600; color: var(--cyan); margin-bottom: 10px; }
.modal-blurb { font-size: 1.05rem; font-weight: 600; color: var(--pink); line-height: 1.4; margin-bottom: 12px; }
.modal-hype { font-size: 1rem; line-height: 1.55; color: #463f63; margin-bottom: 20px; font-weight: 400; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.modal-link {
  font-family: inherit; font-size: .96rem; font-weight: 600; color: var(--deep);
  text-decoration: none; background: #f4f0ff; border: 2px solid #d9cdf3;
  padding: 10px 16px; border-radius: 999px; flex: 1 1 auto; text-align: center; min-width: 140px;
  transition: background-color .1s ease, border-color .1s ease;
}
.modal-link:hover { background: #fff; border-color: var(--deep); }
.modal-link.hidden { display: none; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---- responsive ---- */
@media (max-width: 600px) {
  .card-img { height: 220px; }
  .summary-table .spot-cell { min-width: 150px; }
  .summary-table .spot-name { font-size: .9rem; }
  .summary-table .spot-thumb { width: 30px; height: 30px; }
  .summary-table th, .summary-table td { padding: 6px 7px; }
  .modal-img { height: 200px; }
  .modal-body h2 { font-size: 1.5rem; }
  .modal-body { padding: 18px 18px 22px; }
}
