/* ================= KLEURPALETTEN ================= */
:root, [data-theme="emerald"] {
  --sq-light: #ebecd0;
  --sq-dark: #739552;
  --sq-selected: rgba(245, 246, 130, 0.85);
  --sq-last-move: rgba(245, 246, 130, 0.42);
  --accent: #81b64c;
  --accent-glow-dark: rgba(129, 182, 76, 0.32);
  --accent-glow-light: rgba(129, 182, 76, 0.22);
}

[data-theme="obsidian"] {
  --sq-light: #d6cfc2;
  --sq-dark: #3b3530;
  --sq-selected: rgba(212, 175, 55, 0.75);
  --sq-last-move: rgba(212, 175, 55, 0.32);
  --accent: #c9a227;
  --accent-glow-dark: rgba(212, 175, 55, 0.28);
  --accent-glow-light: rgba(212, 175, 55, 0.2);
}

[data-theme="cyberpunk"] {
  --sq-light: #2d244c;
  --sq-dark: #17112b;
  --sq-selected: rgba(255, 0, 127, 0.65);
  --sq-last-move: rgba(0, 240, 255, 0.28);
  --accent: #ff007f;
  --accent-glow-dark: rgba(255, 0, 127, 0.4);
  --accent-glow-light: rgba(255, 0, 127, 0.2);
}

[data-theme="walnut"] {
  --sq-light: #e6ccb2;
  --sq-dark: #7f5539;
  --sq-selected: rgba(230, 180, 80, 0.8);
  --sq-last-move: rgba(230, 180, 80, 0.38);
  --accent: #b08968;
  --accent-glow-dark: rgba(176, 137, 104, 0.32);
  --accent-glow-light: rgba(176, 137, 104, 0.22);
}

[data-theme="frost"] {
  --sq-light: #e0f2fe;
  --sq-dark: #4b7ba6;
  --sq-selected: rgba(56, 189, 248, 0.75);
  --sq-last-move: rgba(56, 189, 248, 0.35);
  --accent: #0284c7;
  --accent-glow-dark: rgba(56, 189, 248, 0.32);
  --accent-glow-light: rgba(2, 132, 199, 0.18);
}

/* ================= DONKER & LICHT MODUS ================= */
:root, [data-mode="dark"] {
  --bg-main: #111312;
  --bg-panel: rgba(30, 34, 31, 0.78);
  --bg-subtle: rgba(255, 255, 255, 0.04);
  --border-panel: rgba(255, 255, 255, 0.08);
  --text-main: #f4f5f4;
  --text-muted: #9ba39d;
  --accent-glow: var(--accent-glow-dark);
  --board-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 30px var(--accent-glow);
  --piece-shadow: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.35));
  --overlay-bg: rgba(10, 10, 14, 0.78);
  --scrollbar-thumb: rgba(255, 255, 255, 0.14);
}

[data-mode="light"] {
  --bg-main: #eef1ee;
  --bg-panel: rgba(255, 255, 255, 0.82);
  --bg-subtle: rgba(15, 23, 20, 0.05);
  --border-panel: rgba(15, 23, 20, 0.1);
  --text-main: #141816;
  --text-muted: #5c6661;
  --accent-glow: var(--accent-glow-light);
  --board-shadow: 0 18px 40px rgba(15, 23, 20, 0.14), 0 0 28px var(--accent-glow);
  --piece-shadow: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.22));
  --overlay-bg: rgba(238, 241, 238, 0.78);
  --scrollbar-thumb: rgba(15, 23, 20, 0.18);
}

/* ================= BASIS & VIEWPORT-FIT ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 24px;
  transition: background-color 0.45s ease, color 0.35s ease;
}

.ambient-glow {
  position: fixed;
  width: 720px;
  height: 720px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  transition: background 0.5s ease;
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(310px, 380px);
  align-items: stretch;
  gap: 24px;
  width: 100%;
  max-width: 1120px;
  height: min(92dvh, 780px);
}

/* ================= BORD STAGE ================= */
.board-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.board-container {
  position: relative;
  height: 100%;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--border-panel);
  box-shadow: var(--board-shadow);
  transition: box-shadow 0.45s ease, border-color 0.45s ease;
}

.board-container.shake {
  animation: boardShake 0.28s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes boardShake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

#chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  user-select: none;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chessboard.flipped { transform: rotate(180deg); }
#chessboard.flipped .square { transform: rotate(180deg); }

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.square.light { background-color: var(--sq-light); }
.square.dark  { background-color: var(--sq-dark); }

.square.last-move::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--sq-last-move);
  pointer-events: none;
}

.square.selected {
  background-color: var(--sq-selected) !important;
}

.square.check {
  background: radial-gradient(circle, rgba(255, 30, 30, 0.9) 0%, rgba(224, 60, 49, 0.35) 70%, transparent 100%);
  animation: checkGlow 1.5s infinite alternate;
}

@keyframes checkGlow {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}

.coord-rank, .coord-file {
  position: absolute;
  font-size: 0.68rem;
  font-weight: 800;
  pointer-events: none;
  opacity: 0.85;
}

.coord-rank { top: 3px; left: 4px; }
.coord-file { bottom: 2px; right: 4px; }

.light .coord-rank, .light .coord-file { color: var(--sq-dark); }
.dark .coord-rank, .dark .coord-file   { color: var(--sq-light); }

.square.valid-move::after {
  content: "";
  width: 26%;
  height: 26%;
  background-color: rgba(0, 0, 0, 0.24);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  animation: popDot 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.square.valid-capture::after {
  content: "";
  position: absolute;
  inset: 6%;
  border: 5px solid rgba(0, 0, 0, 0.26);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  animation: popDot 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popDot {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.piece {
  width: 82%;
  height: 82%;
  z-index: 3;
  filter: var(--piece-shadow);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  will-change: transform;
}

.square:hover .piece { transform: translateY(-2px) scale(1.06); }
.square.selected .piece { transform: translateY(-4px) scale(1.1); }

.particle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ================= SIDE PANEL ================= */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-header h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.pro-tag {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.2s, border-color 0.2s, background-color 0.3s;
}

.icon-btn:hover {
  transform: scale(1.08);
  border-color: var(--accent);
}

.theme-selector {
  display: flex;
  gap: 6px;
  background: var(--bg-panel);
  padding: 6px 9px;
  border-radius: 20px;
  border: 1px solid var(--border-panel);
  backdrop-filter: blur(10px);
  transition: background-color 0.3s, border-color 0.3s;
}

.theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dot);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s;
}

.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active {
  border-color: var(--text-main);
  transform: scale(1.15);
  box-shadow: 0 0 8px var(--dot);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  backdrop-filter: blur(10px);
  transition: background-color 0.3s, border-color 0.3s;
}

.turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.status-badge.black-turn .turn-dot {
  background: #222;
  border-color: #666;
  box-shadow: none;
}

.status-badge.in-check {
  background: rgba(224, 60, 49, 0.2);
  border-color: #e03c31;
  color: #e03c31;
  animation: pulseCheck 1.2s infinite;
}

.status-badge.in-check .turn-dot {
  background: #e03c31;
  border-color: #e03c31;
  box-shadow: 0 0 8px rgba(224, 60, 49, 0.7);
}

@keyframes pulseCheck {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.move-counter {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.player-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  backdrop-filter: blur(12px);
  padding: 9px 14px;
  border-radius: 12px;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.player-bar.active-player { border-color: var(--accent); }

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.white-avatar { background: #ffffff; color: #111; border: 1px solid rgba(0,0,0,0.12); }
.black-avatar { background: #222524; color: #fff; border: 1px solid #444; }

.player-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.captured-pieces {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.92rem;
  min-height: 18px;
  color: var(--text-muted);
}

.advantage {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 6px;
}

.advantage:empty { display: none; }

/* Zettenverloop */
.move-history-box {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  overflow: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.history-header {
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-panel);
}

.move-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  align-content: start;
  gap: 4px 10px;
  font-size: 0.86rem;
}

.move-history::-webkit-scrollbar { width: 6px; }
.move-history::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.empty-history {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: center;
  padding: 16px 0;
}

.move-num {
  color: var(--text-muted);
  font-weight: 600;
}

.move-item {
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  font-weight: 500;
}

.move-item.latest {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* Modals & Knoppen */
.overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.25s ease;
}

.overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-panel);
  padding: 26px 30px;
  border-radius: 16px;
  text-align: center;
  border: 1px solid var(--border-panel);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.trophy-icon { font-size: 2.5rem; margin-bottom: 6px; }
.modal-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.modal-card h3 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-card p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.95rem; }

.promotion-choices { display: flex; gap: 12px; }

.promo-btn {
  width: 62px;
  height: 62px;
  background: var(--bg-subtle);
  border: 2px solid var(--border-panel);
  border-radius: 12px;
  cursor: pointer;
  padding: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.promo-btn:hover {
  border-color: var(--accent);
  transform: translateY(-4px) scale(1.06);
}

.controls { display: flex; gap: 10px; }

.controls button, .modal-card .btn-primary {
  flex: 1;
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-panel);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

button:active { transform: scale(0.96) !important; }

/* ================= RESPONSIVE ================= */
@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    max-width: 520px;
    gap: 12px;
  }

  .board-stage {
    height: auto;
    width: 100%;
  }

  .board-container {
    width: 100%;
    height: auto;
  }

  .side-panel { height: auto; }
  .move-history-box { max-height: 140px; }
}

/* =====================================================================
   UITBREIDINGEN: menu, klokken, online, slepen, review
   ===================================================================== */
.hidden { display: none !important; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button { font-family: inherit; }

/* Bord: slepen, hint, bewegen */
#chessboard { touch-action: none; }
#chessboard.can-move .square { cursor: pointer; }
.square.dragging .piece { opacity: 0.25; }
.square.hint::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 0 4px #3b82f6; background: rgba(59, 130, 246, 0.25);
  animation: popDot 0.25s ease;
}
.piece-ghost {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.45));
}
.piece-ghost svg { width: 100%; height: 100%; }
.piece svg { width: 100%; height: 100%; display: block; }

/* Volgorde van het zijpaneel (zodat wit/zwart mee wisselt met het bord) */
#blackBar { order: 1; } .move-history-box { order: 2; } #whiteBar { order: 3; }
.tool-row { order: 4; } .controls { order: 5; }
.side-panel.flipped-panel #whiteBar { order: 1; }
.side-panel.flipped-panel #blackBar { order: 3; }

/* Spelersbalk */
.player-right { display: flex; align-items: center; gap: 8px; }
.presence { display: inline-block; width: 8px; height: 8px; margin-left: 7px; border-radius: 50%; background: #e03c31; }
.presence.on { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.5px;
  min-width: 68px; text-align: center; padding: 4px 10px; border-radius: 8px;
  background: var(--bg-subtle); color: var(--text-muted); transition: background-color .2s, color .2s;
}
.clock.running { background: var(--accent); color: #fff; }
.clock.low { color: #e03c31; }
.clock.running.low { background: #e03c31; color: #fff; animation: pulseCheck 1s infinite; }

/* Status / kamerinfo / melding */
.status-badge.thinking .turn-dot { animation: pulseCheck 0.8s infinite; background: var(--accent); }
.room-info, .notice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 12px; border-radius: 12px;
  background: var(--bg-panel); border: 1px solid var(--border-panel); backdrop-filter: blur(10px); font-size: 0.82rem;
}
.room-label { color: var(--text-muted); font-weight: 600; }
.room-code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; font-size: 1rem; color: var(--accent); }
.conn-state { margin-left: auto; color: var(--text-muted); font-size: 0.76rem; }
.conn-state.bad { color: #e03c31; }
.notice { border-color: var(--accent); justify-content: space-between; animation: modalPop .25s ease; }
.notice-btns { display: flex; gap: 6px; }

.mini-btn {
  background: var(--bg-subtle); color: var(--text-main); border: 1px solid var(--border-panel);
  border-radius: 7px; padding: 3px 8px; font-size: 0.74rem; font-weight: 700; cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.mini-btn:hover:not(:disabled) { border-color: var(--accent); }

/* Zettenlijst */
.history-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history-tools { display: flex; gap: 4px; text-transform: none; letter-spacing: 0; }
.move-item[data-ply] { cursor: pointer; transition: background-color .15s; }
.move-item[data-ply]:hover { background: var(--border-panel); }
.move-item.latest { cursor: default; }

/* Actieknoppen */
.tool-row { display: flex; gap: 8px; }
.tool-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 4px;
  background: var(--bg-panel); color: var(--text-main); border: 1px solid var(--border-panel);
  border-radius: 10px; font-size: 0.7rem; font-weight: 700; cursor: pointer; backdrop-filter: blur(10px);
  transition: border-color .2s, transform .15s;
}
.tool-btn span { font-size: 1rem; line-height: 1.2; }
.tool-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }

/* Overlays, modals */
.overlay.screen { position: fixed; z-index: 50; padding: 16px; }
.modal-card .modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.modal-actions button { flex: 1 1 120px; padding: 11px 14px; border: none; border-radius: 12px; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.modal-actions .btn-secondary { border: 1px solid var(--border-panel); }
.modal-card { max-width: 100%; }
.menu-card { width: min(460px, 100%); max-height: 92dvh; overflow-y: auto; text-align: left; }
.menu-card h3 { margin-bottom: 14px; font-size: 1.2rem; }
.menu-brand { text-align: center; margin-bottom: 18px; }
.menu-brand h2 { display: flex; align-items: center; justify-content: center; gap: 8px; letter-spacing: 2px; }
.menu-brand p { margin: 4px 0 0; }
.menu-king { font-size: 2.6rem; color: var(--accent); filter: drop-shadow(0 0 14px var(--accent-glow)); }
.mode-grid { display: grid; gap: 10px; }
.mode-card {
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left;
  padding: 14px 16px; border-radius: 14px; background: var(--bg-subtle); color: var(--text-main);
  border: 1px solid var(--border-panel); cursor: pointer; transition: all .2s cubic-bezier(.34,1.56,.64,1);
}
.mode-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 24px var(--accent-glow); }
.mode-ico { grid-row: 1 / 3; font-size: 1.9rem; text-align: center; }
.mode-card strong { font-size: 1rem; }
.mode-card small { color: var(--text-muted); font-size: 0.8rem; }
.menu-foot { display: grid; gap: 8px; margin-top: 14px; }
.menu-foot button { padding: 11px; border-radius: 12px; font-weight: 700; cursor: pointer; }
.back-btn { background: none; border: none; color: var(--text-muted); font-weight: 600; cursor: pointer; padding: 0 0 10px; }
.back-btn:hover { color: var(--accent); }
.field-label { display: block; margin: 14px 0 7px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 12px; border-radius: 10px; background: var(--bg-subtle); color: var(--text-main);
  border: 1px solid var(--border-panel); font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow); }
.switch-row { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; font-size: 0.88rem; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint-text { margin: 8px 0 0 !important; font-size: 0.82rem !important; color: var(--text-muted); }
.btn-primary.wide { width: 100%; margin-top: 20px; padding: 13px; border: none; border-radius: 12px; font-weight: 800; font-size: 0.95rem; cursor: pointer; }
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--bg-subtle); border-radius: 12px; margin-bottom: 4px; }
.tab { flex: 1; padding: 9px; border: none; border-radius: 9px; background: none; color: var(--text-muted); font-weight: 700; font-size: 0.84rem; cursor: pointer; }
.tab.active { background: var(--accent); color: #fff; }
.code-input {
  width: 100%; margin-top: 4px; padding: 14px; text-align: center; font: 800 2rem ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 12px; text-indent: 12px; text-transform: uppercase; color: var(--text-main);
  background: var(--bg-subtle); border: 2px solid var(--border-panel); border-radius: 14px; outline: none;
}
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.error-text { color: #e03c31; font-size: 0.85rem; margin-top: 12px; font-weight: 600; }
.big-code {
  margin: 4px 0 14px; padding: 16px; text-align: center; border-radius: 14px; background: var(--bg-subtle);
  border: 2px dashed var(--accent); color: var(--accent); font: 900 2.6rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: 10px; text-indent: 10px;
}
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 8px; color: var(--text-muted); font-weight: 600; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-panel); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#waitOverlay .back-btn, #waitOverlay p { display: block; text-align: center; width: 100%; }
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90;
  background: var(--text-main); color: var(--bg-main); padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: modalPop .25s ease;
}

@media (max-width: 860px) {
  .tool-btn { font-size: 0.66rem; }
  .clock { font-size: 1rem; min-width: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
