:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- header ---------- */
.header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; min-height: 60px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.header-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.header-label {
  font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
}
.header-info h1 {
  font-size: 22px; font-weight: 800; letter-spacing: 0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-total { text-align: right; display: flex; flex-direction: column; gap: 3px; flex: none; }
.header-num { font-size: 28px; font-weight: 800; line-height: 1; }
.accent-cyan { color: var(--accent); }
.accent-green { color: var(--accent-secondary); }

/* ---------- home stage ---------- */
.stage {
  flex: 1; position: relative; min-height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 18px 24px;
}
.stage-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; max-width: 100%;
}
.winner-tag {
  font-size: 13px; font-weight: 800; letter-spacing: 3px;
  color: #04121a; background: var(--accent-secondary);
  padding: 5px 16px; border-radius: 999px;
}
.pick {
  font-size: 40px; font-weight: 800; line-height: 1.12;
  max-width: 552px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick.cycling { color: var(--text-secondary); opacity: 0.9; }
.pick.winner { color: var(--accent-secondary); text-shadow: 0 0 30px rgba(0, 255, 136, 0.55); }
.pick.pop { animation: pop 0.5s ease; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0.2; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.pick-sub { font-size: 15px; color: var(--text-muted); font-weight: 600; min-height: 18px; }

/* ---------- confetti ---------- */
.confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.confetti-bit {
  position: absolute; top: -16px; width: 8px; height: 13px; border-radius: 2px;
  opacity: 0.9; animation: fall 1.25s ease-in forwards;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(380px) rotate(380deg); opacity: 0; }
}

/* ---------- buttons ---------- */
.btn { border-radius: var(--radius-md); font-family: inherit; }
.btn-primary { background: linear-gradient(135deg, #00d4ff, #00ff88); color: #04121a; font-weight: 800; }
.btn-tertiary { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 700; }
.btn-danger { background: #3a1420; color: var(--danger); font-weight: 700; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-spin {
  height: 84px; margin: 0 20px 12px;
  font-size: 28px; font-weight: 800; letter-spacing: 4px;
}
.controls { display: flex; gap: 12px; padding: 0 20px 20px; background: var(--bg-primary); }
.controls .btn { flex: 1; min-height: 60px; font-size: 16px; letter-spacing: 1px; }
.controls-3 .btn { font-size: 15px; letter-spacing: 0.5px; }

/* ---------- names list ---------- */
.list-wrap { flex: 1; position: relative; min-height: 0; display: flex; }
.name-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.name-row { display: flex; align-items: center; gap: 10px; }
.name-idx { width: 28px; flex: none; text-align: center; font-size: 14px; font-weight: 700; color: var(--text-muted); }
.name-label {
  flex: 1; min-height: 58px; border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 19px; font-weight: 600; text-align: left; padding: 0 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.name-del {
  width: 58px; min-height: 58px; flex: none; border-radius: 10px;
  background: var(--bg-tertiary); color: var(--danger);
  font-size: 20px; font-weight: 700;
}
.empty-state {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--text-muted);
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 16px; background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 300; color: var(--accent);
}
.empty-state p { font-size: 16px; text-align: center; line-height: 1.5; }
.edit-msg { padding: 0 20px; min-height: 18px; color: var(--danger); font-size: 14px; font-weight: 600; }

/* ---------- keyboard ---------- */
.kb-head { padding: 14px 20px 8px; background: var(--bg-primary); }
.kb-title { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.kb-buffer-wrap {
  margin-top: 8px; min-height: 56px; border-radius: 10px;
  background: var(--bg-secondary); border: 1px solid var(--bg-tertiary);
  display: flex; align-items: center; padding: 0 16px;
}
.kb-buffer { font-size: 24px; font-weight: 700; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.kb-buffer.placeholder { color: var(--text-muted); font-weight: 600; }
.kb-caret {
  display: inline-block; width: 2px; height: 26px; flex: none;
  background: var(--accent); margin-left: 3px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.kb-grid {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 8px 14px 16px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px;
  align-content: start;
}
.kb-key {
  height: 54px; border-radius: 9px;
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.kb-key.special { font-size: 11px; font-weight: 800; letter-spacing: 0.5px; }
.kb-key.k-del, .kb-key.k-space, .kb-key.k-case { background: var(--bg-secondary); color: var(--accent); }
.kb-key.k-done { background: var(--accent); color: #04121a; }
.kb-key.k-cancel { background: #3a1420; color: var(--danger); }

/* ---------- confirm ---------- */
.confirm-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 24px 40px;
}
.confirm-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: #3a1420; color: var(--danger);
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 800;
}
.confirm-text { font-size: 18px; line-height: 1.5; text-align: center; color: var(--text-secondary); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pick.pop, .confetti-bit, .kb-caret { animation: none !important; }
  .kb-caret { opacity: 1; }
}
