.game-shell.theme-code {
  --code-ink:#2b194d;
  --code-muted:#594770;
  --code-line:#ccbae3;
  --code-violet:#7025c5;
  --code-paper:linear-gradient(148deg,#fffbf7,#f3e8fc 50%,#ead9fc);
}
.page-game .game-shell.theme-code.wide {
  background:radial-gradient(ellipse at 76% 30%,#e9d8fb,transparent 65%),#faf6fe;
}
.game-shell.theme-code.wide .game-toolbar {
  color:var(--code-ink); background:#fbf6ff; border-color:var(--code-line);
}
.page-game .game-shell.theme-code.wide .play {
  width:100%; max-width:none; padding:clamp(.75rem,3vw,2.8rem); justify-content:center;
}
.code-machine {
  width:100%; max-width:78rem; margin:0 auto;
  grid-template-columns:minmax(0,1.95fr) minmax(12rem,1fr);
  gap:clamp(.8rem,2.3vw,2rem); align-items:start;
}
.page-game .game-shell.theme-code.wide .code-machine { max-width:100rem; margin:0 auto }
.page-game .game-shell.theme-code .play .code-panel {
  position:relative; isolation:isolate; overflow:hidden; min-height:0;
  display:block; width:100%; max-width:none; padding:clamp(1rem,2.6vw,2.2rem);
  border:1px solid var(--code-line); border-radius:clamp(1.1rem,2.8vw,1.9rem);
  background:radial-gradient(ellipse at 87% 106%,#e2caf9,transparent 58%),var(--code-paper);
  box-shadow:inset 0 0 0 2px #fff9,inset 0 0 15px #fff,0 3px 0 #d2bfe7,0 20px 35px -20px #64468472;
}
.code-panel::before {
  content:""; position:absolute; z-index:-1; pointer-events:none;
  top:-8rem; left:-8%; width:74%; height:11.6rem;
  border-radius:0 0 62% 48%; border-bottom:1px solid #e6c88c8a;
  background:linear-gradient(150deg,#fff8 57%,#fff0 84%),linear-gradient(5deg,#fff9,transparent 40%);
  transform:rotate(-9deg); box-shadow:0 6px 24px #ba86ec36;
}
.code-panel .code-faceplate { flex-wrap:wrap; color:var(--code-ink); padding:0; gap:.55rem .9rem }
.page-game .game-shell.theme-code .code-faceplate .session-banner { width:auto; margin:0; padding:0 }
.page-game .game-shell.theme-code .code-panel .code-faceplate h2 {
  font-size:clamp(1.65rem,3.15vw,3.1rem); line-height:1.06; color:var(--code-ink);
  letter-spacing:-.04em; text-align:start; margin:0;
}
.code-progress { display:flex; flex-wrap:wrap; align-items:center; gap:.55rem; font-size:.88rem }
.code-progress strong { border-radius:2rem; background:#e6d4f8; padding:.28em .68em; white-space:nowrap }
.page-game .game-shell.theme-code .code-progress p {
  margin:0; padding-inline-start:.55rem; border-inline-start:1px solid #bfa9d6; font-weight:700;
}
.page-game .game-shell.theme-code .code-panel :is(.code-instruction,.code-rules,.code-notice) {
  max-width:none; margin:.68rem 0; color:var(--code-muted); text-align:start; line-height:1.45;
}
.page-game .game-shell.theme-code .code-panel .code-rules { font-size:.83em }
.code-notice:empty { display:none }
.page-game .game-shell.theme-code .code-panel .code-notice { font-weight:750 }
.code-panel :is(.code-slots,.code-solution) {
  display:grid; grid-template-columns:repeat(var(--code-slots,3),minmax(0,1fr)); align-items:center;
  gap:clamp(.38rem,1.05vw,.85rem); padding:0; border:0;
}
.code-panel .code-solution { justify-items:center; padding:1rem .4rem; border-radius:1rem; background:#eadcf7; margin-bottom:1rem }
.game-shell.theme-code .code-panel .code-slots button {
  display:grid; place-items:center; min-width:0; min-height:clamp(3.5rem,8vw,6rem); padding:.25rem;
  border:1px solid #b6a0d1; border-radius:clamp(.65rem,1.5vw,1.15rem);
  background:radial-gradient(ellipse at 74% 110%,#ffeccc9c,transparent 44%),
    linear-gradient(136deg,transparent 28%,#fff7 36%,#fff0 43%),
    linear-gradient(168deg,#b7a3ce,#dfcbf3 55%,#eae1f9);
  box-shadow:inset 0 0 0 2px #fff9,inset 0 0 0 3px #e3c78c80,inset 0 4px 10px #532c7436,0 4px 7px #5b38772b;
}
.game-shell.theme-code .code-panel .code-slots button[aria-pressed=true] {
  outline:none; border-color:#a04cdf;
  box-shadow:inset 0 0 0 2px #fffb,inset 0 0 16px #bd72f87a,0 0 0 2px #dc9ff9,0 4px 13px #9c49d974;
}
.game-shell.theme-code .code-panel button:focus-visible { outline:2px solid #5d229c; outline-offset:3px }
.theme-code .code-dot.empty { background:none; box-shadow:none }
.theme-code .code-dot:not(.empty) {
  background:radial-gradient(ellipse at 31% 21%,#fff 0 5%,#fff9 9%,transparent 18%),
    radial-gradient(ellipse at 70% 81%,color-mix(in srgb,var(--chip),white 52%) 0%,transparent 31%),
    radial-gradient(circle at 40% 37%,var(--chip) 18%,color-mix(in srgb,var(--chip),#14052c 50%) 60%,var(--chip) 83%);
  box-shadow:inset 0 0 0 1px #27103955,inset 0 1px 3px #fff9,0 4px 9px -2px color-mix(in srgb,var(--chip),transparent 30%);
}
.game-shell.theme-code .code-panel :is(.code-slots,.code-solution) .code-dot {
  width:min(85%,clamp(2rem,6vw,4.35rem)); height:auto; aspect-ratio:1;
}
.game-shell.theme-code .code-panel .code-palette {
  grid-template-columns:repeat(var(--code-colors,4),minmax(0,1fr)); margin:.95rem 0 .85rem;
  padding:0; gap:clamp(.35rem,.8vw,.65rem);
}
.game-shell.theme-code .code-panel .code-palette button {
  display:grid; justify-items:center; align-content:center; gap:.36rem;
  min-height:clamp(3.5rem,6vw,4.4rem); min-width:0; padding:.42rem .18rem;
  color:var(--code-ink); font-weight:750; line-height:1.15; overflow-wrap:anywhere;
  border:1px solid #d6c4e9; border-radius:clamp(.65rem,1.3vw,1rem);
  background:linear-gradient(160deg,#fbf5ff,#e9daf8);
  box-shadow:inset 0 1px 0 #fff,0 2px 3px #4b266519;
}
.game-shell.theme-code .code-panel .code-palette button:hover { border-color:#a46dcc; background:#fbf5ff }
.code-latest {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr));
  margin:0; padding:.62rem .25rem; border-radius:.8rem;
  color:var(--code-ink); background:linear-gradient(100deg,#eadff6,#e4d2f8);
}
.code-latest > div { display:flex; justify-content:space-between; align-items:center; gap:.35rem; padding-inline:clamp(.48rem,1.5vw,1rem) }
.code-latest > div + div { border-inline-start:1px solid #bfa9d6 }
.code-latest dt { font-weight:700; line-height:1.2 }
.code-latest dd { margin:0; font-size:1.32em; font-weight:850; font-variant-numeric:tabular-nums }
.game-shell.theme-code .code-panel .actions { justify-content:flex-start; gap:.45rem; flex-wrap:wrap; margin:.85rem 0 0 }
.game-shell.theme-code .code-panel .actions .button { min-height:44px; border-radius:.74rem; line-height:1.25 }
.game-shell.theme-code .code-panel .actions :is([data-action="check"],[data-action="next-level"]) {
  color:white; border-color:#6420b0; background:linear-gradient(170deg,#8732e0,#6120b3);
  box-shadow:inset 0 1px 1px #fff6,0 3px 8px #711bcc49;
}
.game-shell.theme-code .code-panel .actions .code-check {
  opacity:1; color:#513670; border-color:#c8a7e8; background:linear-gradient(170deg,#e7d2fa,#d4b4f1);
}
.game-shell.theme-code .code-panel .actions .secondary {
  color:var(--code-ink); background:#fbf3ff; border-color:#bea4de;
}
.game-shell.theme-code .code-panel .actions .secondary:hover { background:#fff; border-color:#a46dcc }
.game-shell.theme-code .code-machine .code-history {
  margin:0; padding:clamp(.8rem,2vw,1.35rem); min-width:0; width:100%; max-width:none;
  max-height:36rem; border:1px solid #ddd0ed; border-radius:1.15rem;
  background:#f8f0ff; color:var(--code-ink);
}
.code-history summary { color:var(--code-ink); padding-bottom:.38rem; font-size:1.08em }
.code-history ol { counter-reset:code-row; list-style:none; padding:0; margin:.4rem 0 0 }
.code-history li { display:grid; gap:.38rem; padding:.6rem 0; border-color:#e5d6f0; counter-increment:code-row }
.code-history li::before { content:'#' counter(code-row); font-size:.78em; color:var(--code-muted) }
.code-history li > div:first-child { display:flex; flex-wrap:wrap; gap:.38rem }
.code-history .code-verdict { display:flex; flex-wrap:wrap; align-items:center; gap:.25rem .65rem }
.code-history .code-verdict strong { margin:0; font-size:.86em }
.code-history li > .button { justify-self:start; min-height:44px; padding:.35rem .65rem; font-size:.85em }
.code-history :is(.code-waiting,.code-feedback-help) { margin:.25rem 0; color:var(--code-muted); font-size:.86em }
.code-history .code-feedback { display:inline-flex; gap:.22rem; align-items:center }

.game-shell.theme-code .code-levels label > span { background:var(--code-paper); color:var(--code-ink); border-color:var(--code-line); border-radius:.8rem }
.game-shell.theme-code .code-levels label:has(input:checked) > span { border-color:#9f66cf; box-shadow:0 0 0 2px #d0a6f3 }
.game-shell.theme-code .code-levels strong { background:#e6d4f8; color:var(--code-ink) }

@media (min-width:850px) {
  .game-shell.theme-code.wide .code-machine { grid-template-columns:minmax(0,2fr) minmax(14rem,1fr) }
  .game-shell.theme-code.wide .code-machine .code-history { max-height:min(70dvh,44rem) }
  .game-shell.theme-code.wide .code-panel .code-slots button { min-height:clamp(4.4rem,14dvh,9.4rem) }
  .game-shell.theme-code.wide .code-panel :is(.code-slots,.code-solution) .code-dot { width:min(85%,clamp(3rem,9dvh,6rem)) }
  .game-shell.theme-code.wide .code-panel .code-palette button { min-height:clamp(4.1rem,9dvh,6rem) }
  .game-shell.theme-code.wide .code-panel .code-palette .code-dot { width:clamp(2rem,4.4dvh,3.15rem); height:auto; aspect-ratio:1 }
}
@media (max-width:849px) {
  .page-game .game-shell.theme-code .code-machine { grid-template-columns:minmax(0,1fr) }
  .game-shell.theme-code .code-machine .code-history { max-height:none; overflow:visible }
  .game-shell.theme-code .code-panel .code-palette { grid-template-columns:repeat(4,minmax(0,1fr)) }
}
@media (max-height:500px) and (orientation:landscape) and (min-width:580px) {
  .page-game .game-shell.theme-code.wide .play { padding:.65rem 1rem; justify-content:flex-start }
  .page-game .game-shell.theme-code.wide .code-machine { grid-template-columns:minmax(0,1.85fr) minmax(9rem,1fr) }
  .page-game .game-shell.theme-code.wide .play .code-panel { padding:.8rem }
  .game-shell.theme-code.wide .code-panel .code-palette { grid-template-columns:repeat(var(--code-colors,4),minmax(0,1fr)) }
  .game-shell.theme-code.wide .code-machine .code-history { max-height:72dvh; overflow:auto }
}
@media (prefers-reduced-motion:no-preference) {
  .code-panel button { transition:transform .16s,border-color .16s,box-shadow .16s }
  .code-panel :is(.code-palette,.actions) button:hover:not(:disabled) { transform:translateY(-2px) }
  .code-panel button:active:not(:disabled) { transform:translateY(1px) }
}
