*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1a1a2e;
  --bg-surface: #16213e;
  --bg-card: #0f3460;
  --text: #e8e8e8;
  --text-muted: #8899aa;
  --accent: #e94560;
  --accent-glow: #ff6b81;
  --gold: #f5c542;
  --green: #4ecdc4;
  --beam-color: #c4b5a0;
  --fulcrum-color: #8a7968;
  --block-color: #3a506b;
  --shared-color: #f5c542;
  --bust-color: #e94560;
  --radius: 12px;
  --font: 'Inter', system-ui, sans-serif;
  --font-display: 'Playfair Display', serif;

  /* Theme engine */
  --glow-left: transparent;
  --glow-right: transparent;
}

/* ============================================================
   THEMES — applied via data-theme on <body>
   ============================================================ */

/* --- void (default, flat dark) --- */
body[data-theme="void"] {
  background: #1a1a2e;
}
body[data-theme="void"] #bg-layer { display: none; }

/* --- drift (slow-moving gradient) --- */
body[data-theme="drift"] {
  background: #0a0a18;
}
body[data-theme="drift"] #bg-layer {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg,
    #0a0a18 0%,
    #2a1060 20%,
    #0d2a4a 40%,
    #1a0a30 60%,
    #0a2030 80%,
    #2a1060 100%
  );
  background-size: 500% 500%;
  animation: driftGradient 12s ease infinite;
  pointer-events: none;
  opacity: 0.9;
}
@keyframes driftGradient {
  0%   { background-position: 0% 0%; }
  25%  { background-position: 100% 0%; }
  50%  { background-position: 100% 100%; }
  75%  { background-position: 0% 100%; }
  100% { background-position: 0% 0%; }
}

/* --- pulse (drift colours, breathing radial glow) --- */
body[data-theme="pulse"] {
  background: #0a0a18;
}
body[data-theme="pulse"] #bg-layer {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #0a0a18;
}
body[data-theme="pulse"] #bg-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 50%,
    #2a1060 0%,
    #0d2a4a 40%,
    transparent 70%
  );
  animation: pulseGlow 4s ease-in-out infinite;
}
body[data-theme="pulse"] #bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 50% 40% at 50% 50%,
    rgba(78, 205, 196, 0.12) 0%,
    transparent 65%
  );
  animation: pulseGlow 4s ease-in-out infinite reverse;
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.12); }
}

/* --- graph (dot grid) --- */
body[data-theme="graph"] {
  background: #10101e;
}
body[data-theme="graph"] #bg-layer {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(78,205,196,0.18) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* --- weighted (reactive beam glows) --- */
body[data-theme="weighted"] {
  background: #0d0d1a;
}
body[data-theme="weighted"] #bg-layer {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transition: background 0.6s ease;
  background:
    radial-gradient(ellipse 55% 60% at 18% 50%, var(--glow-left) 0%, transparent 70%),
    radial-gradient(ellipse 55% 60% at 82% 50%, var(--glow-right) 0%, transparent 70%),
    #0d0d1a;
}

/* Ensure #app and all screens sit above bg-layer */
#app { position: relative; z-index: 1; }

#desktop-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  overflow: hidden;
  text-align: center;
  padding: 24px;
  position: relative;
  z-index: 10;
  background: var(--bg);
}

#desktop-gate { display: none; }
#app { display: block; }

html, body {
  height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  overflow-y: auto;
  min-height: 0;
  animation: fadeIn 0.3s ease;
}

#screen-game {
  justify-content: flex-start;
  padding-top: 8px;
  padding-bottom: 8px;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* ---- Typography ---- */

.logo {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 4px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
  letter-spacing: 0.1em;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover {
  background: var(--bg-card);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-stand {
  background: var(--green);
  color: var(--bg);
  width: 100%;
  margin-top: 10px;
  padding: 10px 24px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.btn-stand:hover {
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---- Inputs ---- */

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border 0.2s;
}

input:focus {
  border-color: var(--accent);
}

/* ---- Auth ---- */

.auth-container {
  text-align: center;
  width: 100%;
  max-width: 360px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-msg {
  color: var(--accent);
  font-size: 0.8rem;
  min-height: 0;
  margin-top: 4px;
}

/* ---- Help Modal ---- */

.help-trigger {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

/* ---- Theme picker ---- */

#settings-trigger {
  position: fixed;
  top: 16px;
  right: 60px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-trigger {
  position: fixed;
  top: 16px;
  right: 104px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-picker {
  position: fixed;
  top: 62px;
  right: 16px;
  z-index: 150;
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#theme-picker.hidden { display: none; }

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.theme-option:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.theme-option.active { color: var(--green); background: rgba(78,205,196,0.08); }

.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}
.theme-swatch.void    { background: #1a1a2e; }
.theme-swatch.drift   { background: linear-gradient(135deg, #0d0d1a, #1a1a3e, #1a0d2e); }
.theme-swatch.pulse   { background: radial-gradient(circle at 50% 60%, #2a1060, #0d2a4a 60%, #0a0a18); }
.theme-swatch.graph   { background: radial-gradient(circle, rgba(78,205,196,0.4) 1px, #10101e 1px); background-size: 6px 6px; }
.theme-swatch.weighted { background: linear-gradient(to right, rgba(233,69,96,0.6), #0d0d1a, rgba(78,205,196,0.6)); }

/* ---- Settings modal ---- */

.settings-box {
  max-width: 340px;
  text-align: left;
}

.settings-section {
  margin-bottom: 20px;
}

.settings-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Difficulty */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-btn {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.diff-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.diff-btn.active {
  border-color: var(--green);
  background: rgba(78,205,196,0.08);
  color: var(--text);
}
.diff-icon { font-size: 1.1rem; text-align: center; }
.diff-name { font-size: 0.9rem; font-weight: 600; }
.diff-desc { font-size: 0.72rem; color: var(--text-muted); justify-self: end; }
.diff-btn.active .diff-desc { color: var(--green); }

/* Theme row inside settings */
.theme-options-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.theme-option-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.theme-option-inline:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.theme-option-inline.active { border-color: var(--green); color: var(--green); background: rgba(78,205,196,0.08); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.modal-box p {
  margin: 0 0 20px;
  font-size: 1.05rem;
  color: var(--text);
}
.modal-actions {
  display: flex;
  gap: 12px;
}
.modal-actions .btn {
  flex: 1;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.help-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.help-list strong {
  color: var(--text);
}

/* ---- Waiting ---- */

.waiting-container {
  text-align: center;
  width: 100%;
  max-width: 360px;
}

.waiting-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

.target-display {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 24px;
}

.waiting-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
.waiting-spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.waiting-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.solo-btn {
  margin-top: 8px;
}

/* ---- Game Screen ---- */

.game-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.target-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.target-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.target-number {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.header-right {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.turn-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.turn-timer {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 40px;
  text-align: right;
}
.turn-timer.warning {
  color: var(--accent);
  animation: pulse 1s ease infinite;
}

.live-match-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--green);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
}
.live-match-banner.hidden { display: none; }

/* ---- Balance Beam (Physics Canvas) ---- */

.beam-wrapper {
  width: 100%;
  max-width: 315px;
  align-self: center;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#beam-canvas {
  flex: 1 1 0;
  width: 100%;
  min-height: 120px;
  display: block;
}

.beam-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 0;
  flex-shrink: 0;
}

.beam-info-side {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.word-pills {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  max-height: 40px;
}

.word-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
  line-height: 1.4;
}

.word-pill-weight {
  color: var(--gold);
  font-weight: 700;
}

.beam-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.beam-total {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.beam-total-hidden {
  color: var(--text-muted);
}

/* ---- Submit Area ---- */

.submit-area {
  width: 100%;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

.opponent-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.opponent-wait.hidden { display: none; }

.status-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 0;
}

/* ---- Word Suggestions ---- */

.word-suggestions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.suggestion-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1 1 0;
  min-width: 0;
}
.suggestion-btn:active {
  transform: scale(0.96);
  background: var(--accent);
}
.suggestion-syl {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 700;
  margin-top: 2px;
}

.word-suggestions.hidden { display: none; }

#word-form.hidden { display: none; }

/* ---- Reveal Screen ---- */

.reveal-container {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.reveal-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.result-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.03em;
}
.result-badge.jackpot {
  background: var(--gold);
  color: var(--bg);
}
.result-badge.closest {
  background: var(--green);
  color: var(--bg);
}
.result-badge.both_bust {
  background: var(--accent);
  color: #fff;
}
.result-badge.draw {
  background: var(--bg-card);
  color: var(--text);
}

.reveal-columns {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
}

.reveal-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}

.reveal-col-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  padding-bottom: 6px;
  text-align: center;
}

.reveal-word-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.reveal-word {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  opacity: 0;
  animation: revealWord 0.4s ease forwards;
}

.reveal-word.shared {
  background: var(--shared-color);
  color: var(--bg);
}
.reveal-word.shared .word-weight {
  color: var(--bg);
  opacity: 0.7;
}

.reveal-word .word-text {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reveal-word .word-weight {
  font-weight: 700;
  color: var(--gold);
  margin-left: 8px;
  font-size: 0.75rem;
}

.reveal-word:hover {
  filter: brightness(1.15);
}

/* Definition modal */
.define-modal-box {
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px;
}
.define-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 8px;
}
.define-word-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  text-transform: lowercase;
  letter-spacing: -0.5px;
}
.define-phonetic {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}
.define-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.define-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 0 14px;
}
.define-origin {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 14px;
  line-height: 1.5;
  text-align: left;
}
.define-origin::before {
  content: 'origin  ';
  font-style: normal;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-size: 0.65rem;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}
.define-meaning {
  margin-bottom: 14px;
}
.define-meaning:last-child {
  margin-bottom: 0;
}
.define-pos {
  display: inline-block;
  font-size: 0.65rem;
  font-style: italic;
  color: var(--bg);
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 7px;
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.define-def {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 8px;
  padding-left: 12px;
  text-align: left;
  position: relative;
}
.define-def::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.define-def .define-example {
  color: var(--text-muted);
  font-style: italic;
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
}
.define-not-found {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.reveal-col-total {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  padding-top: 8px;
  text-align: center;
}

.reveal-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 22px;
  flex-shrink: 0;
}

.reveal-target-pill {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--gold);
}

.reveal-score {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 16px 0;
}

.reveal-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.reveal-actions .btn-primary {
  flex: 1;
  font-size: 1rem;
  padding: 14px 20px;
}

.btn-share-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-share-icon:hover { background: var(--bg-surface); }

.reveal-secondary-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-text-link:hover { color: var(--text); }
.btn-text-link.highlight { color: var(--green); }

/* ---- Leaderboard ---- */

.leaderboard-container {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.leaderboard-container h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 16px;
}

.my-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: 8px;
  font-size: 0.9rem;
}

.lb-rank {
  width: 32px;
  font-weight: 700;
  text-align: center;
}
.lb-rank.top-3 {
  color: var(--gold);
}

.lb-name {
  flex: 1;
  text-align: left;
  margin-left: 8px;
}

.lb-score {
  font-weight: 700;
  color: var(--green);
}

/* ---- Auth divider ---- */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

/* ---- Claim account ---- */

#claim-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.claim-success {
  text-align: center;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ---- Animations ---- */

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes revealWord {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* Word definition flash strip */
.word-def-flash {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 44px; /* sits just above .beam-info */
  background: rgba(15, 20, 40, 0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 5;
  animation: defFlashIn 0.3s ease forwards;
}
.word-def-flash.hidden {
  display: none;
}
.word-def-flash.fading {
  animation: defFlashOut 0.6s ease forwards;
}
.def-flash-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.def-flash-word {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.def-flash-phonetic {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}
.def-flash-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
@keyframes defFlashIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes defFlashOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}


/* ---- Responsive ---- */

.hidden {
  display: none !important;
}

@media (max-width: 400px) {
  .logo { font-size: 2.4rem; }
  .target-display { font-size: 2.8rem; }
  .reveal-word { font-size: 0.75rem; padding: 5px 8px; }
  .reveal-columns { gap: 4px; }
}
