:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --text2: #888;
  --green: #538d4e;
  --green-bright: #6aaa64;
  --yellow: #b59f3b;
  --yellow-bright: #c9b458;
  --grey: #3a3a3c;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --tile-border: #565758;
  --gold: #f59e0b;
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --red: #ef4444;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* NAV */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.nav-logo span { color: var(--green-bright); }
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  color: var(--text2);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface2); }

/* HERO */
.hero {
  text-align: center;
  padding: 40px 20px 24px;
}
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; line-height: 1.2; }
.hero h1 span { color: var(--green-bright); }
.hero p { color: var(--text2); margin-top: 10px; font-size: 1rem; }

/* STREAK BANNER */
.streak-banner {
  background: linear-gradient(135deg, #1a1a0a, #2a1f00);
  border: 1px solid #3d3000;
  border-radius: 12px;
  margin: 0 20px 24px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.streak-info { display: flex; align-items: center; gap: 12px; }
.streak-fire { font-size: 2rem; }
.streak-count { font-size: 2rem; font-weight: 800; color: var(--gold); }
.streak-label { font-size: 0.8rem; color: var(--text2); }
.streak-today { font-size: 0.75rem; color: var(--text2); }
.streak-games { display: flex; gap: 8px; }
.game-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  border: 2px solid var(--border);
  background: var(--surface);
}
.game-dot.done { background: var(--green); border-color: var(--green); }
.game-dot.partial { background: var(--yellow); border-color: var(--yellow); }

/* GAME GRID */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 20px 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.game-card:hover { border-color: var(--green-bright); transform: translateY(-2px); }
.game-card.completed { border-color: var(--green); }
.game-card.completed::after {
  content: '✓';
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.game-icon { font-size: 2.2rem; }
.game-card h3 { font-size: 1.2rem; font-weight: 700; }
.game-card p { color: var(--text2); font-size: 0.88rem; line-height: 1.5; }
.game-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text2);
  width: fit-content;
}
.game-card .play-btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--green);
  color: white;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
}

/* LEADERBOARD PREVIEW */
.leaderboard-preview {
  margin: 0 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  max-width: 1060px;
  margin-left: auto;
  margin-right: auto;
}
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 12px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 24px; font-weight: 700; color: var(--text2); font-size: 0.9rem; }
.lb-rank.gold { color: var(--gold); }
.lb-flag { font-size: 1.3rem; }
.lb-name { flex: 1; font-weight: 600; font-size: 0.95rem; }
.lb-score { font-weight: 700; color: var(--green-bright); }
.lb-bar-wrap { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; }
.lb-bar { height: 100%; background: var(--green); border-radius: 3px; }

/* WORDLE GAME */
.game-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.game-header h2 { font-size: 1.3rem; font-weight: 800; }
.game-meta { font-size: 0.8rem; color: var(--text2); }

/* BOARD */
.board {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board-row {
  display: flex;
  gap: 6px;
}
.tile {
  width: 58px; height: 58px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: border-color 0.1s;
  cursor: default;
  user-select: none;
}
.tile.filled { border-color: var(--tile-border); }
.tile.correct { background: var(--correct); border-color: var(--correct); color: white; }
.tile.present { background: var(--present); border-color: var(--present); color: white; }
.tile.absent  { background: var(--absent);  border-color: var(--absent);  color: white; }
.tile.pop { animation: pop 0.1s ease; }
.tile.flip { animation: flip 0.5s ease forwards; }
.tile.shake { animation: shake 0.5s ease; }
.tile.bounce { animation: bounce 0.1s ease; }

@keyframes pop {
  0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); }
}
@keyframes flip {
  0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-4px); } 40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
@keyframes bounce {
  0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); }
}

/* KEYBOARD */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.key-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.key {
  height: 56px;
  min-width: 36px;
  padding: 0 6px;
  flex: 1;
  max-width: 42px;
  background: var(--surface2);
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.key:hover { opacity: 0.85; }
.key.wide { max-width: 65px; font-size: 0.75rem; }
.key.correct { background: var(--correct); color: white; }
.key.present { background: var(--present); color: white; }
.key.absent  { background: var(--absent);  color: white; }

/* TOAST */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 1.7s forwards;
}
@keyframes toastIn { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* MODAL */
.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: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.modal h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.modal p { color: var(--text2); margin-bottom: 20px; font-size: 0.95rem; }
.result-word {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--green-bright);
  margin: 12px 0;
}
.share-grid {
  font-family: monospace;
  font-size: 1.1rem;
  line-height: 1.4;
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  white-space: pre;
}
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-green  { background: var(--green); color: white; }
.btn-green:hover { background: var(--green-bright); }
.btn-grey   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-grey:hover { border-color: var(--text2); }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* COUNTRY SELECT */
.country-select-modal .modal { max-width: 380px; }
.country-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin: 16px 0;
}
.country-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.country-btn:hover { border-color: var(--green-bright); }
.country-btn .flag { font-size: 1.2rem; }

/* SUDOKU */
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  background: var(--border);
  border: 2px solid var(--text2);
  border-radius: 4px;
  overflow: hidden;
  max-width: 360px;
  width: 100%;
}
.sudoku-cell {
  background: var(--surface);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  outline: none;
  color: var(--text);
  position: relative;
}
.sudoku-cell.given { color: var(--text); font-weight: 800; }
.sudoku-cell.selected { background: #1e3a5f; }
.sudoku-cell.related { background: var(--surface2); }
.sudoku-cell.same-num { background: #1a3020; }
.sudoku-cell.error { color: var(--red); }
.sudoku-cell.correct-cell { color: var(--green-bright); }
/* thick borders for 3x3 boxes */
.sudoku-cell:nth-child(3n) { border-right: 2px solid var(--text2); }
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--text2); }

/* NUMBER PAD */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 300px;
}
.numpad-btn {
  padding: 12px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
}
.numpad-btn:hover { border-color: var(--green-bright); }
.numpad-btn.erase { font-size: 0.8rem; color: var(--text2); }

/* TYPING GAME */
.typing-area {
  width: 100%;
  max-width: 600px;
  font-size: 1.2rem;
  line-height: 1.9;
  letter-spacing: 0.5px;
}
.typing-char { position: relative; }
.typing-char.correct { color: var(--green-bright); }
.typing-char.error { color: var(--red); background: rgba(239,68,68,0.15); border-radius: 2px; }
.typing-char.cursor::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 2px;
  background: var(--text);
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

.typing-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.typing-stats {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
}
.stat { text-align: center; }
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--green-bright); }
.stat-label { font-size: 0.75rem; color: var(--text2); }

/* QUIZ */
.quiz-question {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  padding: 0 8px;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.quiz-option {
  padding: 14px 18px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.quiz-option:hover:not(:disabled) { border-color: var(--blue); }
.quiz-option.correct { border-color: var(--green); background: rgba(83,141,78,0.15); }
.quiz-option.wrong { border-color: var(--red); background: rgba(239,68,68,0.1); }
.quiz-progress {
  display: flex;
  gap: 6px;
}
.quiz-dot {
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
}
.quiz-dot.done { background: var(--green); }
.quiz-dot.current { background: var(--yellow); }

/* CHALLENGE */
.challenge-create {
  width: 100%;
  max-width: 400px;
}
.word-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.word-input:focus { border-color: var(--green-bright); }
.word-input::placeholder { letter-spacing: 1px; font-weight: 400; text-transform: none; color: var(--text2); }
.challenge-link {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 0.8rem;
  word-break: break-all;
  text-align: center;
}

/* FOOTER */
footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text2);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}
footer a { color: var(--text2); text-decoration: none; }
footer a:hover { color: var(--text); }

/* AD SLOT */
.ad-slot {
  margin: 0 20px 24px;
  max-width: 1060px;
  margin-left: auto;
  margin-right: auto;
}
.ad-label { font-size: 0.7rem; color: var(--text2); text-align: center; margin-bottom: 6px; }

/* UTILITIES */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }

/* RESPONSIVE */
@media (max-width: 480px) {
  .tile { width: 50px; height: 50px; font-size: 1.5rem; }
  .key { height: 50px; font-size: 0.8rem; }
  nav { padding: 10px 14px; }
  .nav-links a { padding: 5px 7px; font-size: 0.8rem; }
  .games-grid { grid-template-columns: 1fr; }
}
