:root {
  color-scheme: light;
  --desktop: #008080;
  --button-face: #c0c0c0;
  --button-light: #fff;
  --button-shadow: #808080;
  --button-dark: #404040;
  --title-blue: #000080;
  --ink: #111;
  --window-width: min(806px, calc((100svh - 232px) * 600 / 440));
  font: 12px Tahoma, Verdana, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--desktop); min-width: 280px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; color: #666; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 1px dotted currentColor; outline-offset: -4px; }
[hidden] { display: none !important; }
a { color: #000080; }
#desktop { min-height: 100svh; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.window { background: var(--button-face); padding: 3px; border: 1px solid; border-color: var(--button-light) var(--button-dark) var(--button-dark) var(--button-light); box-shadow: inset -1px -1px var(--button-shadow), inset 1px 1px #dfdfdf; }
#game-window { width: min(var(--window-width), 100%); }
.titlebar { height: 26px; background: linear-gradient(90deg, var(--title-blue), #1084d0); display: flex; align-items: center; gap: 5px; padding: 3px; color: #fff; user-select: none; }
h1 { font-size: 12px; font-weight: 700; margin: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.window-controls { display: flex; gap: 3px; }
.window-controls button, .classic-button { border: 0; background: var(--button-face); box-shadow: inset -1px -1px var(--button-dark), inset 1px 1px var(--button-light), inset -2px -2px var(--button-shadow), inset 2px 2px #dfdfdf; }
.window-controls button { padding: 0; width: 19px; height: 18px; display: grid; place-items: center; }
.window-controls button:last-child { margin-left: 2px; }
.window-controls button:active, .classic-button:active { box-shadow: inset 1px 1px var(--button-dark), inset -1px -1px var(--button-light), inset 2px 2px var(--button-shadow); }
.min-icon { width: 8px; height: 3px; background: #000; transform: translateY(4px); }
.max-icon { width: 10px; height: 9px; border: 1px solid #000; border-top-width: 3px; }
.close-icon { color: #000; font: bold 20px/15px Arial, sans-serif; }
#playfield { position: relative; aspect-ratio: 600 / 440; background: #000; margin-top: 3px; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; touch-action: none; outline-color: #fff; }
.launch-panel { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #101018; color: #eee; text-align: center; padding: 20px; gap: 16px; }
.launch-panel h2 { color: #bcb0ef; font: italic 700 clamp(24px, 5vw, 40px) Georgia, serif; margin: 0; }
.launch-panel p { margin: 0; max-width: 42ch; line-height: 1.6; }
.launch-note { color: #a6a6b5; font-size: 11px; }
progress { width: min(240px, 80%); height: 14px; accent-color: #bcb0ef; }
.classic-button { padding: 8px 20px; min-height: 34px; min-width: 92px; color: var(--ink); }
#start-game { min-width: 156px; font-weight: bold; }
.game-toolbar { display: flex; align-items: center; gap: 2px; padding: 3px 0; flex-wrap: wrap; }
.game-toolbar button { padding: 8px; border: 1px solid transparent; background: transparent; min-height: 34px; }
.game-toolbar button:not(:disabled):hover { border-color: var(--button-light) var(--button-shadow) var(--button-shadow) var(--button-light); }
.game-toolbar button:not(:disabled):active { border-color: var(--button-shadow) var(--button-light) var(--button-light) var(--button-shadow); }
kbd { font: 11px Tahoma, Verdana, sans-serif; }
.game-toolbar kbd { color: #444; margin-left: 6px; }
.toolbar-spacer { flex: 1; }
.statusbar { display: flex; gap: 3px; color: #303030; font-size: 11px; }
.statusbar span { padding: 4px 7px; border: 1px solid; border-color: var(--button-shadow) #dfdfdf #dfdfdf var(--button-shadow); }
.statusbar span:first-child { flex: 1; }
.touch-controls { display: none; gap: 6px; padding: 4px 0 8px; }
.touch-controls button { min-height: 56px; min-width: 0; border: 1px solid; border-color: var(--button-light) var(--button-shadow) var(--button-shadow) var(--button-light); background: var(--button-face); font-weight: bold; flex: 1; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.touch-controls button span { display: block; margin-top: 4px; font-size: 10px; font-weight: normal; }
.touch-controls button:active, .touch-controls button.held { background: #aaa; border-color: var(--button-shadow) var(--button-light) var(--button-light) var(--button-shadow); }
.keyboard-hint { margin: 0; color: #e3f0ed; text-align: center; font-size: 11px; line-height: 2; }
.keyboard-hint kbd { padding: 2px 5px; color: #fff; border: 1px solid #74b6b2; }
.keyboard-hint span { padding: 0 6px; }
.credits { margin: 0; font-size: 10px; color: #b0d7d4; text-align: center; line-height: 1.8; }
.credits a, .credits button { color: inherit; }
.credits button { padding: 0; border: 0; background: none; text-decoration: underline; font-size: inherit; }
#restore-game { display: flex; align-items: center; gap: 10px; }
.dialog-window { width: min(510px, calc(100% - 24px)); max-height: calc(100svh - 32px); border: 1px solid; }
.dialog-window::backdrop { background: #0006; }
.dialog-titlebar { background: var(--title-blue); color: #fff; font-weight: bold; padding: 6px; }
.dialog-content { padding: 16px; line-height: 1.6; }
.dialog-content h2 { margin: 0 0 12px; font-size: 18px; }
.dialog-content p { margin: 0 0 16px; }
.dialog-content form { text-align: right; }
.key-list { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 20px 0; }
.key-list dt, .key-list dd { margin: 0; }
.dialog-content kbd { font-weight: bold; }
.small-note { font-size: 11px; color: #444; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
#game-window.maximized { --window-width: min(1200px, calc((100svh - 180px) * 600 / 440)); }
#game-window:fullscreen { width: 100%; height: 100%; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #000; }
#game-window:fullscreen .titlebar, #game-window:fullscreen .statusbar { display: none; }
#game-window:fullscreen #playfield { width: min(100%, calc((100svh - 44px) * 600 / 440)); margin: 0; flex-shrink: 0; }
#game-window:fullscreen .game-toolbar { background: var(--button-face); width: min(100%, calc((100svh - 44px) * 600 / 440)); }
@media (pointer: coarse), (max-width: 600px) {
  #desktop { padding: max(16px, env(safe-area-inset-top)) 8px max(16px, env(safe-area-inset-bottom)); gap: 12px; }
  #game-window { --window-width: 806px; }
  .touch-controls { display: flex; }
  .keyboard-hint { display: none; }
  .titlebar { height: 28px; }
  .window-controls button { width: 22px; height: 21px; }
  .game-toolbar button { padding: 8px 5px; min-height: 40px; }
  .game-toolbar kbd { display: none; }
  .statusbar span:last-child { display: none; }
  .launch-panel { gap: 10px; }
  .launch-panel > img { width: 32px; height: 32px; }
  .launch-note { display: none; }
  .key-list { grid-template-columns: 100px 1fr; gap: 8px; }
  #game-window:fullscreen #playfield { width: min(100%, calc((100svh - 112px) * 600 / 440)); }
}
@media (max-height: 650px) and (min-width: 601px) {
  #desktop { padding: 12px; gap: 10px; }
  #game-window { --window-width: min(806px, calc((100svh - 126px) * 600 / 440)); }
  .keyboard-hint, .credits { display: none; }
}
@media (pointer: coarse) and (max-height: 650px) {
  #game-window { --window-width: min(806px, calc((100svh - 196px) * 600 / 440)); }
}
