:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #5e5e5e;
  --line: #252525;
  --red: #ff3b30;
  --yellow: #ffd60a;
  --green: #34c759;
  --gray: #b9bcc2;
  --blue: #1677ff;
  --orange: #ff9500;
  --purple: #af52de;
  --white: #ffffff;
  --input-bg: #f2f3f5;
  --shadow: rgba(17, 17, 17, 0.18);
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-size: 16px;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --page: #101318;
  --surface: #171b22;
  --ink: #f4f6fb;
  --muted: #b8bec9;
  --line: #f4f6fb;
  --blue: #409cff;
  --input-bg: #252a34;
  --shadow: rgba(0, 0, 0, 0.5);
}

:root[data-theme="night"] .theme-toggle,
:root[data-theme="night"] .toolbar-button {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(244, 246, 251, 0.16);
}

:root[data-theme="night"] .select-reset-button {
  background: var(--red);
  color: var(--white);
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; background: var(--page); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.game-shell { position: relative; width: min(1120px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; padding: 54px 0 44px; }
.theme-toggle { position: absolute; top: 16px; right: 0; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: var(--page); font-size: 1.2rem; line-height: 1; }
.theme-toggle:hover { transform: scale(1.08); }
.home-screen { position: relative; display: flex; min-height: calc(100vh - 100px); flex-direction: column; align-items: center; }
.home-screen h1 { margin: 0 0 74px; color: var(--ink); font-size: clamp(2rem, 5vw, 4.25rem); font-weight: 700; letter-spacing: -0.07em; text-align: center; }
.mode-screen { display: flex; min-height: calc(100vh - 100px); flex-direction: column; align-items: center; }
.mode-screen h1 { margin: 0 0 74px; color: var(--ink); font-size: clamp(2rem, 5vw, 4.25rem); font-weight: 700; letter-spacing: -0.07em; text-align: center; }
.mode-circles { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 34px; width: 100%; }
.mode-circle { display: grid; place-items: center; width: 190px; height: 190px; padding: 22px; border: 0; border-radius: 50%; color: var(--white); font-size: 1.25rem; font-weight: 700; line-height: 1.15; text-align: center; transition: transform 220ms ease; }
.mode-circle:not(:disabled):hover { transform: scale(1.12); }
.mode-circle:disabled { cursor: not-allowed; }
.mode-lmp { background: var(--blue); }
.mode-congestion { background: var(--purple); }
.mode-day-ahead { background: var(--orange); }
.mode-circle:disabled { opacity: 0.5; }
.day-ahead-screen { padding-bottom: 40px; }
.day-ahead-instruction { margin: 16px 0 7px; color: var(--muted); font-size: 0.9rem; text-align: center; }
.day-ahead-level-description { max-width: 760px; margin: 0 auto 14px; color: var(--ink); font-size: 0.86rem; line-height: 1.4; text-align: center; }
.day-ahead-summary { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; margin: 15px 0; color: var(--muted); font-size: 0.75rem; }
.day-ahead-requirement-box { display: grid; gap: 4px; min-height: 48px; padding: 9px 11px; background: var(--surface); box-shadow: 0 3px 12px var(--shadow); text-align: left; }
.day-ahead-requirement-box span { color: var(--muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.day-ahead-requirement-box strong { color: var(--ink); font-size: 0.84rem; }
.day-ahead-forecast { display: grid; gap: 8px; max-width: 760px; min-width: 0; margin: 0 auto 15px; padding: 11px 13px; overflow: hidden; background: var(--surface); box-shadow: 0 3px 12px var(--shadow); color: var(--ink); }
.day-ahead-forecast-title { font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; }
.day-ahead-forecast-note { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.day-ahead-forecast-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.day-ahead-forecast-columns > div { display: grid; gap: 5px; min-width: 0; align-content: start; font-size: 0.78rem; }
.day-ahead-forecast-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 5px 8px; min-width: 0; align-items: center; font-size: 0.72rem; }
.day-ahead-forecast-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.day-ahead-forecast-row > span:nth-child(2) { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; min-width: 0; color: var(--muted); }
.day-ahead-forecast-row > span:nth-child(2) span { white-space: nowrap; }
.day-ahead-forecast-row > span:nth-child(2) strong { color: var(--accent); }
.day-ahead-forecast-expected { padding-top: 5px; color: var(--ink); font-size: 0.76rem; font-weight: 800; }
.day-ahead-forecast-label { grid-column: 1 / -1; color: var(--muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.day-ahead-forecast-columns strong { color: var(--accent); }
@media (max-width: 760px) { .day-ahead-summary { grid-template-columns: repeat(2, minmax(130px, 1fr)); } }
.day-ahead-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.day-ahead-panel { min-width: 0; overflow: hidden; padding: 16px; background: var(--surface); box-shadow: 0 8px 24px var(--shadow); }
.day-ahead-panel h3 { margin: 0 0 6px; font-size: 1.05rem; }
.day-ahead-panel-note { margin: 0 0 12px; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.day-ahead-offers { display: grid; gap: 10px; }
.day-ahead-offer { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(0, 1.15fr); gap: 12px; min-width: 0; overflow: hidden; align-items: center; padding: 12px; background: var(--input-bg); }
.day-ahead-offer-info { display: grid; gap: 3px; min-width: 0; overflow: hidden; }
.day-ahead-offer-info strong { font-size: 0.86rem; }
.day-ahead-offer-info span { color: var(--muted); font-size: 0.74rem; }
.day-ahead-offer-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 4px; }
.day-ahead-offer-metrics span { display: grid; gap: 2px; min-width: 0; padding: 5px 6px; background: var(--surface); }
.day-ahead-offer-metrics small { color: var(--muted); font-size: 0.61rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.day-ahead-offer-metrics b { overflow: hidden; color: var(--ink); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.day-ahead-curve { display: block; width: 100%; max-width: 270px; height: 108px; margin-top: 5px; overflow: visible; }
.day-ahead-curve-axis { stroke: var(--muted); stroke-width: 1; }
.day-ahead-curve-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.day-ahead-curve-point-label { fill: var(--ink); font-size: 8.5px; font-weight: 700; pointer-events: none; paint-order: stroke; stroke: var(--input-bg); stroke-width: 2px; stroke-linejoin: round; }
.day-ahead-curve-axis-label { fill: var(--muted); font-size: 8.5px; font-weight: 700; pointer-events: none; }
.day-ahead-curve-trace-line { stroke: var(--accent, var(--orange)); stroke-width: 1.25; stroke-dasharray: 3 3; pointer-events: none; }
.day-ahead-curve-trace-point { fill: var(--accent, var(--orange)); stroke: var(--input-bg); stroke-width: 1.5; pointer-events: none; }
.day-ahead-curve-trace-label { fill: var(--ink); font-size: 9px; font-weight: 800; pointer-events: none; paint-order: stroke; stroke: var(--input-bg); stroke-width: 3px; stroke-linejoin: round; }
.day-ahead-curve-readout { min-height: 1.1em; color: var(--ink); font-size: 0.7rem; font-weight: 800; }
.day-ahead-curve-line.wind { stroke: var(--blue); }
.day-ahead-curve-line.solar { stroke: #d39e00; }
.day-ahead-curve-line.gas { stroke: var(--purple); }
.day-ahead-curve-line.hydro { stroke: #168de2; }
.day-ahead-curve-line.battery { stroke: #0f9dcc; }
.day-ahead-curve-line.cycle { stroke: #5856d6; }
.day-ahead-curve-line.peaker { stroke: var(--red); }
.day-ahead-offer-control { display: grid; gap: 3px; }
.day-ahead-offer-control input { width: 100%; accent-color: var(--orange); }
.day-ahead-toggle { min-width: 62px; padding: 7px 10px; border: 0; background: var(--red); color: var(--white); font-size: 0.74rem; font-weight: 800; cursor: pointer; }
.day-ahead-toggle.is-on { background: var(--green); }
.day-ahead-offer-readout { color: var(--ink); font-size: 0.75rem; font-weight: 700; text-align: right; }
.day-ahead-stack { display: grid; gap: 8px; min-height: 176px; align-content: center; padding: 10px 0; }
.day-ahead-combined-curve { display: grid; gap: 5px; padding: 9px; background: var(--input-bg); }
.day-ahead-combined-curve > strong { color: var(--ink); font-size: 0.76rem; }
.day-ahead-combined-curve svg { width: 100%; height: 155px; }
.day-ahead-combined-curve-axis { stroke: var(--muted); stroke-width: 1; }
.day-ahead-combined-curve svg text { fill: var(--muted); font-size: 9px; }
.day-ahead-combined-curve-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.day-ahead-combined-curve-line.wind, .day-ahead-combined-curve-swatch.wind { stroke: var(--blue); background: var(--blue); }
.day-ahead-combined-curve-line.solar, .day-ahead-combined-curve-swatch.solar { stroke: #d39e00; background: #d39e00; }
.day-ahead-combined-curve-line.gas, .day-ahead-combined-curve-swatch.gas { stroke: var(--purple); background: var(--purple); }
.day-ahead-combined-curve-line.hydro, .day-ahead-combined-curve-swatch.hydro { stroke: #168de2; background: #168de2; }
.day-ahead-combined-curve-line.battery, .day-ahead-combined-curve-swatch.battery { stroke: #0f9dcc; background: #0f9dcc; }
.day-ahead-combined-curve-line.cycle, .day-ahead-combined-curve-swatch.cycle { stroke: #5856d6; background: #5856d6; }
.day-ahead-combined-curve-line.peaker, .day-ahead-combined-curve-swatch.peaker { stroke: var(--red); background: var(--red); }
.day-ahead-combined-curve-legend { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--muted); font-size: 0.65rem; }
.day-ahead-combined-curve-legend span { display: inline-flex; align-items: center; gap: 4px; }
.day-ahead-combined-curve-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.day-ahead-stack-row { display: grid; grid-template-columns: 86px minmax(0, 1fr) 65px; gap: 8px; align-items: center; font-size: 0.72rem; }
.day-ahead-stack-label { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.day-ahead-stack-track { display: flex; height: 28px; overflow: hidden; background: var(--input-bg); }
.day-ahead-stack-segment { display: grid; place-items: center; min-width: 2px; color: var(--white); font-size: 0.68rem; font-weight: 700; transition: width 180ms ease; }
.day-ahead-stack-segment.wind { background: var(--blue); }
.day-ahead-stack-segment.solar { background: #ffcc00; color: #111111; }
.day-ahead-stack-segment.gas { background: var(--purple); }
.day-ahead-stack-segment.hydro { background: #35a7ff; }
.day-ahead-stack-segment.battery { background: #5ac8fa; color: #111111; }
.day-ahead-stack-segment.cycle { background: #5856d6; }
.day-ahead-stack-segment.peaker { background: var(--red); }
.day-ahead-stack-value { color: var(--ink); font-weight: 700; text-align: right; }
.day-ahead-stack-axis { display: flex; justify-content: space-between; margin: 3px 0 15px 94px; color: var(--muted); font-size: 0.68rem; }
.day-ahead-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.day-ahead-actions .check-button, .day-ahead-actions .reveal-button { padding: 10px 14px; font-size: 0.78rem; }
.day-ahead-result { display: grid; gap: 5px; min-width: 0; min-height: 116px; margin-top: 14px; padding: 12px; overflow: hidden; background: var(--input-bg); color: var(--ink); font-size: 0.78rem; line-height: 1.4; }
.day-ahead-result strong { font-size: 1.1rem; }
.day-ahead-result.is-correct { color: #16833a; }
.day-ahead-result.is-close { color: #926900; }
.day-ahead-result.is-error { color: var(--red); }
.day-ahead-result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 12px; }
.day-ahead-result-grid span:nth-child(even) { font-weight: 700; text-align: right; }
.day-ahead-calculation-table-wrap { overflow-x: auto; max-width: 100%; }
.day-ahead-calculation-table { width: 100%; min-width: 760px; border-collapse: collapse; color: var(--ink); font-size: 0.67rem; }
.day-ahead-calculation-table th, .day-ahead-calculation-table td { padding: 6px 7px; border-bottom: 1px solid var(--shadow); text-align: right; white-space: nowrap; }
.day-ahead-calculation-table th:first-child, .day-ahead-calculation-table td:first-child { text-align: left; }
.day-ahead-calculation-table th { color: var(--muted); font-size: 0.61rem; letter-spacing: 0.03em; text-transform: uppercase; }
.day-ahead-calculation-table td { background: var(--surface); }
.day-ahead-calculation-table .day-ahead-calculation-total td { background: var(--input-bg); font-weight: 800; }
.day-ahead-navigation { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.construction-screen { padding-bottom: 40px; }
.construction-instruction { margin: 16px 0; color: var(--muted); font-size: 0.9rem; text-align: center; }
.construction-level-description { max-width: 760px; margin: -8px auto 14px; color: var(--ink); font-size: 0.82rem; line-height: 1.4; text-align: center; }
.construction-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.construction-palette { display: grid; gap: 9px; padding: 13px; background: var(--surface); }
.construction-palette h3 { margin: 0 0 3px; font-size: 0.95rem; }
.construction-piece-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.construction-component { display: grid; gap: 3px; place-items: center; padding: 9px; border: 0; color: var(--white); font-size: 0.72rem; font-weight: 700; text-align: center; transition: transform 160ms ease, opacity 160ms ease; }
.construction-node-piece { width: 92px; height: 92px; border-radius: 50%; }
.construction-node-piece.resource { background: var(--blue); }
.construction-node-piece.bus { background: var(--green); }
.construction-node-piece.load { background: var(--orange); }
.construction-line-piece { width: 100%; min-height: 62px; background: var(--purple); }
.construction-component:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); }
.construction-component:disabled { cursor: not-allowed; opacity: 0.25; }
.construction-component span { font-size: 0.65rem; font-weight: 400; }
.construction-component strong { font-size: 0.76rem; }
.line-piece-mark { display: block; width: 70px; height: 5px; border-radius: 99px; background: var(--white); }
.construction-palette-note { margin: 2px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.construction-clear-button { min-height: 30px; padding: 0 13px; border: 0; border-radius: 999px; background: #000000; color: #ffffff; font-size: 0.72rem; font-weight: 700; }
.construction-clear-button:hover { transform: translateY(-2px); }
.construction-workspace { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 520px; }
.construction-map { display: block; width: 100%; min-width: 0; min-height: 0; height: 100%; background: var(--surface); touch-action: none; user-select: none; }
.construction-line { stroke: var(--purple); stroke-width: 5; stroke-linecap: round; }
.construction-line-group.is-unplaced .construction-line { stroke: var(--purple); stroke-dasharray: 10 8; opacity: 0.78; }
.construction-line-hit { stroke: transparent; stroke-width: 22; pointer-events: stroke; }
.construction-line-group.is-selected .construction-line { stroke: var(--purple); stroke-width: 8; }
.construction-line-label, .construction-node-label, .construction-node-detail { fill: var(--ink); pointer-events: none; text-anchor: middle; }
.construction-line-label { font-size: 12px; font-weight: 700; }
.construction-line-group.is-unplaced .construction-line-label { font-size: 10px; }
.construction-node-label { font-size: 13px; font-weight: 700; }
.construction-node-detail { font-size: 10px; }
.construction-node { cursor: grab; }
.construction-node:active { cursor: grabbing; }
.construction-node-circle { stroke: transparent; stroke-width: 0; }
.construction-node.is-selected .construction-node-circle { filter: drop-shadow(0 0 9px var(--blue)); }
.construction-node.resource .construction-node-circle { fill: var(--blue); }
.construction-node.bus .construction-node-circle { fill: var(--green); }
.construction-node.load .construction-node-circle { fill: var(--orange); }
.construction-inspector { min-height: 74px; margin-top: 10px; padding: 12px; background: var(--input-bg); color: var(--ink); font-size: 0.82rem; line-height: 1.4; }
.construction-inspector h3 { margin: 0 0 6px; font-size: 0.95rem; }
.construction-inspector p { margin: 3px 0; color: var(--muted); }
.construction-inspector label { display: grid; gap: 4px; margin-top: 8px; color: var(--muted); font-size: 0.76rem; }
.construction-inspector input { width: 100%; padding: 6px 7px; border: 0; background: var(--surface); color: var(--ink); }
.construction-inspector-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.construction-inspector-actions button { padding: 6px 9px; border: 0; color: var(--white); font-size: 0.75rem; }
.construction-inspector .construction-return { background: var(--blue); }
.construction-inspector .construction-delete { background: var(--red); }
@media (max-width: 760px) {
  .day-ahead-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day-ahead-layout { grid-template-columns: 1fr; }
  .day-ahead-offer { grid-template-columns: 1fr; }
  .day-ahead-offer-control { min-width: 0; }
  .day-ahead-stack-row { grid-template-columns: minmax(58px, .35fr) minmax(0, 1fr) minmax(58px, .35fr); gap: 5px; }
  .day-ahead-stack-value { font-size: 0.65rem; overflow-wrap: anywhere; }
  .construction-layout { grid-template-columns: 1fr; }
  .construction-layout { gap: 10px; }
  .construction-palette { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
  .construction-palette h3, .construction-palette-note { grid-column: 1 / -1; }
  .construction-piece-tray { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-column: 1 / -1; min-width: 0; gap: 6px; }
  .construction-component { min-width: 0; max-width: 100%; touch-action: none; }
  .construction-line-piece { width: 100%; min-height: 56px; }
  .construction-workspace { min-height: 0; }
  .construction-map { height: auto; min-height: 320px; aspect-ratio: 1000 / 600; }
  #network-map { min-height: 0; height: auto; aspect-ratio: 1 / 2; }
  .construction-inspector { min-width: 0; overflow-wrap: anywhere; }
  .construction-navigation, .day-ahead-navigation { position: sticky; bottom: 8px; z-index: 6; flex-wrap: nowrap; padding: 8px; margin-inline: -8px; background: var(--page); }
  .construction-nav-button, .day-ahead-navigation button { min-width: 0; flex: 1 1 0; padding-inline: 10px; }
  .action-row { flex-wrap: wrap; }
}
.select-mode-button { position: absolute; top: 0; left: 0; margin: 0; }
.select-mode-button:hover { transform: scale(1.08); }
.select-reset-button { position: absolute; right: 0; bottom: 0; margin: 0; padding: 9px 14px; border: 0; border-radius: 999px; background: var(--red); color: var(--white); font-size: 0.8rem; font-weight: 700; }
.select-reset-button:hover { transform: translateY(-2px); }
.level-circles { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 30px; width: 100%; min-height: 250px; }
.level-circle { position: relative; display: grid; place-items: center; width: 142px; height: 142px; flex: 0 0 142px; padding: 0; border: 0; border-radius: 50%; color: var(--white); font-size: 3.6rem; font-weight: 700; line-height: 1; transition: transform 220ms ease; }
.level-circle:hover { transform: scale(1.22); z-index: 2; }
.level-circle.is-locked { cursor: not-allowed; }
.level-circle.status-red { background: var(--red); }
.level-circle.status-yellow { background: var(--yellow); color: var(--ink); }
.level-circle.status-green { background: var(--green); }
.level-circle.status-gray { background: var(--gray); color: #4f5258; }
.level-circle.is-latest { animation: latest-pulse 1.8s ease-in-out infinite; }
.level-circle.is-latest:hover { animation-play-state: paused; transform: scale(1.22); }
.level-circle.is-launching { animation: launch-circle 620ms ease-in-out both; }
.burst-dot { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--burst-color); opacity: 0; pointer-events: none; animation: burst-dot 620ms ease-out both; }
@keyframes latest-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes launch-circle { 0% { transform: scale(1.22); } 35% { transform: scale(1.34); } 100% { transform: scale(1.22); } }
@keyframes burst-dot { 0% { opacity: 0; transform: rotate(var(--angle)) translateX(22px) scale(0.2); } 25% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--angle)) translateX(130px) scale(1); } }
@media (prefers-reduced-motion: reduce) { .level-circle.is-latest, .level-circle.is-launching, .burst-dot { animation: none; } }
.level-select-message { max-width: 620px; margin: 46px 0 0; color: var(--ink); font-size: 1rem; text-align: center; }

.level-screen { padding-bottom: 40px; }
.level-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding-bottom: 4px; }
.level-toolbar h2 { margin: 0; font-size: 1.8rem; text-align: center; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.toolbar-button { width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: var(--white); font-size: 1.3rem; line-height: 1; }
.toolbar-button:hover { transform: scale(1.08); }
.level-instruction { margin: 16px 0 0; color: var(--muted); font-size: 0.95rem; text-align: center; }
.level-description { max-width: 760px; margin: 7px auto 0; color: var(--ink); font-size: 0.86rem; line-height: 1.4; text-align: center; }
.network-section { padding-top: 15px; }
.map-frame { position: relative; overflow: visible; background: var(--page); }
#network-map { display: block; width: 100%; min-height: 310px; }
.map-connection-group, .map-node-group { cursor: pointer; transform-box: fill-box; transform-origin: center; transition: transform 160ms ease; }
.map-connection-group:hover, .map-node-group:hover { transform: scale(1.055); }
.map-connection-group:focus, .map-node-group:focus { outline: none; }
.map-connection-group:focus-visible .map-connection, .map-node-group:focus-visible .map-node-circle { filter: drop-shadow(0 0 9px var(--blue)); }
.map-connection { fill: none; stroke: var(--line); stroke-width: 5; stroke-linecap: round; transition: stroke 160ms ease, filter 160ms ease, stroke-width 160ms ease; }
.map-connection-hit { fill: transparent; stroke: none; pointer-events: all; }
.map-connection-group.status-red .map-connection { stroke: var(--red); stroke-width: 7; }
.map-connection-group.status-yellow .map-connection { stroke: var(--yellow); stroke-width: 7; }
.map-connection-group.status-green .map-connection { stroke: var(--green); stroke-width: 7; }
.map-connection-group.is-active .map-connection { filter: drop-shadow(0 0 8px var(--blue)); }
.map-connection-label, .map-connection-meta { fill: var(--ink); pointer-events: none; text-anchor: middle; paint-order: stroke; stroke: var(--page); stroke-width: 5px; stroke-linejoin: round; }
.map-connection-label { font-size: 12px; font-weight: 700; }
.map-connection-meta { font-size: 10px; stroke-width: 4px; }
.map-node-circle.resource-card { fill: var(--blue); }
.map-node-circle.bus-card { fill: var(--green); }
.map-node-circle.load-card { fill: var(--orange); }
.map-node-group .map-node-circle { stroke: transparent; stroke-width: 0; transition: stroke 160ms ease, stroke-width 160ms ease, filter 160ms ease; }
.map-node-group.status-red .map-node-circle { stroke: var(--red); stroke-width: 7; }
.map-node-group.status-yellow .map-node-circle { stroke: var(--yellow); stroke-width: 7; }
.map-node-group.status-green .map-node-circle { stroke: var(--green); stroke-width: 7; }
.map-node-group.is-active .map-node-circle { filter: drop-shadow(0 0 9px var(--blue)); }
.map-node-name { fill: var(--white); font-size: 14px; font-weight: 700; pointer-events: none; }
.map-node-meta, .map-node-price, .map-node-load { fill: var(--white); font-size: 11px; pointer-events: none; }
.map-node-price, .map-node-load { font-weight: 700; }

.map-popover { position: absolute; z-index: 5; width: min(330px, calc(100% - 24px)); padding: 15px 16px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 28px var(--shadow); }
.hover-popover { top: 14px; left: 14px; pointer-events: auto; }
.solve-popover { top: 14px; right: 14px; }
.popover-title { margin: 0 0 7px; font-size: 1rem; font-weight: 700; }
.popover-kind { margin: 0 0 10px; color: var(--muted); font-size: 0.78rem; }
.popover-details { display: grid; gap: 4px; margin: 0; font-size: 0.82rem; line-height: 1.35; }
.popover-details div { display: flex; justify-content: space-between; gap: 12px; }
.popover-details dt { color: var(--muted); }
.popover-details dd { margin: 0; font-weight: 700; text-align: right; }
.popover-curve { margin-top: 13px; }
.popover-curve-title { margin-bottom: 3px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.popover-curve-svg { display: block; width: 100%; height: auto; overflow: visible; }
.popover-curve-axis { stroke: var(--muted); stroke-width: 1; }
.popover-curve-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.popover-curve-axis-label, .popover-curve-value { fill: var(--muted); font-size: 8px; }
.popover-curve-value { fill: var(--ink); font-size: 9px; }
.popover-curve-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.popover-curve-marker { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.popover-curve-readout { margin-top: 2px; color: var(--ink); font-size: 0.74rem; font-weight: 700; text-align: right; }
.popover-close { position: absolute; top: 9px; right: 10px; padding: 2px 5px; border: 0; background: transparent; color: var(--ink); font-size: 1.2rem; line-height: 1; }
.popover-close:hover { color: var(--red); }
.popover-form { display: grid; gap: 9px; margin-top: 13px; }
.popover-form label { color: var(--muted); font-size: 0.78rem; }
.popover-range { width: 100%; accent-color: var(--blue); }
.popover-number { width: 100%; padding: 7px 8px; border: 0; background: var(--input-bg); color: var(--ink); }
.popover-value { color: var(--ink); font-size: 0.82rem; font-weight: 700; }
.popover-note { margin: 10px 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.35; }

.solve-section { margin-top: 18px; }
.action-row { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }
.check-button, .next-button { padding: 12px 22px; border: 0; border-radius: 999px; font-weight: 700; }
.check-button { background: var(--green); color: var(--ink); }
.reveal-button { padding: 12px 22px; border: 0; border-radius: 999px; background: var(--purple); color: var(--white); font-weight: 700; }
.next-button { margin-left: auto; background: var(--blue); color: var(--white); }
.check-button:hover, .reveal-button:hover, .next-button:hover { transform: translateY(-2px); }
.network-feedback { min-height: 36px; margin-top: 14px; color: var(--ink); font-size: 0.88rem; line-height: 1.45; text-align: center; }
.network-feedback.is-correct { color: #16833a; }
.network-feedback.is-close { color: #926900; }
.network-feedback.is-error { color: var(--red); }
.construction-result { display: grid; gap: 4px; min-height: 92px; place-content: center; margin-top: 18px; padding: 12px 16px; border-radius: 12px; background: var(--input-bg); }
.construction-result strong { font-size: clamp(1.45rem, 4vw, 2rem); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.construction-result span { font-size: 0.88rem; }
.construction-navigation { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.construction-nav-button { padding: 11px 18px; border: 0; border-radius: 999px; background: var(--blue); color: var(--white); font-size: 0.82rem; font-weight: 700; }
.construction-nav-button:disabled { cursor: not-allowed; opacity: 0.35; }
.construction-nav-button:hover:not(:disabled) { transform: translateY(-2px); }
.completion-panel { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 10px 0; }
.completion-panel strong, .completion-panel span { font-size: 0.88rem; }

@media (max-width: 760px) {
  .game-shell { width: min(100% - 22px, 620px); padding-top: 58px; }
  .home-screen h1 { margin-bottom: 48px; }
  .select-reset-button { right: 0; bottom: 0; margin: 0; }
  .level-circle { width: 116px; height: 116px; flex-basis: 116px; font-size: 3rem; }
  .solve-popover { top: 10px; right: 10px; }
  .completion-panel { align-items: flex-start; flex-wrap: wrap; }
  .next-button { margin-left: 0; }
}

@media (max-width: 460px) {
  .game-shell { width: calc(100% - 16px); padding-top: 80px; }
  .theme-toggle { top: 12px; right: 8px; }
  #level-screen .level-toolbar,
  #construction-level-screen .level-toolbar,
  #day-ahead-level-screen .level-toolbar { margin-top: 4px; }
  .home-screen h1, .mode-screen h1 { max-width: 100%; padding-inline: 42px; font-size: 2.2rem; overflow-wrap: anywhere; }
  .mode-screen h1 { margin-bottom: 42px; }
  .level-circles { gap: 18px; }
  .level-circle { width: 96px; height: 96px; flex-basis: 96px; font-size: 2.4rem; }
  .level-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .level-toolbar h2 { min-width: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
  .day-ahead-summary { gap: 6px; }
  .day-ahead-requirement-box { padding-inline: 7px; }
  .day-ahead-requirement-box strong { font-size: 0.72rem; overflow-wrap: anywhere; }
  .construction-map { min-height: 280px; }
  #network-map { min-height: 0; height: auto; aspect-ratio: 1 / 2; }
  .construction-palette { padding: 9px; }
  .construction-node-piece { width: 100%; height: 76px; }
  .construction-component { padding: 7px; font-size: 0.67rem; }
  .construction-component strong { font-size: 0.7rem; }
  .construction-component span { font-size: 0.58rem; }
  .map-popover { width: calc(100% - 20px); }
  .hover-popover, .solve-popover { top: 10px; left: 10px; right: auto; }
}
