/* ═══════════════════════════════════════════════════════════════════════
   FIGURAL — Dark Neon Theme
   ═══════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg: #0a0a0f;
  --surface: #13131d;
  --surface2: #1c1c2e;
  --border: #2a2a3e;
  --border-dim: #1e1e30;
  --text: #e0e0ee;
  --text-dim: #6a6a88;
  --cyan: #00f0ff;
  --magenta: #ff00ff;
  --lime: #00ff88;
  --gold: #39ff14;
  --red: #ff4455;
  --cyan-dim: rgba(0, 240, 255, 0.15);
  --magenta-dim: rgba(255, 0, 255, 0.15);
  --lime-dim: rgba(0, 255, 136, 0.15);
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100%;
  padding: 6px 10px;
  gap: 5px;
  overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────────────── */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 4px;
  flex-shrink: 0;
}

#title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 5px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#status {
  display: flex;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  align-items: center;
}

#guesses-left {
  color: var(--text-dim);
}

#word-length-tag {
  color: var(--cyan);
  font-size: 11px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 1px 6px;
  opacity: 0.7;
}

#jackpot {
  color: var(--gold);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.4);
}
#jackpot::after {
  content: ' \1F7E2';
  font-size: 10px;
}

/* ─── Symbol Legend ───────────────────────────────────────────── */

#legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-symbol {
  font-size: 18px;
  line-height: 1;
}

.legend-meaning {
  font-size: 11px;
  font-style: italic;
}

/* ─── Game Board ──────────────────────────────────────────────── */

#board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  overflow-y: auto;
  min-height: 0;
  padding: 4px 0;
}

#board::-webkit-scrollbar { width: 0; }

.guess-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.cell {
  width: 50px;
  height: 50px;
  border: 2px solid var(--border-dim);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}

/* 4-letter words get bigger cells */
.word-len-4 .cell { width: 62px; height: 54px; }
/* 6-letter words get smaller cells */
.word-len-6 .cell { width: 44px; height: 48px; }

.cell.filled {
  border-color: var(--text-dim);
}

.cell.revealed {
  border-color: transparent;
  background: var(--surface2);
}

.cell-letter {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  opacity: 0.7;
}

.cell-symbol {
  font-size: 20px;
  line-height: 1;
  margin-top: 1px;
}

.word-len-6 .cell-letter { font-size: 12px; }
.word-len-6 .cell-symbol { font-size: 17px; }

/* ─── Neon Glow Classes ───────────────────────────────────────── */

.glow-cyan {
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan), 0 0 14px rgba(0,240,255,0.4);
}
.glow-magenta {
  color: var(--magenta);
  text-shadow: 0 0 6px var(--magenta), 0 0 14px rgba(255,0,255,0.4);
}
.glow-lime {
  color: var(--lime);
  text-shadow: 0 0 6px var(--lime), 0 0 14px rgba(0,255,136,0.4);
}

.cell.border-cyan {
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,240,255,0.25), inset 0 0 12px var(--cyan-dim);
}
.cell.border-magenta {
  border-color: var(--magenta);
  box-shadow: 0 0 8px rgba(255,0,255,0.25), inset 0 0 12px var(--magenta-dim);
}
.cell.border-lime {
  border-color: var(--lime);
  box-shadow: 0 0 8px rgba(0,255,136,0.25), inset 0 0 12px var(--lime-dim);
}

/* ─── Guess Wrapper (pfp + row) ──────────────────────────────── */

.guess-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.guess-pfp {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--border);
}

.guess-pfp-placeholder {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

/* ─── Guess Player Tag (legacy, hidden) ──────────────────────── */

.guess-player {
  display: none;
}

/* ─── Message Bar ─────────────────────────────────────────────── */

#message {
  text-align: center;
  font-size: 13px;
  min-height: 18px;
  color: var(--text-dim);
  transition: color 0.2s;
  padding: 2px 0;
  flex-shrink: 0;
}
#message.error { color: var(--red); }
#message.success { color: var(--lime); }

/* ─── Keyboard ────────────────────────────────────────────────── */

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px 0 2px;
  flex-shrink: 0;
}

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.kb-spacer-half { width: 12px; flex-shrink: 0; }

.kb-key {
  min-width: 28px;
  height: 42px;
  border: 1px solid rgba(168,85,247,0.35);
  border-radius: 6px;
  background: rgba(168,85,247,0.15);
  color: #c084fc;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  transition: all 0.15s;
  font-family: inherit;
  flex: 1;
  max-width: 36px;
}

.kb-key:active {
  transform: scale(0.92);
}

.kb-key.kb-wide {
  flex: 1.5;
  max-width: 56px;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.kb-key:hover {
  background: rgba(168,85,247,0.28);
  border-color: rgba(168,85,247,0.55);
}

.kb-key.kb-used {
  background: var(--surface2);
  border-color: transparent;
  color: var(--text-dim);
}

/* ─── Win Overlay ─────────────────────────────────────────────── */

#win-overlay, #fail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s;
}

#win-overlay.hidden, #fail-overlay.hidden {
  display: none;
}

#win-content, #fail-content {
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#win-label {
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

#win-word {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta), var(--lime));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

#win-player {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

#win-jackpot {
  font-size: 24px;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.5);
}

#fail-label {
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--red);
  margin-bottom: 12px;
}

#fail-word {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--text-dim);
}

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

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ─── Cell Animations ─────────────────────────────────────────── */

@keyframes revealFlip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

.cell.revealing {
  animation: revealFlip 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.guess-row.shake-row .cell {
  animation: shake 0.35s ease;
}

@keyframes popCell {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.cell.pop {
  animation: popCell 0.1s ease;
}

/* ─── Overlay mode ────────────────────────────────────────────── */

body.overlay-mode #keyboard { display: none; }
body.overlay-mode #app { padding-bottom: 10px; }
body.overlay-mode #board { flex: 1; }

/* ─── Hub Button ─────────────────────────────────────────────── */

.hub-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.hub-btn:hover {
  color: var(--cyan);
  background: var(--surface2);
}

/* ─── Header Actions (stats + word-size toggle) ──────────────── */

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

.stats-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.stats-toggle-btn:hover,
.stats-toggle-btn.active {
  color: var(--cyan);
  background: var(--surface2);
}

/* ─── Word Size Toggle ───────────────────────────────────────── */

.word-size-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ws-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ws-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.ws-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,240,255,0.12);
  box-shadow: 0 0 8px rgba(0,240,255,0.2);
}

/* ─── Stats Dropdown ─────────────────────────────────────────── */

.stats-dropdown {
  position: absolute;
  top: 44px;
  right: 6px;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: fadeIn 0.15s ease;
}
.stats-dropdown.hidden { display: none; }

.stats-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.stats-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.stats-close:hover { color: var(--text); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.stat-item {
  text-align: center;
  padding: 6px 2px;
  background: var(--surface2);
  border-radius: 6px;
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--cyan);
  line-height: 1.2;
}

.stat-lbl {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ─── Stats History ──────────────────────────────────────────── */

.stats-history {
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.stats-history::-webkit-scrollbar { width: 3px; }
.stats-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.stats-h-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-dim);
  font-size: 11px;
}
.stats-h-entry:last-child { border-bottom: none; }

.stats-h-word {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  flex: 1;
}

.stats-h-guesses {
  color: var(--text-dim);
  margin: 0 8px;
}

.stats-h-result {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
}
.stats-h-result.win { color: var(--lime); }
.stats-h-result.loss { color: var(--red); }

.stats-portal-link {
  display: block;
  text-align: center;
  font-size: 11px;
  color: var(--cyan);
  text-decoration: none;
  padding: 4px 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.stats-portal-link:hover { opacity: 1; }

/* ─── Neon Button (New Game) ─────────────────────────────────── */

.neon-btn {
  padding: 10px 28px;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  background: transparent;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 14px;
  transition: all 0.2s;
  text-shadow: 0 0 6px rgba(0,240,255,0.4);
  box-shadow: 0 0 10px rgba(0,240,255,0.15);
}
.neon-btn:hover {
  background: rgba(0,240,255,0.1);
  box-shadow: 0 0 18px rgba(0,240,255,0.3);
}

/* ─── Win/Fail Overlay Additions (SP) ────────────────────────── */

#win-emoji, #fail-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

#win-info {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

/* ─── MP Login Screen ────────────────────────────────────────── */

.mp-login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: 20px;
}

.mp-login-card {
  text-align: center;
  max-width: 300px;
}

.mp-login-logo {
  font-size: 52px;
  margin-bottom: 8px;
}

.mp-login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.mp-login-card p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 6px;
}

.mp-login-sub {
  font-size: 11px !important;
  margin-bottom: 16px !important;
}

.mp-discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  background: #5865F2;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}
.mp-discord-btn:hover { background: #4752c4; }
.mp-discord-btn:active { transform: scale(0.97); }

.mp-github-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  background: #333;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  font-family: inherit;
}
.mp-github-btn:hover { background: #24292e; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.mp-github-btn:active { transform: scale(0.97); }

.mp-login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.mp-login-divider::before,
.mp-login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.mp-back-link {
  display: block;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.mp-back-link:hover { color: var(--text); }

/* ─── MP Badge ───────────────────────────────────────────────── */

.mp-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,240,255,0.15);
  color: var(--cyan);
  border: 1px solid rgba(0,240,255,0.3);
  flex-shrink: 0;
}

/* ─── MP Guess Count ─────────────────────────────────────────── */

#guess-count {
  color: var(--text-dim);
  font-size: 12px;
}

/* ─── Win Countdown ──────────────────────────────────────────── */

#win-countdown {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ─── Daily Badge ────────────────────────────────────────────── */

.daily-badge {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a1a2e;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: 1px;
  animation: daily-glow 2s ease-in-out infinite alternate;
  white-space: nowrap;
}

@keyframes daily-glow {
  from { box-shadow: 0 0 4px #ffd700; }
  to { box-shadow: 0 0 12px #ff8c00, 0 0 20px rgba(255, 215, 0, 0.25); }
}

/* ─── Frenzy Badge ───────────────────────────────────────────── */

.frenzy-badge {
  background: linear-gradient(135deg, #ff4500, #ff6347);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: 0.5px;
  animation: frenzy-pulse 0.8s ease-in-out infinite alternate;
  white-space: nowrap;
}

.frenzy-label {
  margin-right: 3px;
}

@keyframes frenzy-pulse {
  from { box-shadow: 0 0 4px #ff4500; transform: scale(1); }
  to { box-shadow: 0 0 16px #ff6347, 0 0 24px rgba(255, 69, 0, 0.25); transform: scale(1.05); }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
#board::-webkit-scrollbar { width: 3px; }
#board::-webkit-scrollbar-track { background: transparent; }
#board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════════════════
   SP MODE — Snug 400×700 layout (all 8 rows visible, no scroll)
   ═══════════════════════════════════════════════════════════════════════ */

body.sp-mode #app {
  padding: 4px 8px;
  gap: 3px;
  height: 100vh;
  height: 100dvh;
}

body.sp-mode #header {
  padding: 1px 0 2px;
}

body.sp-mode #title {
  font-size: 16px;
  letter-spacing: 3px;
}

body.sp-mode #legend {
  padding: 2px 0;
  gap: 10px;
}

body.sp-mode .legend-symbol { font-size: 15px; }
body.sp-mode .legend-meaning { font-size: 10px; }

body.sp-mode #board {
  flex: 1;
  overflow: hidden;
  gap: 3px;
  padding: 2px 0;
  min-height: 0;
}

body.sp-mode .guess-row {
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

body.sp-mode .cell {
  width: auto;
  height: auto;
  flex: 1;
  max-width: 50px;
}

/* Override per-length fixed sizes */
body.sp-mode .word-len-4 .cell,
body.sp-mode .word-len-6 .cell {
  width: auto;
  height: auto;
}

body.sp-mode .cell-letter { font-size: 12px; }
body.sp-mode .cell-symbol { font-size: 16px; }
body.sp-mode .word-len-6 .cell-letter { font-size: 11px; }
body.sp-mode .word-len-6 .cell-symbol { font-size: 14px; }

body.sp-mode #message {
  min-height: 16px;
  font-size: 12px;
  padding: 1px 0;
}

body.sp-mode #keyboard {
  gap: 4px;
  padding: 2px 0 2px;
}

body.sp-mode .kb-key {
  height: 38px;
  font-size: 13px;
}

body.sp-mode .kb-key.kb-wide {
  font-size: 11px;
}

body.sp-mode .ws-cycle {
  width: 30px;
  height: 30px;
  font-size: 15px;
}
