
  :root {
    --panel: rgba(14, 28, 48, 0.78);
    --panel-edge: rgba(255, 255, 255, 0.14);
    --text: #eef3fa;
    --muted: #a9b8cc;
    --magenta: #e0359a;
    --amber: #ffb000;
    --green: #3ccf74;
    --red: #ff4d4d;
    --page: #0e1c30;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --panel: rgba(8, 14, 26, 0.84);
      --panel-edge: rgba(255, 255, 255, 0.12);
      --page: #070d18;
    }
  }
  :root[data-theme="dark"] {
    --panel: rgba(8, 14, 26, 0.84);
    --panel-edge: rgba(255, 255, 255, 0.12);
    --page: #070d18;
  }
  html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
  *, *::before, *::after { box-sizing: inherit; }
  body {
    height: 100%; margin: 0; overflow: hidden; position: relative;
    background: var(--page); color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px; line-height: 1.45;
  }
  #scene { position: absolute; inset: 0; }
  #scene canvas { display: block; width: 100%; height: 100%; }
  .num { font-family: "Arial Narrow", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
  .panel {
    position: absolute; background: var(--panel); border: 1px solid var(--panel-edge);
    border-radius: 6px; padding: 10px 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
  }
  #clock { top: 12px; left: 12px; min-width: 190px; }
  #clock .time { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: 0.01em; }
  #clock .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
  #clock .pen { color: var(--red); }
  #board { top: 12px; right: 12px; width: 220px; }
  #board h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
  #board ol { margin: 0; padding-left: 22px; font-size: 15px; }
  #board li { display: flex; justify-content: space-between; gap: 8px; }
  #board li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #board .empty { color: var(--muted); font-size: 14px; }
  #sticks { bottom: 12px; left: 12px; display: flex; gap: 16px; }
  .stick { text-align: center; font-size: 12px; color: var(--muted); }
  .pad {
    width: 92px; height: 92px; border-radius: 8px; position: relative; margin: 0 auto 5px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--panel-edge);
  }
  .pad::before, .pad::after { content: ""; position: absolute; background: rgba(255,255,255,0.12); }
  .pad::before { left: 50%; top: 6px; bottom: 6px; width: 1px; }
  .pad::after { top: 50%; left: 6px; right: 6px; height: 1px; }
  .dot {
    position: absolute; width: 18px; height: 18px; border-radius: 50%; margin: -9px 0 0 -9px;
    background: var(--amber); box-shadow: 0 0 0 3px rgba(255,176,0,0.25); left: 50%; top: 50%;
  }
  .hover-mark { position: absolute; left: 2px; right: 2px; height: 2px; background: var(--green); opacity: 0.7; display: none; }
  .stick b { color: var(--text); font-weight: 600; }
  #telemetry { bottom: 12px; right: 12px; display: grid; grid-template-columns: auto auto; column-gap: 14px; row-gap: 1px; font-size: 14px; }
  #telemetry dt { color: var(--muted); }
  #telemetry dd { margin: 0; text-align: right; font-size: 18px; font-weight: 700; }
  #nextgate { top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; }
  #arrow { width: 30px; height: 30px; transition: none; }
  #nextgate .label { font-size: 14px; color: var(--muted); }
  #nextgate .label b { color: var(--text); font-size: 20px; }
  #banner {
    position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
    font-family: "Arial Narrow", sans-serif; font-weight: 700;
    font-size: clamp(48px, 10vw, 110px); color: #fff; text-shadow: 0 4px 24px rgba(0,0,0,0.55);
    pointer-events: none; text-align: center; line-height: 1;
  }
  #banner small { display: block; font-size: 0.3em; font-weight: 500; margin-top: 10px; }
  #flash { position: absolute; inset: 0; background: var(--red); opacity: 0; pointer-events: none; transition: opacity 0.5s; }
  .overlay {
    position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
    background: rgba(5, 12, 24, 0.55); padding: 16px; overflow-y: auto;
  }
  .overlay.show { display: flex; }
  .card {
    background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 8px;
    max-width: 640px; width: 100%; padding: 26px 28px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .card h1 { font-family: "Arial Narrow", sans-serif; font-size: 44px; line-height: 1; margin: 0 0 6px; font-weight: 700; }
  .card h1 .line { display: inline-block; width: 46px; height: 5px; background: var(--magenta); vertical-align: middle; margin-right: 12px; border-radius: 3px; }
  .card p { margin: 6px 0 14px; color: var(--muted); max-width: 62ch; }
  .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 12px 0 16px; }
  .keys h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
  .keys table { border-collapse: collapse; font-size: 14px; }
  .keys td { padding: 2px 8px 2px 0; }
  kbd {
    display: inline-block; min-width: 24px; padding: 1px 6px; text-align: center;
    border: 1px solid var(--panel-edge); border-bottom-width: 3px; border-radius: 4px;
    background: rgba(255,255,255,0.08); font-family: sans-serif; font-weight: 700; color: var(--text);
  }
  .extra { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
  .extra kbd { margin-right: 3px; }
  .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  button {
    font: 600 16px system-ui, sans-serif; cursor: pointer; border-radius: 6px;
    padding: 10px 18px; border: 1px solid var(--panel-edge); background: rgba(255,255,255,0.08); color: var(--text);
  }
  button.primary { background: var(--amber); color: #1a1200; border-color: var(--amber); }
  button:focus-visible, input:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }
  .seg { display: inline-flex; border: 1px solid var(--panel-edge); border-radius: 6px; overflow: hidden; }
  .seg button { border: 0; border-radius: 0; padding: 8px 12px; font-size: 14px; background: transparent; }
  .seg button[aria-pressed="true"] { background: rgba(224, 53, 154, 0.35); }
  .result { font-size: 64px; font-weight: 700; line-height: 1; margin: 8px 0; }
  .note { color: var(--muted); font-size: 13px; margin-top: 14px; }
  input[type=text] {
    font: 600 18px system-ui, sans-serif; padding: 8px 10px; border-radius: 6px; width: 170px;
    border: 1px solid var(--panel-edge); background: rgba(255,255,255,0.1); color: var(--text); text-transform: uppercase;
  }
  .legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
  .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
  @media (max-width: 760px) {
    #board, #telemetry { display: none; }
    #clock .time { font-size: 34px; }
    #nextgate { top: auto; bottom: 150px; }
    .keys { grid-template-columns: 1fr; }
  }
  @media (prefers-reduced-motion: reduce) { #flash { transition: none; } }

  #compatibility { z-index: 100; background: #070d18; }
  #compatibility .card { max-width: 560px; }
  #compatibility h1 { font-size: 32px; }
  [hidden] { display: none !important; }
  .controls-note { font-size: 13px; }
  .status { color: var(--muted); font-size: 13px; }
  #clearBoardBtn { pointer-events: auto; margin-top: 8px; padding: 4px 8px; font-size: 12px; }
  select { background: #18273c; color: var(--text); border: 1px solid var(--panel-edge); border-radius: 6px; padding: 7px; font: inherit; }
  #scoreNotice { margin-top: 8px; }
  .overlay { align-items: safe center; }
  @media (max-height: 720px) { #menu .card { padding: 16px 22px; } #menu h1 { font-size: 34px; } .keys { margin: 8px 0; } }
