.loop-page {
  --lp-ink: #eafff3;
  --lp-muted: #a7c4b8;
  --lp-console: #0e2e25;
  --lp-board: #112a23;
  --lp-line: #cafa6e;
  --lp-alert: #ffb1af;
  --lp-border: #3c594d;
  --lp-focus: #ffd275;
  width: var(--v3-page, min(92%, 1400px));
  margin: 0 auto 52px;
}
.loop-page [hidden] { display: none !important; }
.loop-page button, .loop-page select, .loop-page input { font: inherit; }
.loop-page button { cursor: pointer; }
.loop-page button:disabled { opacity: .5; cursor: default; }
.loop-page :focus-visible { outline: 3px solid #ef9c26; outline-offset: 3px; }
.loop-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 22px; }
.loop-heading h1 { margin: 0; font-size: clamp(2.1rem, 6vw, 4.1rem); line-height: 1.12; letter-spacing: -.045em; }
.loop-heading p { margin: 8px 0 0; }
.loop-modes { display: flex; gap: 5px; padding: 4px; border: 1.5px solid currentColor; border-radius: 12px; }
.loop-modes button, .loop-panel button, .loop-panel select, .loop-panel input {
  min-height: 44px; padding: 5px 12px; border: 1px solid currentColor; border-radius: 8px;
  background: transparent; color: inherit; font-weight: 650;
}
.loop-modes button { border-color: transparent; white-space: nowrap; }
.loop-modes button[aria-pressed="true"], .loop-panel button.loop-primary {
  color: #112a23; background: var(--lp-line); border-color: #244334;
}
.loop-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(274px, 1fr); gap: 20px; align-items: start; }
.loop-console, .loop-panel { border: 1.5px solid currentColor; border-radius: 12px; box-shadow: 4px 4px 0 currentColor; }
.loop-console { color: var(--lp-ink); background: var(--lp-console); border-color: #0a2119; box-shadow: 4px 4px 0 #060f0b; padding: clamp(13px, 2.4vw, 27px); }
.loop-console-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.loop-console-head p { color: var(--lp-muted); margin: 0; font-size: .82rem; }
.loop-console-head h2 { font-size: clamp(1.28rem, 4.5vw, 2rem); line-height: 1.2; margin: 2px 0 0; }
#clock, #room-code { font-family: SpaceGrotesk, ui-monospace, monospace; font-variant-numeric: tabular-nums; }
#clock { color: var(--lp-line); font-size: clamp(1.5rem, 5vw, 2.5rem); line-height: 1; }
.loop-stage { position: relative; width: min(100%, 510px, max(360px, calc(100svh - 290px))); margin: 13px auto; background: var(--lp-board); border: 1px solid var(--lp-border); border-radius: 10px; overflow: clip; }
#board { display: block; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; cursor: crosshair; }
#board .cell { fill: #e9f3eb; font: 650 27px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
#board .cell.matched { fill: #9eeec0; }
#board .cell.conflict { fill: var(--lp-alert); font-weight: 900; }
#board .dot { fill: #98ae9e; }
#board .dot.branch { fill: var(--lp-alert); r: 5; }
#board .trace { stroke: #5c7567; stroke-width: 1; opacity: .6; stroke-dasharray: 2 4; }
#board .selected .trace { stroke: var(--lp-line); stroke-width: 5; stroke-dasharray: none; opacity: 1; }
#board .exclusion { fill: none; stroke: #a2c0af; stroke-width: 2; opacity: 0; }
#board .excluded .exclusion { opacity: 1; }
#board .edge:focus-visible { outline: none; }
#board .edge:focus-visible .trace, #board .edge.hinted .trace { stroke: var(--lp-focus); stroke-width: 4; stroke-dasharray: none; opacity: 1; }
.loop-overlay { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 10px; background: #102720f4; padding: 18px; text-align: center; }
.loop-overlay strong { font-size: clamp(1.6rem, 7vw, 3rem); line-height: 1.12; color: var(--lp-line); white-space: pre-line; }
.loop-overlay span { color: var(--lp-muted); }
.loop-overlay button { color: #173327; background: var(--lp-line); border-color: var(--lp-line); }
.loop-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px; }
.loop-tool-toggle, .loop-utilities { display: flex; flex-wrap: wrap; gap: 5px; }
.loop-console button { color: var(--lp-ink); background: #1a3d31; border: 1px solid var(--lp-border); border-radius: 7px; min-height: 42px; padding: 5px 10px; }
.loop-console button[aria-pressed="true"], .loop-console .loop-overlay button { color: #112a23; background: var(--lp-line); }
.loop-key {
  display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; margin-inline-start: 2px;
  border: 1px solid currentColor; border-radius: 4px; font: 700 .72rem/1 SpaceGrotesk, ui-monospace, monospace;
}
@media (hover: none) { .loop-key { display: none; } }
.loop-message { color: var(--lp-muted); margin: 8px 0 0; min-height: 1.5em; font-size: .87rem; }
.loop-score { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 10px; color: var(--lp-muted); }
.loop-score span:nth-child(2) { text-align: right; }
.loop-score b { color: var(--lp-ink); }
.loop-score progress { width: 100%; height: 7px; accent-color: var(--lp-line); }
#other-progress { accent-color: #ffb974; }
.loop-sidebar { display: grid; gap: 14px; }
.loop-panel { padding: 15px; background: var(--se-surface, var(--se-card, transparent)); }
.loop-panel h2, .loop-rules summary { margin: 0; font-size: 1.05rem; font-weight: 800; }
.loop-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; }
.loop-panel-head span { font-size: .8rem; }
.loop-chapter { margin-top: 11px; }
.loop-chapter h3 { font-size: .84rem; margin: 0 0 4px; }
.loop-levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.loop-levels button { padding: 3px 0; min-width: 0; font-size: .82rem; font-variant-numeric: tabular-nums; }
.loop-levels button[aria-current="true"] { background: var(--lp-line); color: #112a23; }
.loop-levels button[data-complete] { text-decoration: underline; text-underline-offset: 4px; }
.loop-rules summary { cursor: pointer; }
.loop-rules ul { margin: 7px 0 0; padding-left: 20px; font-size: .9rem; }
.loop-rules li + li { margin-top: 5px; }
#lobby-entry, #lobby-room { display: grid; gap: 7px; margin-top: 12px; }
#lobby-entry label { display: block; font-size: .86rem; font-weight: 700; }
#lobby-entry select { background-color: var(--se-surface, Canvas); }
#join { border-top: 1px solid; padding-top: 12px; margin-top: 6px; }
.loop-join { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
#room-code { display: block; font-size: clamp(1.75rem, 7vw, 2.8rem); line-height: 1; letter-spacing: .13em; }
#room-message { margin: 8px 0 0; font-size: .87rem; }
/* Keep labels on the dark game console readable in both site themes. */
body.lab-shell.se-site .loop-page .loop-console-head h2 { color: var(--lp-ink) !important; }
body.lab-shell.se-site .loop-page :is(.loop-console-head p, #board-message) { color: var(--lp-muted) !important; }
body.lab-shell.se-site .loop-page .loop-heading h1 { margin-bottom: 0; }
@media (max-width: 730px) {
  .loop-heading { align-items: start; flex-direction: column; margin-bottom: 14px; }
  .loop-layout { grid-template-columns: 1fr; gap: 16px; }
  .loop-layout[data-entry="true"] .loop-sidebar { grid-row: 1; }
  .loop-layout[data-entry="true"] .loop-console { display: none; }
}
