:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1720;
}

* { box-sizing: border-box; }

html, body, #game-shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  background: #0d1720;
  color: #eff9f4;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-shell { display: grid; place-items: center; background: #0d1720; }

#stage {
  position: relative;
  width: min(100vw, 960px);
  height: min(56.25vw, 540px);
  overflow: hidden;
  background: #10232b;
}

@media (orientation: landscape) {
  #stage { width: min(177.7778vh, 960px); height: min(100vh, 540px); }
}

#game-canvas { display: block; width: 100%; height: 100%; outline: none; }

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(55px, 1fr));
  gap: 6px;
  pointer-events: none;
}

#hud div {
  min-width: 62px;
  padding: 6px 8px;
  border: 1px solid rgba(157, 238, 198, 0.28);
  background: rgba(8, 20, 26, 0.88);
}

#hud span, #hud strong { display: block; }
#hud span { color: #98b7ac; font-size: 9px; font-weight: 800; letter-spacing: 0.08em; }
#hud strong { color: #b8ffd7; font-size: 15px; line-height: 1.05; }

#action-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 7px;
}

#action-controls button, .result-actions button {
  min-height: 38px;
  border: 1px solid rgba(185, 238, 213, 0.45);
  background: rgba(8, 20, 26, 0.93);
  color: #eff9f4;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
}

#action-controls button { min-width: 72px; }
#action-controls button[aria-pressed="true"] { background: #d9ae45; color: #172023; border-color: #f7d779; }
#action-controls button:focus-visible, .panel button:focus-visible { outline: 2px solid #f7d779; outline-offset: 2px; }

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100% - 44px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid rgba(181, 246, 211, 0.38);
  background: rgba(8, 21, 28, 0.95);
  text-align: center;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.38);
}

.status-label { margin: 0 0 7px; color: #9ce8bb; font-size: 11px; font-weight: 900; letter-spacing: 0.12em; }
.panel h1, .panel h2 { margin: 0; color: #ffffff; font-size: 28px; letter-spacing: 0; }
.panel h2 { font-size: 24px; }
.panel p:not(.status-label) { margin: 12px 0 0; color: #cadbd4; font-size: 14px; line-height: 1.45; }
.controls-copy { color: #92aea2 !important; font-size: 12px !important; }

.panel button {
  min-height: 43px;
  padding: 0 16px;
  border: 1px solid rgba(185, 238, 213, 0.45);
  background: #152b33;
  color: #eff9f4;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.panel .primary { border-color: #c8ffdb; background: #b8ffd7; color: #123025; }
#start-button { margin-top: 18px; }
.best-result { color: #aee9c3 !important; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.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;
}

@media (max-width: 620px) {
  #hud { top: 8px; left: 8px; gap: 4px; }
  #hud div { min-width: 48px; padding: 4px 5px; }
  #hud span { font-size: 7px; }
  #hud strong { font-size: 11px; }
  #action-controls { top: 8px; right: 8px; gap: 4px; }
  #action-controls button { min-width: 57px; min-height: 30px; font-size: 8px; }
  .panel { width: min(370px, calc(100% - 28px)); padding: 17px; }
  .panel h1 { font-size: 24px; }
  .panel p:not(.status-label) { font-size: 12px; }
}

@media (max-width: 620px) and (orientation: portrait) {
  .panel { padding: 10px 14px; }
  .status-label { margin-bottom: 4px; font-size: 9px; }
  .panel h1, .panel h2 { font-size: 22px; }
  .panel p:not(.status-label) { margin-top: 7px; font-size: 11px; line-height: 1.25; }
  .controls-copy { font-size: 10px !important; }
  .panel button { min-height: 37px; }
  #start-button { margin-top: 10px; }
  .result-actions { margin-top: 10px; }
}
