:root {
  color-scheme: dark;
  --panel: #0b1020;
  --panel-raised: #121a31;
  --border: #2a3657;
  --ink: #f5fbff;
  --muted: #9fb0c9;
  --brand: #4cc9f0;
  --brand-dark: #123d5a;
  --focus: #ffe36b;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--panel);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

button,
canvas { -webkit-tap-highlight-color: transparent; }

#shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

#stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #07101f;
}

canvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 420 / 640;
  background: #6fd2f4;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
}

canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

#controls {
  flex: 0 0 auto;
  padding: 7px 10px 8px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 -8px 24px rgb(2 6 23 / 35%);
}

.status-row,
.button-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-row {
  gap: 18px;
  min-height: 25px;
  margin-bottom: 6px;
}

.metric {
  display: inline-flex;
  min-width: 54px;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.metric-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.metric strong {
  min-width: 1.2em;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

.button-row {
  flex-wrap: wrap;
  gap: 6px;
}

button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 11px;
  background: var(--panel-raised);
  color: var(--ink);
  font: 700 12px/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--brand);
  background: #172442;
}

button:active:not(:disabled) { transform: translateY(1px); }

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  opacity: .42;
  cursor: default;
}

button.primary {
  border-color: #66e0ff;
  background: var(--brand);
  color: #06121d;
  min-width: 72px;
}

button.primary:hover:not(:disabled) { background: #7ee7ff; }

button[hidden] { display: none; }

.hint {
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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: 360px) {
  #controls { padding-inline: 6px; }
  .status-row { gap: 8px; }
  .button-row { gap: 4px; }
  button { padding-inline: 8px; font-size: 11px; }
  .hint { font-size: 9.5px; }
}

@media (max-height: 520px) {
  #controls { padding-block: 4px 5px; }
  .status-row { margin-bottom: 4px; min-height: 21px; }
  .metric strong { font-size: 14px; }
  button { min-height: 28px; padding-block: 4px; }
  .hint { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled) { transform: none; }
}
