:root {
  --bg-deep: #15092b;
  --bg-panel: rgba(34, 17, 68, 0.88);
  --bg-card: rgba(49, 25, 94, 0.78);
  --border-soft: rgba(168, 85, 247, 0.28);
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-gold: #fbbf24;
  --accent-green: #22c55e;
  --accent-cyan: #38bdf8;
  --accent-red: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --font-display: 'Fredoka', 'Space Grotesk', sans-serif;
  --font-sans: 'Inter', system-ui, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #311263 0%, #140829 70%, #0b0418 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 360px;
  height: 360px;
  background: rgba(168, 85, 247, 0.22);
  top: -100px;
  left: -80px;
}
.bg-glow-2 {
  width: 360px;
  height: 360px;
  background: rgba(236, 72, 153, 0.16);
  bottom: -100px;
  right: -80px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 12px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 7px 12px;
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

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

.brand-badge {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

/* Goal & Level Container (Official WOS style) */
.goal-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.goal-box {
  position: relative;
  overflow: hidden;
  background: rgba(15, 7, 34, 0.8);
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 4px 12px;
  min-width: 210px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.goal-box.unlocked {
  border-color: var(--accent-gold);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
}

.goal-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.28), rgba(168, 85, 247, 0.35));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.goal-box.unlocked .goal-bar-fill {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.32), rgba(34, 197, 94, 0.35));
}

.goal-box-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.goal-lock-icon {
  font-size: 1.05rem;
}

.goal-metric {
  display: flex;
  flex-direction: column;
}

.goal-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}

.goal-val {
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: #fff;
}

.goal-box.unlocked .goal-val {
  color: var(--accent-gold);
}

.goal-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.16);
}

.level-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 5px 10px;
}

.hud-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.hud-val {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--accent-gold);
}

.record-pill .hud-val {
  color: var(--accent-cyan);
}

.hearts-pill .hud-val {
  font-size: 0.82rem;
  letter-spacing: 1px;
}

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

.room-pill-quick {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #fff;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.76rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s ease;
}
.room-pill-quick:hover {
  background: rgba(56, 189, 248, 0.28);
}
.room-pill-quick strong {
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
}

.btn-top-go {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
  animation: pulseGreen 1.5s infinite alternate;
}

@keyframes pulseGreen {
  from { transform: scale(1); box-shadow: 0 0 8px rgba(34, 197, 94, 0.35); }
  to { transform: scale(1.04); box-shadow: 0 0 16px rgba(34, 197, 94, 0.65); }
}

.btn-sound {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-drawer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn-drawer-toggle:hover {
  background: rgba(168, 85, 247, 0.3);
}

.badge-count {
  background: var(--accent-gold);
  color: #1e1b4b;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
}

/* Room & Options Drawer */
.room-drawer {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(14px);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 14px;
}

.drawer-col h3 {
  font-size: 0.84rem;
  color: var(--accent-gold);
  margin-bottom: 8px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.field-row input,
.opt-item select {
  width: 100%;
  background: rgba(15, 7, 32, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.autopilot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-right: 6px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 5px 10px; font-size: 0.76rem; }
.btn-lg { padding: 10px 20px; font-size: 0.95rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
}
.btn-ghost {
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.btn-danger {
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.room-status {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.opt-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Stage Layout */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 10px;
  min-height: 0;
}

.board-panel {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  transition: box-shadow 0.3s, border-color 0.3s;
}

/* Lobby / Waiting Room Overlay */
.lobby-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 6, 32, 0.94);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.lobby-overlay[hidden],
.lobby-overlay.is-hidden {
  display: none !important;
}

.lobby-card {
  background: linear-gradient(180deg, #2b125a 0%, #160836 100%);
  border: 2px solid rgba(168, 85, 247, 0.45);
  border-radius: 20px;
  padding: 22px 24px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lobby-badge {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.lobby-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: #fff;
}

.lobby-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lobby-room-info {
  background: rgba(13, 5, 28, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 14px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  flex-wrap: wrap;
}

.lobby-room-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
}

.lobby-room-code {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--accent-gold);
  letter-spacing: 0.06em;
}

.lobby-roster-box {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
}

.lobby-roster-box h4 {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.lobby-players-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lobby-player-tag {
  background: rgba(168, 85, 247, 0.22);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lobby-player-tag.is-host {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.16);
}

.lobby-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-go-pulse {
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.45);
  animation: pulseGreen 1.4s infinite alternate;
  width: 100%;
  font-family: var(--font-display);
  font-size: 1.05rem;
  padding: 12px 24px;
  border-radius: 12px;
}

.guest-waiting-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--accent-gold);
}

.spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-gold);
  animation: pulseDot 0.8s infinite alternate;
}

@keyframes pulseDot {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

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

.board-panel.flash-hit {
  box-shadow: inset 0 0 28px rgba(251, 191, 36, 0.25);
  border-color: rgba(251, 191, 36, 0.65);
}

.board-panel.flash-hitmax {
  box-shadow: inset 0 0 36px rgba(56, 189, 248, 0.38);
  border-color: var(--accent-cyan);
}

/* Timer Bar with Official WOS Padlock Checkpoints */
.timer-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-track {
  position: relative;
  flex: 1;
  height: 12px;
  background: rgba(15, 7, 32, 0.85);
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.32);
  overflow: visible;
}

.timer-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a855f7, #ec4899, #fbbf24);
  transition: width 0.35s linear;
}

.timer-fill.danger {
  background: linear-gradient(90deg, #ef4444, #f97316);
  animation: pulseDanger 0.7s infinite alternate;
}

@keyframes pulseDanger {
  from { opacity: 0.75; }
  to { opacity: 1; }
}

.timer-locks-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timer-lock-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2e1065;
  border: 2px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s, background 0.25s, border-color 0.25s;
}

.timer-lock-node.opened {
  background: rgba(34, 197, 94, 0.25);
  border-color: var(--accent-green);
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0.65;
}

.timer-meta-pill {
  background: rgba(15, 7, 32, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.timer-meta-pill strong {
  color: #fff;
  font-family: var(--font-display);
}

/* Words Grid (Slots) */
.words-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 7px 10px;
  align-content: start;
  overflow-y: auto;
  padding: 4px 2px;
  max-height: 44vh;
}

.word-slot {
  background: rgba(20, 10, 42, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.24);
  border-radius: 10px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.word-slot.hitmax-slot {
  border-color: rgba(56, 189, 248, 0.48);
  background: linear-gradient(135deg, rgba(14, 42, 74, 0.55), rgba(30, 15, 64, 0.8));
}

.word-slot.solved {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.65), rgba(49, 16, 94, 0.88));
  border-color: rgba(251, 191, 36, 0.6);
  animation: popSlot 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.word-slot.solved.hitmax-slot {
  background: linear-gradient(135deg, rgba(3, 105, 161, 0.75), rgba(59, 7, 100, 0.9));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.word-slot.expired-slot {
  background: rgba(30, 15, 50, 0.55);
  border-color: rgba(244, 63, 94, 0.45);
  opacity: 0.82;
}

@keyframes popSlot {
  0% { transform: scale(0.93); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.slot-boxes {
  display: flex;
  gap: 3px;
}

.slot-char {
  width: 22px;
  height: 25px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: transparent;
  user-select: none;
}

.word-slot.hitmax-slot .slot-char {
  border-color: rgba(56, 189, 248, 0.38);
}

.slot-char.hint-revealed {
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.14);
}

.word-slot.solved .slot-char {
  background: linear-gradient(180deg, #f59e0b, #d97706);
  border-color: #fde68a;
  color: #1e1b4b;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.word-slot.solved.hitmax-slot .slot-char {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-color: #bae6fd;
  color: #082f49;
}

.word-slot.expired-slot .slot-char {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.slot-finder {
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--accent-gold);
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* Official WOS Anagram Stage (Wheel Dock) */
.wheel-dock {
  background: linear-gradient(180deg, rgba(46, 16, 101, 0.88), rgba(24, 9, 54, 0.95));
  border: 2px solid rgba(168, 85, 247, 0.42);
  border-radius: 16px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.wheel-dock.goal-achieved {
  border-color: var(--accent-gold);
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.22);
}

.anagram-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(13, 5, 28, 0.82);
  border: 1px solid rgba(168, 85, 247, 0.32);
  border-radius: 999px;
  padding: 5px 12px;
}

.neon-lamps {
  display: flex;
  align-items: center;
  gap: 4px;
}

.neon-lamps span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.35);
  transition: background 0.25s, box-shadow 0.25s;
}

.wheel-dock.goal-achieved .neon-lamps span {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
  animation: lampPulse 0.9s infinite alternate;
}

@keyframes lampPulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.feedback-marquee {
  flex: 1;
  text-align: center;
  overflow: hidden;
}

.feedback-text {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #e9d5ff;
}

.feedback-text strong[data-color="red"] {
  color: #fb7185;
  text-decoration: underline;
}

.feedback-text strong[data-color="yellow"] {
  color: var(--accent-gold);
}

.feedback-text strong[data-color="cyan"] {
  color: var(--accent-cyan);
}

.feedback-text strong[data-color="green"] {
  color: #4ade80;
}

.anagram-tiles-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2px 0;
}

.letter-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.letter-tile {
  position: relative;
  width: 52px;
  height: 58px;
  border-radius: 13px;
  background: linear-gradient(180deg, #ffffff 0%, #ede9fe 100%);
  border: 2px solid #c4b5fd;
  box-shadow: 0 4px 0 #5b21b6, 0 6px 12px rgba(0, 0, 0, 0.38);
  color: #2e1065;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.25s;
}

.letter-tile:hover {
  transform: translateY(-2px);
}
.letter-tile:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #5b21b6;
}

.letter-tile.shuffle-flip {
  animation: tileSlotFlip 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tileSlotFlip {
  0% { transform: translateY(0) rotateX(0deg) scale(1); }
  45% { transform: translateY(-8px) rotateX(85deg) scale(0.92); }
  100% { transform: translateY(0) rotateX(0deg) scale(1); }
}

.tile-points {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #6d28d9;
  line-height: 1;
}

/* Mystery / Hidden Letter (?1, ?2) */
.letter-tile.mystery-tile {
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  border-color: #fde047;
  box-shadow: 0 4px 0 #b45309, 0 0 14px rgba(251, 191, 36, 0.4);
  color: #451a03;
}
.letter-tile.mystery-tile .tile-points {
  color: #78350f;
}

/* Revealed Fake Letter (Red X Invalid) */
.letter-tile.fake-revealed {
  background: linear-gradient(180deg, #fecdd3 0%, #f43f5e 100%);
  border-color: #fda4af;
  box-shadow: 0 3px 0 #9f1239;
  color: #fff;
  opacity: 0.72;
  text-decoration: line-through;
}
.letter-tile.fake-revealed::after {
  content: 'FALSA';
  position: absolute;
  top: -7px;
  right: -6px;
  background: #be123c;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.anagram-subbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.bonus-pill {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--accent-gold);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.jump-hint {
  color: var(--accent-cyan);
}

/* Guess Input Bar */
.guess-bar {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
}

.cooldown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 8, 42, 0.94);
  border: 1px solid var(--accent-gold);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--accent-gold);
  z-index: 4;
}

.guess-input {
  flex: 1;
  background: rgba(13, 6, 28, 0.9);
  border: 2px solid rgba(168, 85, 247, 0.45);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.guess-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.btn-clear-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  cursor: pointer;
}

.btn-submit-guess {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.guess-feedback-toast {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 5px 12px;
  border-radius: 10px;
  margin-top: 6px;
  pointer-events: none;
  animation: fadeInDown 0.18s ease;
}

.guess-feedback-toast[hidden] {
  display: none !important;
}

.input-shake {
  animation: shakeX 0.35s ease;
  border-color: #ef4444 !important;
}

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

/* Sidebar: Players & Feed */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.card-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.players-section {
  flex: 1;
  min-height: 150px;
}

.feed-section {
  flex: 1;
  min-height: 150px;
}

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

.section-header h2 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: #fff;
}

.pill-subtle {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 8px;
  border-radius: 999px;
}

.players-list,
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 210px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.player-row.is-me {
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.14);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rank-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-gold);
  width: 18px;
}

.player-nick {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.75rem;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.feed-item.feed-hit {
  background: rgba(34, 197, 94, 0.15);
  border-left: 3px solid var(--accent-green);
}
.feed-item.feed-hitmax {
  background: rgba(56, 189, 248, 0.22);
  border-left: 3px solid var(--accent-cyan);
}
.feed-item.feed-bonus {
  background: rgba(251, 191, 36, 0.15);
  border-left: 3px solid var(--accent-gold);
}
.feed-item.feed-miss {
  opacity: 0.7;
}

/* Official WOS Interval / Win / GameOver Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 24, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}

.modal-backdrop[hidden],
.modal-backdrop.is-hidden {
  display: none !important;
}

.modal-card {
  background: linear-gradient(180deg, #2b125a 0%, #170836 100%);
  border: 2px solid rgba(168, 85, 247, 0.55);
  border-radius: 20px;
  padding: 18px 20px;
  max-width: 620px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.65);
  max-height: 92dvh;
  overflow-y: auto;
}

.modal-card.win-3 {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 38px rgba(56, 189, 248, 0.35);
}

.modal-card.win-2 {
  border-color: var(--accent-gold);
}

.modal-stars {
  font-size: 1.55rem;
  margin-bottom: 4px;
}

.modal-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-gold), #f97316);
  color: #1e1b4b;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-bottom: 4px;
  color: #fff;
}

.modal-card p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.next-level-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
  font-size: 0.78rem;
}
.next-level-banner strong {
  font-family: var(--font-display);
  color: var(--accent-cyan);
  font-size: 0.92rem;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.76rem;
}
.stat-chip strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--accent-gold);
}

.modal-dual-rankings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
  text-align: left;
}

.modal-rkg-box {
  background: rgba(13, 5, 28, 0.65);
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-radius: 12px;
  padding: 8px 10px;
}

.modal-rkg-box h4 {
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--accent-gold);
  margin-bottom: 6px;
  text-align: center;
}

.modal-rkg-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 110px;
  overflow-y: auto;
}

.modal-rkg-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.missed-words-box {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.missed-words-box h4 {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.missed-words-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
.missed-word-tag {
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
  font-family: var(--font-display);
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.autopilot-countdown {
  display: inline-block;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.78rem;
  margin-left: 4px;
}

/* Mobile Responsive Adjustments */
@media (max-width: 860px) {
  .drawer-grid {
    grid-template-columns: 1fr;
  }
  .options-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stage {
    grid-template-columns: 1fr;
  }
  .sidebar-panel {
    flex-direction: row;
  }
  .players-section,
  .feed-section {
    flex: 1;
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding: 5px 6px;
    gap: 5px;
  }
  .topbar {
    padding: 5px 8px;
    gap: 6px;
  }
  .brand h1 {
    font-size: 0.88rem;
  }
  .goal-box {
    min-width: 170px;
    padding: 3px 8px;
  }
  .goal-val {
    font-size: 0.8rem;
  }
  .level-pill {
    padding: 3px 7px;
  }
  .hud-val {
    font-size: 0.82rem;
  }
  .words-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    max-height: 35dvh;
  }
  .slot-char {
    width: 18px;
    height: 21px;
    font-size: 0.72rem;
  }
  .letter-tile {
    width: 42px;
    height: 48px;
    font-size: 1.25rem;
    border-radius: 10px;
  }
  .anagram-subbar {
    font-size: 0.65rem;
  }
  .sidebar-panel {
    flex-direction: column;
    gap: 6px;
  }
  .players-list,
  .feed-list {
    max-height: 110px;
  }
  .modal-dual-rankings {
    grid-template-columns: 1fr;
  }
}
