/* Girgit Run: the play page. A full-bleed stage (the world) with its controls on it, bottom sheets for depth.
   Phone portrait first. Tokens only (site.css); quantity colours from explore.mjs (--gx-*). Weights 400 and 500. */
.run { padding-bottom: 24px; }

/* ---------- the stage ---------- */
.stage {
  --glass: color-mix(in srgb, var(--void) 72%, transparent);
  --glass-2: color-mix(in srgb, var(--void) 80%, transparent);
  --ink-soft: color-mix(in srgb, var(--bone) 82%, transparent);
  --gut: 12px;
  position: relative; isolation: isolate; overflow: hidden;
  margin: 0 calc(-1 * var(--margin));
  height: clamp(340px, 70svh, 820px);
  background: var(--raised);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
@media (min-width: 769px) { .stage { --gut: 16px; } }
@media (min-width: 960px) {
  .stage { margin: 16px 0 0; border-radius: 16px; height: clamp(480px, 70vh, 780px); }
}
.world { position: absolute; inset: 0; outline: none; touch-action: none; }
.world:focus-visible { box-shadow: inset 0 0 0 2px var(--bone); }
.world-cv { display: block; width: 100%; height: 100%; touch-action: none; }

/* every control on the stage */
.stage button { -webkit-tap-highlight-color: transparent; font: inherit; }
.stage .ic { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 999px; background: var(--glass); color: var(--bone); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.stage .ic svg { width: 20px; height: 20px; }
.stage .ic:active { transform: scale(.94); }
.stage .ic[aria-pressed="true"] { background: var(--bone); color: var(--void); }
.ic.small { width: 36px; height: 36px; }
.ic.small svg { width: 16px; height: 16px; }

/* ---------- top: mission pill, lenses, icons ---------- */
.hud-top { position: absolute; z-index: 4; left: var(--gut); right: var(--gut); top: var(--gut);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "pill icons" "lenses lenses"; gap: 8px; align-items: start; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.pill { grid-area: pill; justify-self: start; max-width: 100%; min-height: 44px; display: grid; grid-template-columns: minmax(0, 1fr) 16px; grid-template-areas: "k chev" "t chev" "p chev";
  column-gap: 8px; align-items: center; text-align: left; padding: 6px 12px 7px 14px; border: 0; border-radius: 16px; background: var(--glass); color: var(--bone); cursor: pointer;
  transition: background var(--t-fast); }
.pill:active { background: var(--glass-2); }
.pill-k { grid-area: k; font-size: 11px; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--mix-4); font-weight: 500; }
.pill-t { grid-area: t; font-size: var(--text-sm); line-height: 18px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-p { grid-area: p; font-size: 12px; line-height: 16px; color: var(--mix-2); font-variant-numeric: lining-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-p:empty { display: none; }
.pill-chev { grid-area: chev; width: 16px; height: 16px; color: var(--mix-4); }
.pill.done .pill-k::after { content: " · done"; color: var(--gx-5); }
.hud-icons { grid-area: icons; display: flex; gap: 8px; }

.lenses { grid-area: lenses; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; padding: 3px; border-radius: 14px; background: var(--glass); }
.lens { position: relative; min-width: 0; height: 42px; display: grid; justify-items: center; align-content: center; gap: 3px; padding: 0 2px; border: 0; border-radius: 11px;
  background: transparent; color: var(--mix-4); cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.lens svg { width: 17px; height: 17px; }
.lens span { font-size: 10px; line-height: 12px; font-weight: 500; letter-spacing: -0.005em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lens::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 0; height: 2px; border-radius: 2px; background: var(--c); transform: translateX(-50%); transition: width var(--t-base) var(--ease); }
.lens[aria-pressed="true"] { color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.lens[aria-pressed="true"]::after { width: 16px; }
.lens.lead { background: color-mix(in srgb, var(--c) 26%, transparent); }
@media (hover: hover) { .lens:hover { color: var(--bone); } .lens[aria-pressed="true"]:hover { color: var(--c); } }
@media (min-width: 900px) {
  .hud-top { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "pill lenses icons"; }
  .pill { max-width: 260px; }
  .lenses { justify-self: center; width: min(100%, 540px); }
  .lens { height: 48px; }
  .lens svg { width: 19px; height: 19px; }
  .lens span { font-size: 11.5px; line-height: 14px; }
}

/* ---------- bottom: thumb controls ---------- */
.pad { position: absolute; z-index: 4; left: var(--gut); right: var(--gut); bottom: var(--gut); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.pad-l, .pad-r { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.pad-r { flex-direction: column; align-items: flex-end; }
.ctl { display: grid; place-items: center; border: 0; color: var(--bone); background: var(--glass); cursor: pointer; touch-action: none;
  transition: background 90ms, color 90ms, transform 90ms var(--ease), opacity var(--t-fast); }
.ctl svg { width: 26px; height: 26px; pointer-events: none; }
.run-btn { width: 68px; height: 68px; border-radius: 22px; }
.jump-btn { width: 84px; height: 84px; border-radius: 999px; gap: 0; align-content: center; }
.jump-btn svg { width: 24px; height: 24px; margin-bottom: 1px; }
.jump-btn span { font-size: 13px; line-height: 14px; font-weight: 500; pointer-events: none; }
.act-btn { min-width: 128px; height: 64px; padding: 0 22px; border-radius: 999px; background: var(--bone); color: var(--void); font-size: var(--text-md); font-weight: 500; }
.ctl.on { background: var(--bone); color: var(--void); transform: scale(.93); }
.act-btn.on { background: var(--mix-3); }
.ctl[aria-disabled="true"] { opacity: .38; }
.ctl[aria-disabled="true"].on { background: var(--glass); color: var(--bone); transform: scale(.97); }
@media (min-width: 769px) { .run-btn { width: 72px; height: 72px; } .jump-btn { width: 88px; height: 88px; } }

/* ---------- the strips that sit over the bottom of the world ---------- */
.tune, .rewind { position: absolute; z-index: 5; left: var(--gut); right: var(--gut); border-radius: 14px; background: var(--glass-2); }
.tune { bottom: calc(var(--gut) + 96px); padding: 6px 12px; font-size: var(--text-sm); line-height: 34px; color: var(--mix-2); text-align: center; }
.tune.low { bottom: calc(var(--gut) + 74px); }
.tune .gx-num { min-height: 30px; }
.tune .gx-num .gx-step, .tune .gx-step { top: auto !important; bottom: calc(100% + 6px); }
.tune b { font-weight: 500; color: var(--bone); }
.rewind { bottom: calc(var(--gut) + 96px); display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 6px; align-items: center; padding: 4px 6px 4px 6px; }
.rewind .gx-scrub { margin: 0; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
.rewind .gx-scrub button { width: 40px; height: 40px; background: var(--raised-2); }
.rewind .gx-scrub output { min-width: 5.5ch; font-size: var(--text-xs); }
.stage.rewinding .tune { display: none; }
@media (min-width: 900px) { .tune, .rewind { left: 50%; right: auto; width: min(560px, calc(100% - 2 * var(--gut))); transform: translateX(-50%); } .tune { bottom: var(--gut); } .rewind { bottom: calc(var(--gut) + 2px); } .tune.low { bottom: var(--gut); } }

/* ---------- hints and toasts ---------- */
.hint, .toast { position: absolute; z-index: 9; margin: 0; pointer-events: none; font-size: var(--text-sm); line-height: 1.35; font-weight: 500; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28); }
.hint { max-width: min(260px, calc(100% - 2 * var(--gut))); padding: 8px 12px; background: var(--bone); color: var(--void); }
.hint::after { content: ""; position: absolute; left: var(--ax, 50%); bottom: -5px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.toast { left: 50%; top: var(--toast-top, 128px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 2 * var(--gut)); padding: 8px 14px; background: var(--glass-2); color: var(--bone); text-align: center; }
.hint:not([hidden]), .toast:not([hidden]) { animation: pop var(--t-base) var(--spring); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.toast:not([hidden]) { animation-name: pop-c; }
@keyframes pop-c { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------- cards over the world: start, guess, goal, result ---------- */
.veil { position: absolute; inset: 0; z-index: 3; background: color-mix(in srgb, var(--void) 58%, transparent); transition: opacity var(--t-base); }
.card { position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); width: min(420px, calc(100% - 2 * var(--gut))); border-radius: 16px; background: var(--void);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35); padding: 18px; display: grid; gap: 10px; }
.card:not([hidden]) { animation: rise var(--t-base) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } }
.card > * { margin: 0; }
.card-k { font-size: 11px; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--mix-4); font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.card-t { font-size: var(--text-xl); line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; }
.card-l { font-size: var(--text-sm); line-height: 1.45; color: var(--mix-2); }
.card-b { display: grid; gap: 8px; margin-top: 4px; }
.card-start { top: var(--card-top, 76px); text-align: left; cursor: pointer; }
.card-start .btn { cursor: pointer; }

.card-start .card-t { font-size: var(--text-2xl); }
.card-start .card-b { grid-template-columns: 1fr 1fr; }
.card-start .card-b .btn { padding: 0 12px; }
.card-guess { top: var(--card-top, 76px); max-height: calc(100% - var(--card-top, 76px) - var(--card-bot, 100px)); overflow: auto; overscroll-behavior: contain; padding: 14px; gap: 10px; }
.card-guess .q { font-size: 15px; line-height: 1.38; padding-right: 36px; }
.card-guess .q b { font-weight: 500; }
.card-guess .opts { display: grid; gap: 6px; margin: 0; }
.card-guess .opts.two { grid-template-columns: 1fr 1fr; }
.stage.guessing .lenses, .stage.starting .lenses { display: none; }
@media (max-width: 899px) { .stage.coaching .lenses { display: none; } }
.card-guess .opt { min-height: 44px; padding: 8px 12px; font-size: var(--text-sm); line-height: 1.3; }
.card-guess .g-skip { position: absolute; top: 8px; right: 8px; background: var(--raised-2); color: var(--mix-3); }
.card.nudge { animation: nudge 360ms var(--ease); }
@keyframes nudge { 20% { transform: translateX(calc(-50% - 6px)); } 45% { transform: translateX(calc(-50% + 5px)); } 70% { transform: translateX(calc(-50% - 3px)); } }
.card-coach { top: var(--card-top, 76px); gap: 6px; padding: 12px 14px; }
.card-coach .said { font-size: var(--text-xs); line-height: 1.3; color: var(--mix-4); }
.card-coach .said b { color: var(--bone); font-weight: 500; }
.card-coach .goal { font-size: var(--text-sm); line-height: 1.45; }
.coach-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -6px 0 0; }
.coach-h .ic { background: var(--raised-2); flex: none; }
.card-result { bottom: var(--gut); padding: 14px 16px 16px; gap: 8px; }
.card-result .v { font-size: var(--text-md); line-height: 1.35; font-weight: 500; }
.card-result .v .ok { color: var(--gx-5); }
.card-result .v .no { color: var(--gx-4); }
.card-result .why1 { font-size: var(--text-sm); line-height: 1.45; color: var(--mix-2); }
.card-result .lensnote { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; font-size: var(--text-xs); color: var(--mix-4); white-space: nowrap; }
.card-result .lensnote i { width: 8px; height: 8px; border-radius: 999px; background: var(--c); flex: none; }
.card-result .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.card-result .row .btn { flex: 1 1 auto; }
.card-result .row .btn svg { width: 16px; height: 16px; }
.card-result { gap: 6px; }
.stage.carded .pad, .stage.carded .tune { visibility: hidden; }
.stage.guessing .pad { opacity: .6; }

/* ---------- below the stage ---------- */
.run-head { padding: 20px 0 8px; max-width: var(--measure); }
.run-head .ch-kicker { margin-bottom: 6px; }
.run-title { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: 500; letter-spacing: -0.025em; margin: 0; }
.run-dek { margin: 6px 0 0; color: var(--mix-3); font-size: var(--text-md); line-height: var(--leading-md); }
@media (min-width: 960px) { .run-head { padding-top: 32px; } .run-title { font-size: var(--text-3xl); line-height: var(--leading-3xl); letter-spacing: -0.03em; } }
.about { max-width: var(--measure); margin-top: 16px; border-radius: 12px; background: var(--raised); }
.about summary { min-height: 52px; display: flex; align-items: center; padding: 0 16px; cursor: pointer; font-weight: 500; list-style: none; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 1.75px solid var(--mix-4); border-bottom: 1.75px solid var(--mix-4); transform: rotate(45deg) translate(-2px, -2px); transition: transform var(--t-fast); }
.about[open] summary::after { transform: rotate(-135deg); }
.about-b { padding: 0 16px 18px; display: grid; gap: 12px; font-size: var(--text-sm); line-height: 1.6; color: var(--mix-2); }
.about-b p { margin: 0; }
.about-b .label { margin-top: 6px; }
.about-b ul, .about-b ol { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.about-missions a { color: var(--bone); }

/* ---------- bottom sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--void) 40%, transparent); opacity: 0; transition: opacity var(--t-base) var(--ease); }
.scrim.on { opacity: 1; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(100%, 560px); max-height: min(78svh, 680px); display: flex; flex-direction: column;
  border-radius: 16px 16px 0 0; background: var(--raised); color: var(--bone); box-shadow: 0 -10px 40px rgba(0, 0, 0, .3);
  transform: translateY(105%); transition: transform var(--t-base) var(--ease); padding-bottom: env(safe-area-inset-bottom); }
.sheet.on { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-grab { flex: none; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grab i { width: 36px; height: 4px; border-radius: 999px; background: var(--mix-6); }
.sheet-h { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 6px 18px; touch-action: none; }
.sheet-h h2 { font-size: var(--text-lg); line-height: 1.3; font-weight: 500; letter-spacing: -0.015em; }
.sheet .ic { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 999px; background: var(--raised-2); color: var(--bone); cursor: pointer; }
.sheet .ic svg { width: 16px; height: 16px; }
.sheet-b { overflow: auto; overscroll-behavior: contain; padding: 4px 18px 22px; display: grid; gap: 12px; align-content: start; }
.sheet-b > * { margin: 0; }
.sheet-b .label { margin-top: 4px; }
.sheet-hint { font-size: var(--text-xs); color: var(--mix-4); }
.set-sentence { font-size: var(--text-md); line-height: 2.05; color: var(--mix-2); }
.set-sentence .gx-num[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.set-then { font-size: var(--text-sm); line-height: 1.7; color: var(--mix-3); padding: 10px 12px; border-radius: 8px; background: var(--raised-2); }
.chips .chip[aria-pressed="true"] { background: var(--bone); color: var(--void); }
@media (pointer: coarse) { .sheet .chip { height: 40px; } }

/* the mission sheet */
.mi-now { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--raised-2); }
.mi-now > * { margin: 0; }
.mi-now .card-k { color: var(--mix-4); }
.mi-now h3 { font-size: var(--text-lg); line-height: 1.3; font-weight: 500; letter-spacing: -0.015em; }
.mi-now .goal { font-size: var(--text-sm); line-height: 1.5; color: var(--mix-2); }
.mi-now .said { font-size: var(--text-sm); color: var(--mix-3); }
.mi-now .said b { color: var(--bone); font-weight: 500; }
.mi-now .status { font-size: var(--text-sm); line-height: 1.45; color: var(--bone); }
.mi-now .status:empty { display: none; }
.mi-now .mi-why { display: grid; gap: 8px; font-size: var(--text-sm); line-height: 1.6; color: var(--mix-2); }
.mi-now .mi-why p { margin: 0; }
.mi-now .mi-why b { color: var(--bone); font-weight: 500; }
.mi-now .row { display: flex; flex-wrap: wrap; gap: 8px; }
.mi-read { display: grid; gap: 2px; padding: 12px 14px; border-radius: 8px; background: var(--raised); text-decoration: none; color: var(--bone); }
.mi-read span { font-size: var(--text-xs); color: var(--mix-4); }
.mi-read b { font-weight: 500; font-size: var(--text-sm); }
.mi-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mi-list button { width: 100%; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 52px; padding: 8px 12px; border: 0; border-radius: 8px;
  background: var(--raised-2); color: var(--bone); font: inherit; text-align: left; cursor: pointer; }
.mi-list button:hover { background: var(--mix-7); }
.mi-list button[aria-current="true"] { box-shadow: inset 0 0 0 1.5px var(--bone); }
.mi-n { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; background: var(--raised); font-size: var(--text-xs); font-weight: 500; }
.mi-list .done .mi-n { background: var(--gx-5); color: var(--void); }
.mi-t { font-size: var(--text-sm); line-height: 1.3; font-weight: 500; }
.mi-s { font-size: var(--text-xs); color: var(--mix-4); white-space: nowrap; }
.mi-free { justify-self: start; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim, .lens::after, .ctl { transition: none; }
  .card:not([hidden]), .hint:not([hidden]), .toast:not([hidden]), .card.nudge { animation: none; }
}

/* anything hidden stays hidden, whatever display its class sets */
.stage [hidden], .sheet[hidden], .scrim[hidden] { display: none !important; }

/* the backdrop layers behind the world canvas (drawn once, moved by transforms) */
.sc { position: absolute; inset: 0; overflow: hidden; pointer-events: none; contain: strict; }
.sc-sky { position: absolute; left: 0; top: 0; }
.sc-l { position: absolute; left: 0; top: 0; will-change: transform; }
.sc canvas { display: block; max-width: none; }
.world-cv { position: relative; z-index: 2; }
