/* Pixel Run. Built only from the site's own tokens, so both themes follow. */

.pr { display: grid; gap: var(--sp-3); margin: 0 0 var(--sp-7); }
.pr-head { margin-bottom: var(--sp-4); }

/* Two columns once there is room: the scene stays in view beside the editor. */
@media (min-width: 1020px) {
  .pr {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "hud console" "stage console";
    align-items: start; column-gap: var(--sp-4);
  }
  .pr-hud { grid-area: hud; }
  .pr-stagecol { grid-area: stage; position: sticky; top: 84px; }
  .pr-console { grid-area: console; }
}

/* ------------------------------------------------------------------ HUD */
.pr-hud { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; }
.pr-name { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); color: var(--ink); margin-inline-end: auto; }
.pr-chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .75rem;
  border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface);
  font-size: .84rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.pr-chip b { font-variant-numeric: tabular-nums; }
.pr-stars .icon { width: 1rem; height: 1rem; fill: #c28b00; stroke: #8a6100; }
.pr-coins i { width: .9rem; height: .9rem; border-radius: 50%; background: #ffcb3a; border: 2px solid #b8800d; display: inline-block; }
.pr-py[data-state="ready"] { color: var(--ok); border-color: var(--ok); }
.pr-py[data-state="loading"] { color: var(--warn); border-color: var(--warn); }
.pr-py[data-state="failed"] { color: var(--bad); border-color: var(--bad); }
.pr-pips { display: inline-flex; gap: .3rem; align-items: center; }
.pr-pips i {
  width: .95rem; height: .95rem; border-radius: 50%; border: 2px solid var(--border-strong);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-style: normal; font-weight: 800; line-height: 1;
}
.pr-pips i.on { background: var(--ok); border-color: var(--ok); }
.pr-pips i.on::after { content: "\2713"; color: var(--surface); }
.pr-pips i.bad { background: var(--bad); border-color: var(--bad); }
.pr-pips i.bad::after { content: "\00d7"; color: var(--surface); font-size: .85rem; }
.pr-pips i.now { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-quiet); }

/* ---------------------------------------------------------------- stage */
.pr-stage {
  line-height: 0; border-radius: var(--r-l); overflow: hidden; background: #8ed4f2;
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
}
.pr-stage canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.pr-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin: .7rem 0 0; font-size: .82rem; color: var(--ink-3); }
.pr-foot span { flex: 1 1 14rem; }

/* -------------------------------------------------------------- console */
.pr-console { container-type: inline-size; min-width: 0; outline: none; min-height: 14rem; }
.pr-boot { color: var(--ink-3); }
.pr-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.pr-card h3 { margin: 0 0 .4rem; font-size: var(--step-2); line-height: 1.2; }
.pr-card h4 { margin: .9rem 0 .35rem; font-size: .92rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.pr-card p { margin: 0 0 .75rem; }
.pr-card p:last-child { margin-bottom: 0; }
.pr-kicker { font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.pr-kicker.pr-good { color: var(--ok); }
.pr-kicker.pr-bad { color: var(--bad); }
.pr-concept { font-weight: 600; color: var(--accent); }
.pr-note { font-size: .88rem; color: var(--ink-3); }
.pr-revise a, .pr-key a, .pr-weak a { text-decoration: underline; text-underline-offset: 2px; }
.pr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; }
.pr-actions .pr-msg { flex-basis: 100%; margin: 0; }
.pr-check { display: flex; gap: .55rem; align-items: flex-start; margin-top: .9rem; font-size: .92rem; color: var(--ink-2); cursor: pointer; }
.pr-check input { margin-top: .25rem; accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.pr .tool-btn {
  font: inherit; font-size: .85rem; font-weight: 600; padding: .45rem 1rem;
  border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pr .tool-btn:hover { background: var(--accent-quiet); color: var(--accent); border-color: transparent; }
.pr .tool-btn:disabled { opacity: .5; cursor: not-allowed; }
.pr .tool-btn:disabled:hover { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); }
.pr .tool-btn[aria-pressed="true"] { background: var(--accent-quiet); color: var(--accent); border-color: var(--accent); }
.pr .btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.pr button:focus-visible, .pr a:focus-visible, .pr input:focus-visible, .pr textarea:focus-visible, .pr summary:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 2px;
}
.linklike { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ------------------------------------------------------------ challenge */
.pr-grid { display: grid; gap: var(--sp-3); margin-top: .5rem; }
@container (min-width: 760px) {
  .pr-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: var(--sp-4); }
}
.pr-story { font-style: italic; color: var(--ink-3); }
.pr-msg code, .pr-task code, .pr-story code, .pr-hint code, .pr-key code, .pr-examples code, .pr-tests code, .pr-q code, .pr-opt code {
  font-family: var(--font-mono); font-size: .86em; background: var(--surface-sunk); color: var(--ink);
  padding: .08em .35em; border-radius: 6px; overflow-wrap: anywhere;
}
.pr-examples { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.pr-examples li { font-size: .92rem; color: var(--ink-2); overflow-wrap: anywhere; }
.pr-hints { margin-top: .75rem; }
.pr-hint {
  padding: .6rem .8rem; border-radius: var(--r-s); background: var(--warn-bg); color: var(--ink);
  border: 1px solid var(--warn); font-size: .92rem; margin: 0 0 .5rem;
}

.pr-editor {
  display: block; width: 100%; min-height: 11rem; resize: vertical; tab-size: 4; white-space: pre; overflow: auto;
  font-family: var(--font-mono); font-size: .88rem; line-height: 1.65; color: var(--ink);
  background: var(--surface-sunk); border: 1px solid var(--border-strong); border-radius: var(--r-s);
  padding: .8rem .95rem;
}
.pr-editor[readonly] { opacity: .75; }
.pr-edtip { font-size: .8rem; color: var(--ink-3); margin: .4rem 0 0; }
.pr-attempts { display: flex; align-items: center; gap: .4rem; margin: .8rem 0 0; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.pr-dots { display: inline-flex; gap: .3rem; }
.pr-dots i { width: .8rem; height: .8rem; border-radius: 50%; border: 2px solid var(--border-strong); background: transparent; }
.pr-dots i.on { background: var(--accent); border-color: var(--accent); }

.pr-results { margin-top: .8rem; }
.pr-results:empty { display: none; }
.pr-results.is-bad, .pr-results.is-warn { padding: .8rem 1rem; border-radius: var(--r-s); border: 1px solid; }
.pr-results.is-bad { background: var(--bad-bg); border-color: var(--bad); color: var(--ink); }
.pr-results.is-warn { background: var(--warn-bg); border-color: var(--warn); color: var(--ink); }
.pr-msg { margin: 0 0 .5rem; }
.pr-sub { margin: 0; font-size: .86rem; color: var(--ink-3); }
.pr-tests { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .35rem; font-size: .88rem; }
.pr-tests li { overflow-wrap: anywhere; }
.pr-tick { display: inline-block; min-width: 2.6rem; font-weight: 800; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.is-pass .pr-tick { color: var(--ok); }
.is-fail .pr-tick { color: var(--bad); }
.pr-detail { display: block; margin: .15rem 0 0 2.9rem; color: var(--ink-2); }

/* ------------------------------------------------------------- quiz mode */
.pr-q { font-weight: 600; margin: .8rem 0 .5rem; }
.pr-opts { display: grid; gap: .5rem; }
.pr-opt {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; font: inherit; padding: .6rem .8rem;
  border-radius: var(--r-s); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.pr-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-quiet); }
.pr-opt:disabled { cursor: default; }
.pr-opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); text-decoration: line-through; }
.pr-optkey {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-quiet); color: var(--accent); font-weight: 800; font-size: .85rem;
}

/* --------------------------------------------------- other cards and text */
.pr-solution {
  margin: .6rem 0; padding: .8rem 1rem; background: var(--surface-sunk); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-s); overflow: auto; white-space: pre; tab-size: 4;
  font-family: var(--font-mono); font-size: .86rem; line-height: 1.65; box-shadow: none;
}
.pr-solution code { background: none; padding: 0; font-size: inherit; color: inherit; }
.pr-model { margin: .8rem 0 0; }
.pr-model summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.pr-stars-big { font-size: var(--step-1); font-weight: 700; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pr-starline { color: #8a6100; letter-spacing: .1em; font-size: 1.35em; }
.pr-weak { margin: .4rem 0 0; padding-left: 1.1rem; display: grid; gap: .35rem; }
.pr-status p { color: var(--ink-3); margin: 0; }

[data-theme="dark"] .pr-starline { color: #f0c55c; }
[data-theme="dark"] .pr-stars .icon { fill: #f0c55c; stroke: #f0c55c; }
[data-theme="dark"] .pr-coins i { border-color: #ffe08a; }
[data-theme="dark"] .pr-stage { background: #1c2250; }

@media (prefers-reduced-motion: reduce) {
  .pr * { transition: none !important; scroll-behavior: auto !important; }
}
@media print { .pr { display: none; } }

/* The corner mascot would sit on top of the editor and the Run button. Pixel is
   the star of this page already. */
.mascot-dock { display: none; }

/* A Tab key is not on every keyboard, so touch screens get a button for it. */
.pr-tabbtn { display: none; margin-top: .5rem; }
@media (pointer: coarse) { .pr-tabbtn { display: inline-block; } }


/* Generated by build.py: the dark rules above, repeated for readers
   whose system asks for dark before any script has run. An explicit
   data-theme="light" still overrides them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pr-starline {color: #f0c55c;}
  :root:not([data-theme="light"]) .pr-stars .icon {fill: #f0c55c; stroke: #f0c55c;}
  :root:not([data-theme="light"]) .pr-coins i {border-color: #ffe08a;}
  :root:not([data-theme="light"]) .pr-stage {background: #1c2250;}
}
