: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 ---------- */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; min-height: 56px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.app-header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.3px; }
.icon-back {
  width: 48px; height: 48px; flex: none;
  border-radius: 10px; background: var(--bg-tertiary);
  color: var(--text-primary); font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- home ---------- */
.result-banner {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 20px; min-height: 52px;
  background: var(--bg-primary);
}
.result-banner #resultText {
  font-size: 24px; font-weight: 700; color: var(--text-secondary);
  text-align: center; max-width: 560px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-banner.show #resultText { color: var(--accent-secondary); }
.result-banner.pop #resultText { animation: pop 0.5s ease; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0.2; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.wheel-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.wheel-stage { position: relative; width: 300px; height: 300px; }
#wheel {
  display: block; width: 300px; height: 300px;
  border-radius: 50%;
  box-shadow: 0 0 26px rgba(0, 212, 255, 0.18);
}
.pointer {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 26px solid var(--accent);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  z-index: 3;
}

.home-actions {
  padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-primary);
}
.btn-spin {
  height: 68px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, #00d4ff, #00ff88);
  color: #04121a; font-size: 26px; font-weight: 800; letter-spacing: 2px;
}
.action-row { display: flex; gap: 12px; }
.btn-secondary {
  flex: 1; min-height: 56px; border-radius: var(--radius-md);
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 17px; font-weight: 600;
}

/* ---------- edit ---------- */
.opt-count { padding: 10px 20px 2px; color: var(--text-muted); font-size: 14px; }
.edit-msg { padding: 0 20px; color: var(--danger); font-size: 14px; min-height: 18px; }
.opt-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 6px 16px; display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.opt-row { display: flex; align-items: center; gap: 10px; }
.opt-swatch { width: 18px; height: 38px; border-radius: 6px; flex: none; }
.opt-edit {
  flex: 1; min-height: 56px; border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 18px; font-weight: 600; text-align: left; padding: 0 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.opt-del {
  width: 56px; min-height: 56px; flex: none; border-radius: 10px;
  background: var(--bg-tertiary); color: var(--danger);
  font-size: 22px; font-weight: 700;
}
.edit-actions {
  padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-primary);
}
.edit-actions .btn-secondary { width: 100%; }

/* ---------- presets ---------- */
.preset-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.preset-btn {
  min-height: 62px; border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-primary);
  text-align: left; padding: 10px 16px;
  display: flex; flex-direction: column; gap: 3px; justify-content: center;
}
.preset-btn .pname { font-size: 18px; font-weight: 700; }
.preset-btn .pitems {
  font-size: 13px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- keyboard ---------- */
.kb-display {
  margin: 14px 20px; min-height: 56px; border-radius: 10px;
  background: var(--bg-secondary); border: 1px solid var(--bg-tertiary);
  display: flex; align-items: center; padding: 0 16px;
  font-size: 24px; font-weight: 700;
}
#kbBuffer { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.kb-display .caret {
  display: inline-block; width: 2px; height: 26px; flex: none;
  background: var(--accent); margin-left: 2px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.kb-grid {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 6px 14px 16px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px;
  align-content: start;
}
.kb-key {
  height: 50px; border-radius: 9px;
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.kb-key.special { font-size: 11px; font-weight: 700; 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); }
