/* =====================================================
   LEXARENA — style.css
   ===================================================== */

/* ─── RESET & BASE ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0E0E12;
  --surface:   #16161E;
  --tile:      #1C2140;
  --tile-edge: #2A3160;
  --active:    #F5A623;
  --found:     #3DDC84;
  --text:      #E8ECF4;
  --text-dim:  #7B849C;
  --danger:    #FF5B5B;
  --rare:      #FF9500;
  --amber:     #F5A623;
  --radius:    12px;
  --cell-size: clamp(60px, 18vw, 84px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── SCREENS ───────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
}

.hidden { display: none !important; }

/* ─── MENU ──────────────────────────────────────────── */
#menu-screen {
  justify-content: center;
  gap: 32px;
}

.menu-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.logo-title {
  font-family: 'Space Mono', monospace;
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
}

.logo-title span {
  color: var(--amber);
}

.logo-sub {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.logo-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 120px;
  margin-top: 8px;
  opacity: 0.35;
}

.logo-tile {
  aspect-ratio: 1;
  background: var(--tile);
  border: 1px solid var(--tile-edge);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
}

/* Mode grid */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

.mode-btn {
  background: var(--tile);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  color: var(--text);
}

.mode-btn:hover, .mode-btn:focus {
  border-color: var(--amber);
  background: #1f2545;
  outline: none;
}

.mode-btn:active { transform: scale(0.97); }

.mode-btn.daily {
  grid-column: span 2;
  flex-direction: row;
  align-items: center;
  background: linear-gradient(135deg, #1a1f35 0%, #2a1f35 100%);
  border-color: #6a3fa0;
}

.mode-emoji { font-size: 22px; }
.mode-name { font-weight: 700; font-size: 15px; }
.mode-desc { font-size: 12px; color: var(--text-dim); }

/* Bottom actions */
.menu-footer {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--tile-edge);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }

/* ─── GAME SCREEN ───────────────────────────────────── */
#game-screen {
  justify-content: flex-start;
  gap: 12px;
  padding-top: 16px;
}

/* HUD */
.hud {
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-left { display: flex; gap: 6px; align-items: center; }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: 8px;
  color: var(--text-dim);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 18px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--text-dim); }

.hud-score-wrap {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: 8px;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

#hud-score {
  font-family: 'Space Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--amber);
}

.hud-score-label { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }

.hud-timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

#hud-timer {
  font-family: 'Space Mono', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  transition: color 0.3s;
}

#hud-timer.urgent {
  color: var(--danger);
  animation: pulse-timer 0.5s infinite alternate;
}

@keyframes pulse-timer {
  from { opacity: 1; }
  to   { opacity: 0.5; }
}

#hud-words {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Current word display */
.current-word-wrap {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#current-word {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: 0 0 20px rgba(245,166,35,0.5);
  min-height: 1em;
  transition: text-shadow 0.2s;
}

/* Board */
.board-wrap {
  position: relative;
  width: fit-content;
}

#board-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--cell-size));
  grid-template-rows: repeat(4, var(--cell-size));
  gap: 6px;
  position: relative;
  z-index: 1;
}

.cell {
  background: var(--tile);
  border: 2px solid var(--tile-edge);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-family: 'Space Mono', monospace;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s, box-shadow 0.12s;
  touch-action: none;
  position: relative;
  z-index: 2;
}

.cell.active {
  background: #2a2f58;
  border-color: var(--amber);
  color: var(--amber);
  transform: scale(1.07);
  box-shadow: 0 0 18px rgba(245,166,35,0.45);
  z-index: 4;
}

.cell.found-flash {
  background: rgba(61,220,132,0.22);
  border-color: var(--found);
  color: var(--found);
  animation: flash-green 0.55s ease-out forwards;
}

@keyframes flash-green {
  0%   { transform: scale(1.1); }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* SVG path overlay */
#path-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.drag-line {
  fill: none;
  stroke: var(--amber);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
  filter: drop-shadow(0 0 8px rgba(245,166,35,0.7));
}

/* Floating score */
.float-score {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--found);
  pointer-events: none;
  z-index: 10;
  animation: float-up 0.85s ease-out forwards;
  white-space: nowrap;
}

.float-score.rare { color: var(--rare); font-size: 22px; }
.float-score.invalid { color: var(--danger); font-size: 16px; }

@keyframes float-up {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* Word list */
.word-list-wrap {
  width: 100%;
  max-width: 380px;
  max-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--tile-edge) transparent;
}

#word-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 0;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 13px;
  animation: pop-in 0.2s ease-out;
}

.word-item.rare {
  border-color: var(--rare);
  background: rgba(255,149,0,0.1);
}

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

.wl-word { font-weight: 700; font-family: 'Space Mono', monospace; font-size: 12px; }
.wl-pts  { color: var(--amber); font-size: 11px; }

/* Round banner */
.round-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: 16px;
  padding: 20px 40px;
  font-family: 'Space Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--amber);
  z-index: 100;
  animation: fade-in-out 1.5s ease-out forwards;
  pointer-events: none;
}

@keyframes fade-in-out {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── RESULT SCREEN ─────────────────────────────────── */
#result-screen {
  justify-content: center;
  gap: 20px;
  max-width: 420px;
  margin: 0 auto;
}

.result-header {
  text-align: center;
}

.result-title {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.result-medal {
  font-size: 48px;
  line-height: 1;
}

#res-medal {
  font-size: clamp(32px, 8vw, 52px);
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  color: var(--amber);
  margin-top: 6px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-card.wide { grid-column: span 2; }

.stat-val {
  font-family: 'Space Mono', monospace;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  color: var(--text);
}

.stat-val.highlight { color: var(--amber); }
.stat-val.rare-val  { color: var(--rare); font-size: 16px; }

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Missed words */
.missed-section {
  width: 100%;
}

.missed-title {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#res-missed {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.missed-word {
  background: rgba(255,91,91,0.08);
  border: 1px solid rgba(255,91,91,0.25);
  border-radius: 5px;
  padding: 3px 8px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--danger);
}

.missed-more {
  font-size: 11px;
  color: var(--text-dim);
  align-self: center;
}

/* Share */
.share-section { width: 100%; }

#res-share-text {
  display: none;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.btn-primary {
  background: var(--amber);
  color: #0E0E12;
  border: none;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.5px;
}

.btn-primary:hover   { opacity: 0.9; }
.btn-primary:active  { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
}

.btn-secondary:hover  { border-color: var(--text-dim); }

.result-row { display: flex; gap: 8px; }
.result-row .btn-secondary { flex: 1; }
.result-row .btn-ghost { flex: 1; }

/* ─── STATS MODAL ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  position: relative;
}

.modal-title {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: 1px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stats-item {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.stats-num {
  font-family: 'Space Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--amber);
}

.stats-lbl {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.modal-close {
  width: 100%;
  background: transparent;
  border: 1px solid var(--tile-edge);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.15s, border-color 0.15s;
}

.modal-close:hover { color: var(--text); border-color: var(--text-dim); }

/* ─── SCROLLBAR ─────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tile-edge); border-radius: 4px; }

/* ─── MENU FOOTER (wrap em telas pequenas) ──────────── */
.menu-footer {
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── PAGES (créditos / configurações) ──────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 4px;
}

.page-title {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

/* ─── CRÉDITOS ──────────────────────────────────────── */
#credits-screen {
  justify-content: flex-start;
  gap: 0;
  max-width: 420px;
  margin: 0 auto;
}

.credits-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.credits-section {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credits-section h3 {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.credits-section p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.credits-section strong {
  color: var(--amber);
}

.credits-link {
  color: var(--amber);
  font-size: 14px;
  word-break: break-all;
  text-decoration: none;
}
.credits-link:hover { text-decoration: underline; }

.credits-note {
  font-size: 12px !important;
  color: var(--text-dim) !important;
  margin-top: 2px;
}

.credits-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 0.5px;
}

/* ─── CONFIGURAÇÕES ─────────────────────────────────── */
#settings-screen {
  justify-content: flex-start;
  gap: 0;
  max-width: 420px;
  margin: 0 auto;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.settings-item {
  background: var(--surface);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-item.danger-zone {
  border-color: rgba(255, 91, 91, 0.3);
}

.settings-item-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-item-label > span:first-child {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-dim);
}

.theme-toggle {
  display: flex;
  gap: 3px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  flex-shrink: 0;
}

.theme-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.theme-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(255,91,91,0.4);
  border-radius: 8px;
  color: var(--danger);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-danger:hover { background: rgba(255,91,91,0.1); }

.clear-confirm {
  background: rgba(255,91,91,0.05);
  border: 1px solid rgba(255,91,91,0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clear-confirm p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.clear-confirm-actions {
  display: flex;
  gap: 8px;
}

.clear-confirm-actions .btn-secondary,
.clear-confirm-actions .btn-danger {
  flex: 1;
  text-align: center;
}

/* ─── TEMA CLARO ────────────────────────────────────── */
body.theme-light {
  --bg:        #F0F2F8;
  --surface:   #FFFFFF;
  --tile:      #E2E6F0;
  --tile-edge: #BDC4D4;
  --active:    #D4891A;
  --found:     #1A9A5A;
  --text:      #1A1C2E;
  --text-dim:  #6B7080;
  --danger:    #DC2626;
  --rare:      #B45309;
  --amber:     #D4891A;
}

body.theme-light .mode-btn:hover,
body.theme-light .mode-btn:focus {
  background: #d4d8ea;
}

body.theme-light .mode-btn.daily {
  background: linear-gradient(135deg, #dce0f0 0%, #e4d8f0 100%);
  border-color: #8a60c0;
}

body.theme-light .cell.active {
  background: #f0d880;
  border-color: var(--amber);
  color: #1A1C2E;
  box-shadow: 0 0 14px rgba(212,137,26,0.35);
}

body.theme-light .stats-item {
  background: var(--tile);
}

/* ─── RESPONSIVE ────────────────────────────────────── */
@media (min-width: 600px) {
  #game-screen {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 32px;
  }

  .game-col-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .game-col-right {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 4px;
  }

  .word-list-wrap {
    max-height: 340px;
  }
}

/* ─── REDUCED MOTION ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
