:root {
    color-scheme: dark;
    /* Keep automatic darkening from recoloring the light states where supported. */
    color-scheme: only dark;
    --navy: #1a365d;
    --muted: #bacade;
    --red: #ac4948;
    --panel: #15263df2;
    --line: #8dacc438;
    font-family: Inter, "Segoe UI", sans-serif;
    color: #e5edf8;
    background: #111f32;
    font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.6; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, a, summary { touch-action: manipulation; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible { outline: 3px solid #f2b66d; outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed; top: 12px; left: 12px; z-index: 20; padding: 12px; background: #15263d; color: white; }
main { position: relative; min-height: 100vh; min-height: max(100dvh, var(--game-min-height, 580px)); }
@media (min-width: 1000px) {
    main.has-help { --help-space: 352px; }
}
.exercise-panel { position: absolute; inset: 0; outline: none; }
.board { position: absolute; inset: 0; overflow: hidden; background-color: #111f32; background-image: radial-gradient(#8babc526 1px, transparent 1px), radial-gradient(ellipse at 50% 40%, #1d3450, transparent 75%); background-size: 24px 24px, 100% 100%; isolation: isolate; }
.game-hud { position: absolute; z-index: 4; inset: max(12px, env(safe-area-inset-top)) 20px auto; display: grid; justify-items: center; grid-template-columns: minmax(0, 1fr) var(--help-space, 0px); gap: 10px 0; pointer-events: none; }
.game-hud > * { pointer-events: auto; }
.game-topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
h1 { font-size: 20px; line-height: 1.2; font-weight: 650; margin: 0; text-align: center; }
.back-link, .overlay-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; color: #e5edf8; background: var(--panel); font-size: 14px; text-decoration: none; }
.overlay-button:hover, .back-link:hover { background: #284263; }
.exercise-tabs { grid-column: 1; display: flex; gap: 5px; padding: 4px; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.exercise-tab { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; background: transparent; color: var(--muted); font-size: 14px; white-space: nowrap; }
.exercise-tab[aria-selected="true"] { background: #e5edf8; color: #172b45; }
.exercise-tab:hover:not([aria-selected="true"]) { background: #284263; color: white; }
.tab-done { color: #8de6b8; font-size: 14px; }
.exercise-tab[aria-selected="true"] .tab-done { color: #216241; }
.first-steps { grid-column: 1; max-width: 560px; margin: 0; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: #d5e5fb; font-size: 14px; text-align: center; }
.connections, .nodes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.connections { z-index: 1; overflow: visible; }
.nodes { z-index: 2; top: var(--play-top, 180px); bottom: var(--play-bottom, 100px); right: var(--help-space, 0px); width: auto; height: auto; }
.tablet-node { position: absolute; transform: translate(-50%, -50%); width: 86px; text-align: center; pointer-events: none; color: #e3eaf2; }
.node-light { width: 86px; height: 86px; display: block; margin: 0 auto 9px; border: 2px solid #8293a8; border-radius: 50%; background: radial-gradient(ellipse at 40% 20%, #3b5067 0%, #202e40 45%, #101b2a 100%); box-shadow: 0 5px 12px #0006, inset 0 2px 3px #ffffff26, inset 0 -5px 9px #0006; pointer-events: auto; position: relative; touch-action: none; user-select: none; cursor: grab; }
/* Draw the lights entirely in CSS, without a native mobile button skin. */
.node-light { -webkit-appearance: none; appearance: none; }
.node-light::before { content: ''; position: absolute; top: 10%; left: 22%; width: 56%; height: 28%; border-radius: 50%; background: linear-gradient(#ffffff30, #ffffff00); pointer-events: none; }
.node-light::after { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.node-light.is-on { background: radial-gradient(circle at 48% 44%, #e0e7ef 0%, #cdd8e4 65%, #b7c7d8 100%); border-color: #d7e3ef; box-shadow: 0 4px 8px #00000038, 0 0 16px #d1dfed30, 0 0 32px #d1dfed50, inset 0 2px 3px #ffffff24, inset 0 -3px 5px #23375020; }
.node-light.is-on::before { opacity: 0; }
.node-light.is-intervention { background: radial-gradient(ellipse at 40% 20%, #793d40 0%, #4b1c26 50%, #2e101c 100%); border-color: #c77d80; box-shadow: 0 5px 12px #0006, inset 0 2px 3px #e2a1a530, inset 0 -5px 9px #0006; }
.node-light.is-intervention.is-on { background: radial-gradient(circle at 48% 44%, #f0b5a9 0%, #e18b7e 60%, #c55c54 100%); border-color: #efb3a8; box-shadow: 0 4px 8px #00000038, 0 0 16px #e88b7950, 0 0 34px #e0786880, inset 0 2px 3px #ffffff24, inset 0 -3px 5px #50232b20; }
.node-light.is-drop-target { outline: 3px solid #f2b66d; outline-offset: 7px; }
.node-light.is-drop-target::after { background: #f2b66d18; box-shadow: 0 0 22px #f2b66d70; }
.node-light { margin-bottom: 0; }
.node-light .intervention-symbol { display: none; position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); color: #fce9e3; pointer-events: none; }
.node-light.is-intervention .intervention-symbol { display: block; }
.node-light.is-intervention.is-on .intervention-symbol { color: #632d35; }
.board.is-dragging .node-light { cursor: grabbing; }
@media (hover: hover) {
    .node-light:hover:not(.is-drop-target) { filter: brightness(1.1); }
}
.edge-line { fill: none; stroke: #a8c8ff; stroke-width: 2; pointer-events: none; }
.edge-underlay { fill: none; stroke: #111f32; stroke-width: 6; pointer-events: none; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 24; pointer-events: stroke; cursor: pointer; }
.edge:hover .edge-line { stroke: #f2b66d; stroke-width: 3; }
.draft-edge { fill: none; stroke: #f2b66d; stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }
.tablet-actions { position: absolute; z-index: 4; bottom: max(16px, env(safe-area-inset-bottom)); left: calc((100% - var(--help-space, 0px)) / 2); transform: translateX(-50%); width: max-content; max-width: calc(100% - var(--help-space, 0px) - 32px); display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.reset-actions { display: flex; align-items: center; gap: 12px; }
.reset-button { min-height: 44px; border: 1px solid #607b9a; border-radius: 8px; background: linear-gradient(#2b425f, #233751); color: #e0e9f5; font-size: 13px; padding: 8px 12px; box-shadow: 0 2px 4px #0002, inset 0 1px 0 #ffffff0a; }
.reset-button:hover:not(:disabled) { background: linear-gradient(#385371, #2b425f); border-color: #88a2be; color: white; }
.reset-button:disabled { color: #a3b3c6; background: #1c2d43; border-color: #40546d; box-shadow: none; }
.reset-button > span { font-size: 16px; vertical-align: -1px; margin-right: 4px; }
.button-icon { display: inline-block; vertical-align: -3px; margin-right: 4px; }
.check-button, .next-button { min-height: 44px; padding: 11px 16px; color: #172b45; border: 1px solid #dce9fc; border-radius: 8px; background: linear-gradient(#e5eefb, #c9daef); box-shadow: 0 3px 6px #0003, inset 0 1px 0 #ffffff80; font-size: 14px; font-weight: 650; display: flex; gap: 20px; align-items: center; justify-content: space-between; white-space: nowrap; }
.check-button:hover { background: linear-gradient(#f3f7ff, #dce9fc); }
.next-button { margin-top: 16px; background: #216241; border-color: #216241; color: white; }
.next-button:hover { background: #194d33; }
.dialog-toolbar { position: sticky; top: 0; z-index: 1; display: flex; justify-content: flex-end; padding: 8px 12px; background: #172940; border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; gap: 12px; }
.dialog-close { display: inline-flex; gap: 16px; align-items: center; min-height: 44px; padding: 8px 12px; border: 1px solid #607b9a; border-radius: 8px; background: linear-gradient(#2b425f, #233751); color: #e0e9f5; font-size: 14px; box-shadow: 0 1px 3px #17345112; }
.dialog-close:hover { background: #385371; }
.back-link, .overlay-button { box-shadow: 0 2px 4px #0002, inset 0 1px 0 #ffffff08; }
.back-link:active, .overlay-button:active, .reset-button:active:not(:disabled), .check-button:active, .next-button:active, .dialog-close:active, .exercise-tab:active { transform: translateY(1px); box-shadow: inset 0 2px 4px #0002; }
h3 { color: #e5edf8; font-size: 18px; margin: 0; }
.guide-card, .feedback { padding: 20px; font-size: 14px; }
.guide-card > p { margin: 12px 0; }
.guide-card details { border-top: 1px solid var(--line); margin-top: 12px; }
.guide-card summary { display: list-item; padding: 11px 0; min-height: 44px; color: #d5e5fb; font-weight: 600; cursor: pointer; }
.guide-card details ul { padding-left: 18px; }
.guide-card details li { margin: 8px 0; }
.legend { display: grid; gap: 8px; margin: 14px 0; }
.legend > span { display: grid; grid-template-columns: 12px minmax(0, 1fr); align-items: start; gap: 8px; }
.legend-light { display: inline-block; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; border: 1px solid #8292a6; }
.legend-symbol { text-align: center; }
.natural-off { background: #172334; }
.intervention-on { background: var(--red); border-color: var(--red); }
.feedback strong { display: block; color: #f2c084; font-size: 20px; margin-bottom: 8px; }
.feedback.is-correct strong { color: #9de4bb; }
.feedback p { margin: 12px 0 0; }
.no-script { position: relative; z-index: 10; margin: 0; padding: 20px; background: #fff4e5; color: #25374e; }
@media (max-width: 600px) {
    .game-hud { left: 10px; right: 10px; gap: 8px; }
    .game-topbar { gap: 8px; }
    h1 { font-size: 16px; }
    .back-link, .overlay-button { font-size: 13px; padding: 8px 10px; gap: 5px; }
    .exercise-tabs { width: 100%; }
    .exercise-tab { flex: 1; min-width: 0; padding: 8px 4px; gap: 4px; font-size: 13px; }
    .first-steps { font-size: 13px; padding: 8px 12px; }
    .tablet-node { width: 64px; }
    .node-light { width: 64px; height: 64px; font-size: 20px; }
    .tablet-actions { width: calc(100% - 20px); max-width: none; padding: 8px 10px; gap: 4px; flex-direction: column-reverse; bottom: max(10px, env(safe-area-inset-bottom)); }
    .check-button { width: 100%; }
    .reset-actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; }
    .reset-button { font-size: 12px; padding: 8px 6px; }
    .next-button { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: no-preference) {
    .node-light { transition: background .15s, color .15s, border-color .15s, box-shadow .15s; }
}

.help-panel, .result-panel { position: absolute; z-index: 5; border: 1px solid #607b9a; border-radius: 12px; background: #15263df7; color: #dce7f5; box-shadow: 0 8px 28px #0004; overflow: auto; overscroll-behavior: contain; }
.help-panel { top: 76px; right: 16px; width: 320px; max-height: calc(100dvh - 92px); }
.panel-controls { display: flex; gap: 8px; }
#expand-help, .help-summary { display: none; }
.result-panel { left: calc((100% - var(--help-space, 0px)) / 2); transform: translateX(-50%); bottom: var(--actions-space, 100px); width: min(560px, calc(100% - var(--help-space, 0px) - 32px)); max-height: min(60dvh, 500px); }
.result-close { position: absolute; top: 8px; right: 8px; min-width: 44px; justify-content: center; }
.feedback { padding-top: 20px; }
.feedback strong { padding-right: 44px; }
@media (max-width: 999px) {
    .help-panel { top: auto; bottom: var(--actions-space, 100px); left: 10px; right: 10px; width: auto; max-height: min(65dvh, 560px); }
    #expand-help { display: inline-flex; }
    .help-summary { display: block; font-size: 13px; line-height: 1.5; margin: 0; padding: 8px 16px 12px; }
    .help-objective { margin: 0 0 10px; color: var(--muted); }
    .help-objective strong { color: #e5edf8; }
    .help-gestures { display: grid; gap: 6px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
    .help-gestures > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); column-gap: 12px; align-items: baseline; }
    .help-gestures dt { font-weight: 650; color: #e5edf8; }
    .help-gestures dd { margin: 0; color: var(--muted); }
    .help-panel.is-expanded .help-summary { display: none; }
    .help-panel .dialog-toolbar { padding: 6px 10px; }
    .help-panel .guide-card { padding: 16px; }
    .panel-controls { gap: 6px; }
    .panel-controls .dialog-close { padding: 8px; }
    .help-panel:not(.is-expanded) .dialog-toolbar { padding-block: 4px; }
    .help-panel:not(.is-expanded) .panel-controls .dialog-close { min-height: 24px; padding-block: 0; }
}
