:root {
  color-scheme: dark;
  --bg: #05070f;
  --ink: #e6eefc;
  --muted: #8ea0c8;
  --p1: #59e3ff;
  --p2: #ff7ad9;
  --line: rgba(140, 170, 220, 0.18);
}

/* An author rule that sets `display` beats the UA stylesheet's [hidden],
   so keep this explicit — panels are toggled with el.hidden. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px clamp(10px, 3vw, 28px) 18px;
  overflow: hidden;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.bar p { margin: 0; color: var(--muted); font-size: 13px; }

h1 {
  margin: 0;
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--p1);
}

h1 span { color: var(--p2); }

main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

/* The stage letterboxes inside the viewport, so its overlay is sized against
   the stage itself (cqh/cqw) rather than against vw/vh. */
.stage {
  position: relative;
  container-type: size;
  width: min(100%, 1080px, (100dvh - 190px) * (900 / 560));
  aspect-ratio: 900 / 560;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  touch-action: none;
  cursor: none;
}

.stage.is-idle { cursor: auto; }

canvas { display: block; width: 100%; height: 100%; }

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.4cqh, 16px);
  padding: clamp(12px, 4cqh, 28px);
  background: rgba(5, 8, 16, 0.82);
  backdrop-filter: blur(6px);
  text-align: center;
}

.panel h2 {
  margin: 0;
  font-size: clamp(20px, 8cqh, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel .line {
  margin: 0;
  color: var(--muted);
  font-size: clamp(12px, 3.4cqh, 16px);
}

.panel .keys {
  margin: 0;
  color: var(--muted);
  font-size: clamp(10px, 2.8cqh, 13px);
}

.row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2cqw, 14px);
  flex-wrap: wrap;
  justify-content: center;
}

.row-label {
  color: var(--muted);
  font-size: clamp(10px, 2.8cqh, 13px);
  min-width: 7ch;
  text-align: right;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

button, .ghost {
  font: inherit;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.seg button {
  padding: clamp(4px, 1.4cqh, 8px) clamp(9px, 2.6cqw, 18px);
  font-size: clamp(10px, 2.8cqh, 14px);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.seg button:hover { color: var(--ink); }

.seg button.on {
  background: var(--p1);
  color: #04121a;
  font-weight: 600;
}

.primary {
  margin-top: clamp(2px, 1.6cqh, 10px);
  padding: clamp(8px, 2.4cqh, 14px) clamp(26px, 8cqw, 54px);
  font-size: clamp(13px, 3.6cqh, 18px);
  font-weight: 600;
  color: #04121a;
  background: linear-gradient(135deg, var(--p1), #9fe9ff);
  box-shadow: 0 8px 26px rgba(89, 227, 255, 0.28);
}

.primary:hover { filter: brightness(1.08); }

.ghost {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  text-decoration: none;
}

.ghost:hover { color: var(--ink); }

.panel .ghost.wide {
  padding: clamp(5px, 1.8cqh, 9px) clamp(16px, 5cqw, 30px);
  font-size: clamp(11px, 3cqh, 14px);
}

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

.rotate {
  display: none;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* A decision about the device, not about the stage box — so this one reads the
   viewport on purpose. */
@media (orientation: portrait) and (pointer: coarse) {
  .rotate { display: block; }
  footer.bar { flex-direction: column; align-items: flex-start; gap: 4px; }
  .row-label { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .primary { transition: none; }
}
