/* Screens owned by the core area: home (today.js), welcome (onboarding.js), play (play.js), result (result.js) and
   their parts (ui/core-*.js). Reads tokens.css; shared parts live in app.css. Every class here starts with core-. */

/* ---------- Shared core parts ---------- */
.core-stage, .core-ob-stage, .core-trio, .core-result-trio { position: relative; }
.core-stage .cine-panel { min-height: 158px; }
.core-stage .cine-panel:nth-child(2) { min-height: 172px; }
.core-stage .cine-panel .film, .core-ob-stage .cine-panel .film { font-size: clamp(1.1rem, 4.6vw, 1.35rem); line-height: 1.05; }
.core-stage.revealed .cine-panel { animation: core-flip var(--dur-slow) var(--ease-spring) both; }
.core-stage.revealed .cine-panel:nth-child(2) { animation-delay: 120ms; }
.core-stage.revealed .cine-panel:nth-child(3) { animation-delay: 240ms; }
@keyframes core-flip { from { opacity: .3; filter: brightness(1.6); } to { opacity: 1; filter: none; } }

.core-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.core-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: var(--radius-pill);
  font: 800 var(--fs-sm)/1.2 var(--font-body); border: 0; color: var(--text); background: var(--bg-inset);
}
.core-chip.film { background: var(--dim); color: var(--dim-text); font-family: var(--font-display); font-weight: 600; border-radius: 10px; }
.core-chip.film.opening { background: var(--cyan); color: var(--text-inverse); }
.core-chip.film.trick { background: var(--red); color: var(--cream); }
.core-chip.film.final { background: var(--gold); color: var(--text-inverse); }
button.core-chip.film { cursor: pointer; min-height: var(--tap); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.core-chip.person .pts { color: var(--gold); font-weight: 800; }
.core-chip .half { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--cyan-tint); color: var(--dim-text); font-size: var(--fs-xs); }
.core-chip.enter { animation: chip-in var(--dur-slow) var(--ease-spring) both; }
.core-chip .tier-shape, .core-chip svg { width: 12px; height: 12px; flex: none; }
.core-fine { color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; text-align: center; }
.core-fine b.red { color: #ff8aa5; }
.core-fine b.gold { color: var(--gold); }

/* ---------- Home ---------- */
.core-today { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabs-h)); }
.core-home-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.core-home-logo { height: 40px; }
.core-home-me { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); }
.core-streak { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--bg-card); color: var(--text); font-weight: 800; text-decoration: none; }
.core-streak svg { width: 16px; height: 16px; color: var(--gold); }
.core-nudge { margin-top: var(--s4); }
.core-daily { display: flex; flex-direction: column; }
.core-daily-head { text-align: center; margin-top: var(--s8); }
.core-daily-num { font: 700 var(--fs-2xl)/1.1 var(--font-display); }
.core-daily-sub { margin-top: 4px; color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); }
.core-stage { margin: var(--s8) auto 0; width: 100%; max-width: 380px; }
.core-theme { text-align: center; margin-top: var(--s8); }
.core-theme-label { font: 600 var(--fs-xl)/1.2 var(--font-display); color: var(--gold); }
.core-theme-hint { margin-top: 4px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; text-wrap: balance; }
.core-cta { margin-top: var(--s8); }
.core-cta .btn-lg { min-height: 60px; font: 700 var(--fs-xl) var(--font-display); }
.core-note { margin-top: var(--s3); text-align: center; color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; }
.core-played { display: flex; align-items: baseline; justify-content: center; gap: var(--s3); margin-bottom: var(--s4); }
.core-played b { font: 700 var(--fs-2xl) var(--font-display); color: var(--gold); }
.core-party { margin-top: var(--s6); }
.core-party-dots { display: flex; flex: none; }
.core-party-dots i { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--bg-card); background: var(--red); }
.core-party-dots i:nth-child(2) { background: var(--cyan); margin-left: -9px; }
.core-party-dots i:nth-child(3) { background: var(--gold); margin-left: -9px; }
.core-home-foot { margin-top: auto; padding-top: var(--s6); text-align: center; display: grid; justify-items: center; }
.core-home-foot > a { display: inline-flex; align-items: center; min-height: var(--tap); font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); text-decoration: none; }

/* ---------- Welcome ---------- */
.core-ob-card { text-align: left; }
.core-ob-hero { align-items: center; text-align: center; justify-content: center; }
.core-ob-hero .core-ob-stage { width: 100%; max-width: 340px; }
.core-ob-mark { height: auto; margin: 0 auto; }
.core-ob-lead { font-size: var(--fs-lg); color: var(--text-2); line-height: 1.4; font-weight: 600; }
.core-ob-shout { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); letter-spacing: .04em; }
.core-ob-title { font: 700 clamp(1.6rem, 7vw, 2.1rem)/1.15 var(--font-display); text-wrap: balance; }
.core-ob-demo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: var(--s5); border-radius: var(--radius-lg); background: var(--bg-raised); }
.core-ob-arrow { color: var(--text-2); font-weight: 800; }
.core-ob-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.core-ob-rules li { padding: var(--s4); border-radius: var(--radius); --rule-edge: var(--line-strong); background: var(--bg-card); box-shadow: 0 4px 0 var(--rule-edge); color: var(--text-2); font-weight: 600; line-height: 1.4; }
.core-ob-rules li b { display: block; color: var(--text); font: 600 var(--fs-lg)/1.25 var(--font-display); margin-bottom: 2px; }
.core-ob-rules li.red { --rule-edge: var(--red-edge); }
.core-ob-rules li.cyan { --rule-edge: var(--cyan-edge); }
.core-ob-rules li.gold { --rule-edge: var(--gold-edge); }
/* Every intro card sizes its big parts to the height the track actually has (cqh = 1% of it), so nothing is cut
   off on short phones, under browser bars or with the keyboard up. The card still scrolls as a last resort. */
.core-ob-stage .cine-panel { min-height: clamp(76px, 30cqh, 158px); }
.core-ob-stage .cine-panel:nth-child(2) { min-height: clamp(84px, 33cqh, 172px); }
.core-ob-hero .core-ob-stage { margin: clamp(4px, 3cqh, var(--s6)) 0 clamp(4px, 2cqh, var(--s4)); }
.core-ob-mark { width: min(300px, 80vw, 66cqh); }
.core-ob-title { font-size: min(clamp(1.6rem, 7vw, 2.1rem), 8.5cqh); }
@container ob (max-height: 430px) {
  .core-ob-stage .cine-panel { padding-block: var(--s2); }
  .core-ob-stage .cine-panel .film { font-size: min(1.35rem, 7cqh); }
  .ob-card { gap: var(--s2); }
  .core-ob-lead { font-size: var(--fs-md); }
  .core-ob-demo { padding: var(--s3); }
  .core-ob-rules { gap: var(--s2); }
  .core-ob-rules li { padding: var(--s2) var(--s3); font-size: var(--fs-sm); line-height: 1.3; }
  .core-ob-rules li b { font-size: var(--fs-md); }
}
@container ob (max-height: 330px) {
  .ob-card > .label.accent { display: none; }
  .core-ob-rules li b { display: inline; margin-right: 4px; }
  .ob-card { gap: 6px; }
  .core-ob-rules li { font-size: var(--fs-xs); }
}
/* The name card with the phone keyboard up: keep the field and "Let's play", drop the extra lines. */
@container ob (max-height: 260px) {
  .ob-card .core-ob-lead, .ob-card .hint { display: none; }
}

/* ---------- Play ---------- */
.core-top { display: flex; align-items: center; gap: var(--s3); }
.core-top-title { flex: 1; min-width: 0; text-align: center; font: 700 var(--fs-lg) var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.core-clock { min-width: 64px; text-align: right; font: 700 var(--fs-xl) var(--font-display); font-variant-numeric: tabular-nums; }
.core-clock.low { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.core-clock.untimed { font: 800 var(--fs-xs) var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.core-clock.hit { animation: core-hit 700ms var(--ease-out); }
@keyframes core-hit { 0%, 40% { color: var(--danger); transform: scale(1.18); } 100% { transform: none; } }
.core-trio { margin-top: var(--s5); }
.core-trio .cine-panel { min-height: 104px; }
.core-trio .cine-panel.here { outline-width: 3px; }
.core-rival { margin-top: var(--s4); }
.core-step { margin-top: var(--s6); }
.core-step.shake { animation: core-shake 420ms var(--ease-out); }
@keyframes core-shake { 15%, 55% { transform: translateX(-8px); } 35%, 75% { transform: translateX(8px); } 100% { transform: none; } }
.core-steps { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; gap: 10px; font-size: var(--fs-sm); font-weight: 800; color: var(--text-2); }
.core-steps li { display: flex; align-items: center; gap: 7px; }
.core-steps li > span { width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; background: var(--line); font: 700 13px var(--font-display); }
.core-steps li > span svg { width: 14px; height: 14px; }
.core-steps li.on { color: var(--text); }
.core-steps li.on > span { background: var(--gold); color: var(--text-inverse); }
.core-steps li.done > span { background: var(--green); color: var(--text-inverse); }
.core-steps li.bar { width: 18px; height: 2px; border-radius: 1px; background: var(--line); }
#picked:not(:empty) { display: flex; justify-content: center; margin-top: var(--s4); }
.core-person {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px 0 22px; border: 0; border-radius: 24px;
  background: var(--cyan); box-shadow: 0 4px 0 var(--cyan-edge); color: var(--text-inverse); font: 800 var(--fs-lg) var(--font-body); cursor: pointer;
}
.core-person svg { width: 16px; height: 16px; }
.core-prompt { margin-top: var(--s4); text-align: center; font: 800 var(--fs-lg)/1.3 var(--font-body); text-wrap: balance; }
.core-prompt .core-now { color: var(--gold); }
.core-answer { position: relative; margin-top: var(--s4); }
.core-input {
  width: 100%; min-height: 60px; padding: 0 var(--s4); border-radius: var(--radius); border: 2px solid var(--line-strong);
  background: var(--bg-inset); color: var(--text); font: 700 var(--fs-xl) var(--font-display); text-align: center;
}
.core-input::placeholder { color: var(--text-2); font-weight: 600; }
.core-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 178, 51, .25); }
.core-input:disabled { opacity: .6; }
.core-ta { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: 6px; }
.core-ta:empty { display: none; }
.core-ta-opt {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; padding: 0 var(--s4);
  border-radius: var(--radius-sm); background: var(--bg-card); cursor: pointer; font-weight: 800; font-size: var(--fs-md);
}
.core-ta-opt[aria-selected="true"] { background: var(--gold-tint); box-shadow: inset 0 0 0 2px var(--gold); }
.core-ta-year { color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); }
.core-ta-tag { flex: none; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.core-ta-tag.red { color: #ff8aa5; }
.core-ta-tag.gold { color: var(--gold); }
.core-ta-empty { padding: var(--s3); text-align: center; color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); }
.core-step .core-fine { margin-top: var(--s3); }
.core-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s6); }
.core-peek { min-height: var(--tap); }
.core-misses { font-weight: 800; font-size: var(--fs-sm); color: var(--text-2); }
.core-misses.has { color: var(--danger); }
.core-chain-card { margin-top: var(--s4); }
.core-chain-card .spread { margin-bottom: var(--s3); align-items: center; }
.core-chain-card .label { letter-spacing: .08em; }
.core-chain-card [data-undo] { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); }
.core-chain-card [data-undo] svg { width: 18px; height: 18px; }
.core-tools { display: flex; gap: var(--s2); margin-top: var(--s4); }
.core-tools .btn { flex: 1; }
.core-peek-note { margin: var(--s2) 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); background: var(--cyan-tint); color: var(--dim-text); font-weight: 800; font-size: var(--fs-sm); }
.core-peek-list { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: 4px; }
.core-peek-row {
  width: 100%; min-height: 52px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px;
  padding: var(--s2) var(--s4); border: 0; border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text); text-align: left; cursor: pointer;
}
.core-peek-row .name { font-weight: 800; }
.core-peek-row .role { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.core-peek-row:disabled { opacity: .55; cursor: default; }

/* ---------- Result ---------- */
.core-result-trio { margin-top: var(--s3); }
.core-hero { text-align: center; margin-top: var(--s5); position: relative; }
.core-hero-score { font: 700 clamp(3.4rem, 18vw, 4.6rem)/1 var(--font-display); color: var(--gold); }
.core-hero-score small { font-size: .38em; color: var(--text-2); }
.core-hero-score.out { font-size: clamp(2.4rem, 12vw, 3.2rem); color: var(--text-2); }
.core-hero-sub { margin-top: var(--s2); color: var(--text-2); font-weight: 800; }
.core-par-flag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s2); padding: 4px 12px; border-radius: var(--radius-pill); background: var(--green); color: var(--text-inverse); font-weight: 800; font-size: var(--fs-sm); }
.core-par-flag svg { width: 16px; height: 16px; }
.core-hero-rank:not(:empty) { display: inline-flex; gap: var(--s2); align-items: baseline; margin-top: var(--s2); }
.core-stats { list-style: none; margin: var(--s4) 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); }
.core-stats li { padding: 6px 14px; border-radius: var(--radius-pill); background: var(--bg-card); font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); }
.core-stats li b { color: var(--text); }
.core-stats li.good b { color: var(--good); }
.core-stats li.bad b { color: var(--danger); }
.core-sec-label { margin-bottom: var(--s3); }
.core-fold { margin-top: var(--s4); }
.core-fold summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 800; list-style: none; }
.core-fold summary::-webkit-details-marker { display: none; }
.core-fold summary::after { content: "+"; margin-left: auto; font: 700 var(--fs-xl) var(--font-display); color: var(--gold); }
.core-fold[open] summary::after { content: "−"; }
.core-fold[open] summary { margin-bottom: var(--s3); }
.core-half-tag { font-size: var(--fs-xs); font-weight: 800; color: var(--dim-text); }
.core-par-route { margin-top: var(--s2); }
.core-result-foot .btn-primary { font-family: var(--font-display); }

/* ---------- Tablet and desktop: the app column grows for the game, which gets a side panel ---------- */
@media (min-width: 760px) {
  .core-stage { max-width: 440px; }
  .core-stage .cine-panel { min-height: 190px; }
  .core-stage .cine-panel:nth-child(2) { min-height: 206px; }
  .core-trio { max-width: 460px; margin-left: auto; margin-right: auto; }
  .core-trio .cine-panel { min-height: 124px; }
}
@media (min-width: 1200px) {
  :root:has(.core-play) { --col: 1040px; }
  .core-play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s8); align-items: start; }
  .core-play-side { position: sticky; top: var(--s5); margin-top: var(--s5); padding: var(--s5); border-radius: var(--radius-lg); background: var(--bg-raised); }
  .core-play-side .core-meta { margin-top: 0; }
  .core-play-side .core-chain-card { background: var(--bg-card); }
  .core-trio { max-width: 560px; }
  .core-trio .cine-panel { min-height: 150px; }
  .core-trio .cine-panel .film { font-size: var(--fs-lg); }
  .core-play .core-step { max-width: 520px; margin-left: auto; margin-right: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .core-step.shake, .core-clock.hit, .core-stage.revealed .cine-panel, .core-chip.enter { animation: none; }
}
.sealed .cine-panel .film { font: 700 clamp(3rem, 14vw, 4rem)/1 var(--font-display); }
