:root {
  --bg: #1E1E1E;
  --surface: #2A2A2A;
  --line: #3A3A3A;
  --text: #FFFFFF;
  --muted: rgba(255, 255, 255, 0.6);
  --accent: #62FFD2;
  --danger: #FF6B6B;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 48px 24px;
  text-align: center;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted);
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px rgba(98, 255, 210, 0.6); }

h1 { margin: 0; font-size: clamp(36px, 5vw, 64px); font-weight: 700; letter-spacing: 0.02em; }

#pair-form { position: relative; display: flex; flex-direction: column; align-items: center; gap: 28px; }

.code-boxes { display: flex; gap: clamp(12px, 2vw, 24px); }
.code-boxes span {
  width: clamp(72px, 9vw, 128px); height: clamp(96px, 12vw, 160px);
  display: flex; align-items: center; justify-content: center;
  border-radius: 20px; background: var(--surface); border: 2px solid var(--line);
  font-size: clamp(48px, 7vw, 96px); font-weight: 700; font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.code-boxes span.filled { border-color: rgba(98, 255, 210, 0.5); }
.code-boxes span.cursor { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(98, 255, 210, 0.18); }
.code-boxes.shake { animation: shake 320ms ease; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* The real input sits over the boxes, invisible, so typing / paste / IME all work. */
#code {
  position: absolute; top: 0; left: 0; width: 100%; height: clamp(96px, 12vw, 160px);
  opacity: 0; border: 0; font-size: 16px; caret-color: transparent; cursor: text;
}

button { font: inherit; cursor: pointer; }
.primary {
  min-width: 220px; padding: 16px 36px; border: 0; border-radius: 999px;
  background: var(--accent); color: #0B2B22; font-size: 22px; font-weight: 700;
}
.primary:disabled { opacity: 0.35; cursor: default; }
.primary.big { min-width: 320px; padding: 24px 56px; font-size: 32px; }
.primary:focus-visible, .link:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.link { background: none; border: 0; color: var(--muted); font-size: 18px; text-decoration: underline; text-underline-offset: 4px; }

.error { min-height: 1.5em; margin: 0; color: var(--danger); font-size: 20px; }
.hint { margin: 0; color: var(--muted); font-size: 18px; max-width: 36em; line-height: 1.6; }
.paired { margin: 0; color: var(--accent); font-size: 22px; font-weight: 600; }
.paired strong { font-variant-numeric: tabular-nums; letter-spacing: 0.1em; }

/* ---------- presentation ---------- */
#stage { position: fixed; inset: 0; background: #000; overflow: hidden; }
#stage.nocursor { cursor: none; }
#slide { position: absolute; user-select: none; -webkit-user-select: none; }
#ink { position: absolute; pointer-events: none; }
#blank { position: absolute; inset: 0; background: #000; display: none; }
body.is-hidden #blank { display: block; }
#waiting {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.35); font-size: 24px;
}

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; z-index: 10;
  background: rgba(30, 30, 30, 0.88); color: var(--text); font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
