/* Kurvkalaset only (spel-kurvkalaset.html).
   Split out of css/style.css so pages do not download rules they cannot use; tests/css-scope.test.js checks the scope. */

/* ===================== Kurvkalaset (kart racing) ===================== */
.kart-stage .adv-btns { grid-template-areas: "lamp item" ". action"; }
.kart-stage .kart-brake { width: 62px; height: 62px; background: #ffe1dc; }
.kart-stage .adv-stick-zone { width: 50%; height: 78%; }
.kart-hud .kart-place { font-size: 1.35rem; padding: 3px 12px; }
.kart-hud .kart-place small { font-size: .8rem; opacity: .7; }
.kart-hud .chip.boost { background: #ffe08a; }
.kart-hud .chip.drift { background: #d6efff; }
.kart-hud .chip.drift.t2 { background: #ffe08a; }
.kart-gate { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3; display: grid; justify-items: center; gap: 6px; pointer-events: none; }
.kart-gate .q { background: #1f2348; color: #ffe08a; font-weight: 900; font-size: 1.7rem; border-radius: 16px; padding: 4px 18px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.kart-gate .lanes { display: flex; gap: 8px; pointer-events: auto; }
.kart-gate button { position: relative; min-width: 64px; min-height: 48px; border: 0; border-radius: 14px; background: #fff; box-shadow: inset 0 -6px 0 var(--lane), 0 4px 0 rgba(0,0,0,.22); font: inherit; font-weight: 900; font-size: 1.35rem; color: var(--ink); cursor: pointer; touch-action: none; padding: 4px 12px 8px; }
.kart-gate button.on { background: var(--lane); outline: 3px solid #1f2348; }
.kart-gate button kbd { position: absolute; top: -6px; left: -6px; font-size: .6rem; padding: 1px 5px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: none; }
.adv-explain.kart-explain { top: auto; bottom: 16px; left: 16px; transform: scale(.72); transform-origin: left bottom; }
.adv-explain.kart-explain.out { opacity: 0; }
.kart-results { columns: 2; text-align: left; max-width: 320px; margin: 10px auto 0; padding-left: 0; list-style: none; }
.kart-results li.me { background: #fff1c2; font-weight: 900; }
@media (max-width: 640px) {
  .kart-gate { top: 66px; }
  .kart-hud { max-width: 100%; }
}
@media (max-width: 640px), (max-height: 500px) {
  .kart-gate .q { font-size: 1.25rem; padding: 2px 12px; }
  .kart-gate button { min-width: 52px; min-height: 44px; font-size: 1.1rem; }
  .kart-stage .kart-brake { width: 54px; height: 54px; }
}
.kart-stage .adv-pop { white-space: normal; width: max-content; max-width: min(92%, 34rem); text-align: center; line-height: 1.1; }
@media (max-width: 640px) {
  .kart-stage .adv-pop { font-size: 1.45rem; }
  .kart-stage .adv-pop.info { font-size: 1.15rem; }
}
/* Kurvkalaset start card on short screens (≤ 920 px high, where the shared rule hides the companion): the companion becomes a small badge beside the title
   (still visible). On wide screens the four option rows sit two by two, labels left of their buttons, so the card fits the stage. */
.kart-stage #overlay .card > p[style] { margin: 4px 0 2px !important; }
.kart-stage #overlay .card > .gs-go { margin-top: 6px !important; }
.kart-cab-btn { margin: 6px 0 0 6px; min-height: 44px; vertical-align: middle; }
@media (max-height: 920px) {
  .kart-stage #overlay .card { position: relative; }
  .kart-stage #overlay .card > div:first-child:has(> svg) { display: block !important; position: absolute; left: 14px; top: 8px; width: 64px !important; margin: 0 !important; z-index: 1; }
  .kart-stage #overlay .card > h2, .kart-stage #overlay .card > h2 + p { margin-left: 70px; margin-right: 20px; }
}
@media (min-width: 641px) {
  .kart-stage #overlay .card { display: grid; grid-template-columns: max-content max-content max-content max-content; justify-content: center; column-gap: 10px; align-items: center; max-width: min(820px, 96%); }
  .kart-stage #overlay .card > * { grid-column: 1 / -1; }
  .kart-stage #overlay .card > div:first-child:has(> svg) { justify-self: center; }
  .kart-stage #overlay .card > h2 + p { max-width: 640px; justify-self: center; }
  .kart-stage #overlay .card > p:has(+ .toggle-group) { grid-column: auto; text-align: right; margin: 3px 0 !important; }
  .kart-stage #overlay .card > .toggle-group { grid-column: auto; justify-content: flex-start; margin: 3px 0; flex-wrap: nowrap; }
  /* Eight tracks and two cups: the track row wraps and does not size the grid columns (contain). */
  .kart-stage #overlay .card > p:has(+ .toggle-group[data-opt="track"]) { grid-column: 1; }
  .kart-stage #overlay .card > .toggle-group[data-opt="track"] { grid-column: 2 / -1; flex-wrap: wrap; row-gap: 2px; contain: inline-size; width: min(680px, 74vw); }
  .kart-stage #overlay .card > .toggle-group[data-opt="track"] button { padding-inline: 10px; font-size: .9rem; }
}
/* Trophy cabinet */
.kart-cab { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(31, 35, 72, .38); padding: 10px; }
.kart-cab[hidden] { display: none; }
.kart-cab .card { max-width: 560px; width: 100%; max-height: 100%; overflow: auto; text-align: center; }
.kart-cab-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .95rem; }
.kart-cab-table th, .kart-cab-table td { padding: 6px 4px; border-bottom: 1px solid #efe4d6; }
.kart-cab-table tbody th { text-align: left; font-weight: 800; }
.kart-medal { font-size: 1.5rem; line-height: 1; }
.kart-medal.none { color: #c9bfb2; font-size: 1.2rem; }
/* Kurvkalaset v4: garage, notes on the start card, unlocks on the end card */
.kart-start-btns { display: inline; }
.kart-gar-btn { margin: 6px 0 0 6px; min-height: 44px; vertical-align: middle; }
.kart-note { display: block; margin-top: 6px; font-weight: 700; font-size: .9rem; color: var(--ink); }
.kart-unlock { font-weight: 800; margin: 6px 0; }
.kart-cab-more { font-weight: 700; margin: 4px 0; }
.kart-gar .card { max-width: 680px; text-align: left; }
.kart-gar h2, .kart-gar .card > p.muted { text-align: center; }
.kart-gar h3 { margin: 12px 0 6px; font-size: 1rem; }
.kart-gar-now { background: #fff8ec; border-radius: 14px; padding: 8px 12px; }
.kart-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; margin: 0; }
.kart-bars div { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.kart-bars dt { font-size: .78rem; font-weight: 700; }
.kart-bars dd { margin: 0; display: flex; gap: 2px; }
.kart-bars i { width: 10px; height: 10px; border-radius: 3px; background: #e9e1d4; }
.kart-bars i.on { background: #ff8a3d; }
.kart-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.kart-part { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; min-width: 0; min-height: 44px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font: inherit; color: var(--ink); cursor: pointer; text-align: center; }
.kart-part .ic { font-size: 1.6rem; line-height: 1.1; }
.kart-part b { font-size: .85rem; }
.kart-part small { font-size: .72rem; font-weight: 800; }
.kart-part .mini { font-size: .72rem; color: var(--ink-soft); }
.kart-part.on { border-color: #ff8a3d; box-shadow: 0 0 0 3px rgba(255, 138, 61, .3); }
.kart-part[disabled] { cursor: default; background: #f6f4fb; }
.kart-part[disabled] .ic { filter: grayscale(.8) opacity(.6); }
.kart-req { color: var(--ink-soft); font-weight: 600 !important; line-height: 1.2; }
@media (max-width: 640px) {
  .kart-bars { grid-template-columns: repeat(2, 1fr); }
}
.kart-results.kart-cup small, .kart-results small { color: #6b6f93; font-weight: 700; }
