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

/* The game is a fixed light theme; pin the shared site tokens so the nav matches it in dark mode too. */
:root {
  --bg: #fff; --surface: #fff; --surface-2: #f1f1ed; --text: #222; --muted: #5f636b;
  --line: #e4e4de; --accent: #0a6cc2; --accent-ink: #fff; color-scheme: light;
}

body {
  font-family: var(--font);
  background: #fff;
  color: #222;
  min-height: 100vh;
  line-height: 1.6;
}

#app { padding: 2rem; }

/* Screens */
.screen { display: none; animation: fadeIn 0.25s ease; }
.screen.active { display: flex; flex-direction: column; align-items: center; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 15px;
  padding: 10px 22px;
}
.btn-primary {
  background: #007acc;
  color: #fff;
}
.btn-primary:hover {
  background: #005fa3;
}
.btn-back {
  background: none;
  color: #888;
  padding: 8px 14px;
}
.btn-back:hover { color: #222; }
.btn-give-up {
  background: none;
  color: #bbb;
  font-size: 13px;
  padding: 6px 14px;
  margin-top: 12px;
}
.btn-give-up:hover { color: #888; }
.btn-hint {
  background: none;
  color: #007acc;
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid #007acc;
  border-radius: 8px;
}
.btn-hint:hover { background: #f0f7ff; }
.bottom-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

/* ===== TITLE ===== */
.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 75vh;
  text-align: center;
  gap: 12px;
}
.title-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #222;
}
.subtitle {
  color: #666;
  font-size: 1rem;
  max-width: 380px;
  margin-bottom: 12px;
}
.title-stats {
  color: #999;
  font-size: 13px;
  margin-top: 8px;
}

/* ===== LEVELS ===== */
.levels-header {
  width: 100%;
  max-width: 620px;
  margin: 4rem auto 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.levels-header h2 { flex: 1; font-size: 1.4rem; }
.level-progress { color: #999; font-size: 13px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 6px;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

.level-tile {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: 2px solid #e8e8e8;
  background: #fff;
  transition: all 0.15s;
  position: relative;
  color: #222;
}
.level-tile:hover:not(.locked) {
  border-color: #007acc;
  box-shadow: 0 2px 8px rgba(0,122,204,0.15);
}
.level-tile.completed {
  border-color: #34c759;
  background: #f0fdf4;
}
.level-tile.current {
  border-color: #007acc;
  background: #f0f7ff;
}
.level-tile.locked {
  opacity: 0.3;
  cursor: not-allowed;
}
.level-tile .stars {
  font-size: 7px;
  position: absolute;
  bottom: 3px;
  color: #f5a623;
  letter-spacing: 0.5px;
}

/* ===== GAME ===== */
.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 3.5rem auto 12px;
}
.level-badge {
  background: #f2f2f2;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  color: #555;
}
.guess-counter {
  margin-left: auto;
  color: #999;
  font-size: 13px;
}

.game-body {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Thermometer */
.thermometer-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
}
.thermometer {
  flex: 1;
  height: 18px;
  background: #f2f2f2;
  border-radius: 9px;
  overflow: hidden;
}
.temp-fill {
  height: 100%;
  width: 0%;
  border-radius: 9px;
  transition: width 0.5s cubic-bezier(0.34,1.56,0.64,1), background 0.5s ease;
  background: #cde;
}
.temp-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 90px;
}
.temp-label { font-weight: 700; font-size: 13px; color: #999; }
.temp-score { font-size: 11px; color: #bbb; }

/* Input */
.input-area { display: flex; gap: 8px; width: 100%; }
#guess-input {
  flex: 1;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 11px 16px;
  color: #222;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
#guess-input:focus { border-color: #007acc; }
#guess-input::placeholder { color: #bbb; }

/* Guess History */
.guess-history {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 380px;
  overflow-y: auto;
}
.guess-history::-webkit-scrollbar { width: 3px; }
.guess-history::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.empty-state {
  text-align: center;
  color: #bbb;
  font-size: 13px;
  padding: 28px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #fafafa;
  border-radius: 7px;
  animation: slideIn 0.2s ease;
  border-left: 3px solid #ddd;
}
.guess-row.top-guess { background: #f0f7ff; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.guess-row .guess-word { flex: 1; font-weight: 600; font-size: 14px; }
.guess-row .guess-rank { font-size: 12px; font-weight: 700; min-width: 28px; }
.guess-row .guess-bar {
  width: 50px; height: 5px;
  background: #eee; border-radius: 3px; overflow: hidden;
}
.guess-row .guess-bar-fill { height: 100%; border-radius: 3px; }
.guess-row .guess-temp { font-size: 11px; font-weight: 600; min-width: 55px; text-align: right; }

/* ===== WIN / GIVE UP ===== */
.win-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 75vh;
  text-align: center;
  gap: 14px;
}
.win-content h2 { font-size: 1.6rem; color: #222; }
.win-word {
  font-size: 2.2rem;
  font-weight: 700;
  color: #34c759;
  text-transform: uppercase;
  letter-spacing: 3px;
}
.reveal-word { color: #ff6b35; }
.win-guesses { color: #999; font-size: 14px; }
.win-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Confetti */
.win-celebration {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10;
}
.confetti {
  position: absolute; width: 6px; height: 6px; border-radius: 1px;
  animation: confettiFall 2.5s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 9px 22px; border-radius: 8px;
  font-size: 13px; font-weight: 500; z-index: 100;
  animation: toastIn 0.2s ease, toastOut 0.25s ease 1.8s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* Shake */
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.shake { animation: shake 0.25s ease; }

/* Rank badge */
#rank-badge {
  width: 100%;
  text-align: center;
  padding: 8px 0;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#rank-badge.show {
  opacity: 1;
  transform: scale(1);
}
.rank-number {
  font-size: 28px;
  font-weight: 700;
  display: block;
  line-height: 1.1;
}
.rank-of {
  font-size: 12px;
  color: #999;
}

/* Latest guess highlight */
.guess-row.latest-guess {
  background: #f0f7ff;
  box-shadow: 0 0 0 1px rgba(0,122,204,0.15);
}

@media (max-width: 600px) {
  #app { padding: 1rem; }
  .title-content h1 { font-size: 2rem; }
  .win-word { font-size: 1.6rem; }
  .rank-number { font-size: 24px; }
}
