/* ============================================
   WORDLE NEON EDITION — styles.css
   Palette: Volcanic Glass + Acid Neon accents
   Fonts: Syne (display) + Space Mono (tiles)
   ============================================ */

:root {
  --bg:          #0d0d0f;
  --bg2:         #13131a;
  --bg3:         #1a1a26;
  --surface:     #1e1e2e;
  --surface2:    #252538;
  --border:      #2e2e45;
  --text:        #e8e6f0;
  --text-muted:  #6b6b8a;
  --text-dim:    #3a3a55;

  /* Tile states */
  --correct:     #39d353;
  --correct-bg:  #0f3320;
  --correct-glow:#39d353;
  --present:     #f5c518;
  --present-bg:  #332d00;
  --present-glow:#f5c518;
  --absent:      #3a3a55;
  --absent-bg:   #1a1a26;

  /* Neon accents */
  --neon-pink:   #ff3cac;
  --neon-cyan:   #00f5ff;
  --neon-green:  #39d353;
  --neon-yellow: #f5c518;
  --neon-purple: #b06aff;

  --radius:      8px;
  --tile-size:   clamp(48px, 11vw, 62px);
  --tile-gap:    clamp(4px, 1vw, 6px);
  --font-display: 'Syne', sans-serif;
  --font-mono:    'Space Mono', monospace;

  --transition: 0.2s ease;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* LIGHT THEME */
body.light {
  --bg:          #f5f5f7;
  --bg2:         #ebebef;
  --bg3:         #e0e0e8;
  --surface:     #ffffff;
  --surface2:    #f0f0f5;
  --border:      #d0d0e0;
  --text:        #1a1a2e;
  --text-muted:  #6b6b8a;
  --text-dim:    #b0b0c8;
  --absent:      #b0b0c8;
  --absent-bg:   #e0e0e8;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  overflow-x: hidden;
  transition: background 0.4s, color 0.4s;
}

/* ===== PARTICLE CANVAS ===== */
#particles-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 120px;
}
.header-right { justify-content: flex-end; }

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text);
  text-shadow: 0 0 20px rgba(176, 106, 255, 0.5);
  line-height: 1;
}
.logo-dot { color: var(--neon-pink); }

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ff3cac22, #f5c51822);
  border: 1px solid #ff3cac44;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--neon-yellow);
  letter-spacing: 0.05em;
}
.streak-badge svg { width: 12px; height: 12px; fill: var(--neon-pink); }
.streak-badge.pulse { animation: streakPulse 0.6s var(--bounce); }

@keyframes streakPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Icon buttons */
.icon-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--text); background: var(--surface); }

.hard-mode-btn { color: var(--text-muted); }
.hard-mode-btn.active { color: var(--neon-pink); text-shadow: 0 0 8px var(--neon-pink); }
.hard-mode-btn.active svg { filter: drop-shadow(0 0 4px var(--neon-pink)); }
.hard-label { font-size: 9px; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 10px 20px;
  border-radius: 24px;
  animation: toastIn 0.3s var(--bounce) forwards;
  pointer-events: none;
  white-space: nowrap;
}
.toast.out { animation: toastOut 0.3s ease forwards; }
.toast.error { background: var(--neon-pink); color: #fff; }
.toast.success { background: var(--neon-green); color: #000; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ===== MAIN ===== */
.main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 24px;
  gap: 12px;
  min-height: calc(100vh - 56px);
}

/* ===== TIMER BAR ===== */
.timer-bar-wrap {
  width: 100%;
  max-width: 360px;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  display: none;
}
.timer-bar-wrap.active { display: flex; align-items: center; }

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
  border-radius: 3px;
  transition: width 1s linear, background 1s;
  transform-origin: left;
}
.timer-bar.warning { background: linear-gradient(90deg, var(--neon-yellow), var(--neon-pink)); }
.timer-bar.danger  { background: linear-gradient(90deg, var(--neon-pink), #ff0000); animation: timerPulse 0.5s infinite alternate; }

.timer-label {
  position: absolute;
  right: 0;
  top: -18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

@keyframes timerPulse {
  from { opacity: 1; }
  to   { opacity: 0.5; }
}

/* ===== BOARD ===== */
.board-section { display: flex; justify-content: center; }

.board {
  display: grid;
  grid-template-rows: repeat(6, var(--tile-size));
  grid-template-columns: repeat(5, var(--tile-size));
  gap: var(--tile-gap);
}

/* ===== TILES ===== */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: default;
  user-select: none;
  position: relative;
  transition: border-color 0.1s, background 0.1s;
  transform-style: preserve-3d;
}

/* Empty tile */
.tile.empty { border-color: var(--text-dim); }

/* Filled (typed but not submitted) */
.tile.filled {
  border-color: var(--text-muted);
  animation: tilePop 0.1s var(--bounce);
}

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

/* Flip animation */
.tile.flip {
  animation: tileFlip 0.5s ease forwards;
}

@keyframes tileFlip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}

/* Revealed states */
.tile.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  box-shadow: 0 0 12px var(--correct-glow), inset 0 0 8px rgba(57,211,83,0.1);
}
.tile.present {
  background: var(--present-bg);
  border-color: var(--present);
  color: var(--present);
  box-shadow: 0 0 12px var(--present-glow), inset 0 0 8px rgba(245,197,24,0.1);
}
.tile.absent {
  background: var(--absent-bg);
  border-color: var(--absent);
  color: var(--text-muted);
}

/* Hint tile */
.tile.hint-revealed {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-cyan);
  animation: hintGlow 1s ease infinite alternate;
}
@keyframes hintGlow {
  from { box-shadow: 0 0 8px var(--neon-cyan); }
  to   { box-shadow: 0 0 24px var(--neon-cyan), 0 0 40px rgba(0,245,255,0.3); }
}

/* Shake (invalid word) */
.tile.shake { animation: tileShake 0.5s ease; }
@keyframes tileShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* Win bounce */
.tile.bounce { animation: tileBounce 0.6s var(--bounce); }
@keyframes tileBounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-18px); }
  70%  { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

/* ===== HINT ROW ===== */
.hint-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.hint-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  border-radius: 24px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 0 8px rgba(0,245,255,0.2);
}
.hint-btn svg { width: 14px; height: 14px; }
.hint-btn:hover {
  background: rgba(0,245,255,0.1);
  box-shadow: 0 0 16px rgba(0,245,255,0.4);
  transform: translateY(-1px);
}
.hint-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.hint-cost { font-size: 10px; opacity: 0.7; }

.hints-left {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== KEYBOARD ===== */
.keyboard-section { width: 100%; max-width: 500px; }

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

.key-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.key {
  height: clamp(44px, 8vw, 56px);
  min-width: clamp(28px, 6vw, 40px);
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.key::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.1s;
}
.key:active::after { opacity: 0.08; }

.key.wide { min-width: clamp(48px, 10vw, 66px); font-size: clamp(9px, 2vw, 12px); }

.key.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  box-shadow: 0 0 8px rgba(57,211,83,0.4);
}
.key.present {
  background: var(--present-bg);
  border-color: var(--present);
  color: var(--present);
  box-shadow: 0 0 8px rgba(245,197,24,0.4);
}
.key.absent {
  background: var(--absent-bg);
  border-color: var(--absent);
  color: var(--text-dim);
}
.key:hover:not(.correct):not(.present):not(.absent) {
  background: var(--surface);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s var(--bounce);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.rules-list li::before { content: '→ '; color: var(--neon-cyan); }

.example-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 8px;
}
.ex-tile {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.ex-tile.correct { background: var(--correct-bg); border-color: var(--correct); color: var(--correct); }
.ex-tile.present { background: var(--present-bg); border-color: var(--present); color: var(--present); }
.ex-tile.absent  { background: var(--absent-bg);  border-color: var(--absent);  color: var(--text-muted); }

.ex-desc {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.modal-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

/* STATS MODAL */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
}
.stat-num {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--neon-cyan);
  line-height: 1;
}
.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
}

.dist-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}

.dist-chart { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.dist-num { width: 14px; text-align: right; color: var(--text-muted); }
.dist-bar-wrap { flex: 1; height: 22px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.dist-bar {
  height: 100%;
  background: var(--surface2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 24px;
  transition: width 0.8s var(--bounce);
}
.dist-bar.highlight {
  background: linear-gradient(90deg, var(--correct-bg), var(--correct));
  color: var(--correct);
  box-shadow: 0 0 8px rgba(57,211,83,0.3);
}

.next-word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.next-timer { display: flex; flex-direction: column; gap: 2px; }
.next-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-muted); }
.next-countdown { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--text); }

/* RESULT MODAL */
.modal-result { text-align: center; }
.result-emoji { font-size: 52px; margin-bottom: 8px; animation: emojiDrop 0.5s var(--bounce); }
@keyframes emojiDrop {
  from { transform: translateY(-30px) scale(0.5); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.result-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-word { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.result-word strong { color: var(--text); font-family: var(--font-mono); }

.result-stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}
.r-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.r-stat span {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--neon-yellow);
}
.r-stat small { font-size: 10px; color: var(--text-muted); letter-spacing: 0.06em; }

.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* SHARE BUTTON */
.share-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--neon-green), var(--neon-cyan));
  border: none;
  color: #000;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 12px 24px;
  border-radius: 30px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(57,211,83,0.3);
}
.share-btn svg { width: 16px; height: 16px; }
.share-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(57,211,83,0.5); }

.play-again-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 12px 24px;
  border-radius: 30px;
  cursor: pointer;
  transition: all var(--transition);
}
.play-again-btn:hover { background: var(--surface); border-color: var(--text-muted); transform: translateY(-2px); }

/* ===== CONFETTI CANVAS ===== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
  :root { --tile-size: 46px; --tile-gap: 4px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-height: 700px) {
  .main { gap: 8px; padding: 8px 16px 16px; }
  :root { --tile-size: 48px; }
}

/* ===== GLOW PULSE on active row ===== */
.tile.active-row {
  box-shadow: 0 0 0 1px rgba(176,106,255,0.2);
}

/* ===== COMBO FLASH ===== */
@keyframes comboFlash {
  0%   { background: rgba(176,106,255,0.3); }
  100% { background: transparent; }
}
.combo-flash { animation: comboFlash 0.4s ease; }