:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2a2e3d;
  --text: #e8e6e1;
  --text-dim: #8b8a87;
  --accent: #d4a853;
  --accent-glow: #d4a85330;
  --green: #4ade80;
  --green-dim: #4ade8020;
  --red: #f87171;
  --red-dim: #f8717120;
  --cheap: #6ee7b7;
  --mid: #fbbf24;
  --expensive: #f87171;
  --radius: 12px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 12px;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.info-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.info-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  animation: slideUp 0.4s ease;
}

.info-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.info-text p {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.info-close-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px 32px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 8px;
}

.info-close-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 2.4rem;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent) 0%, #f0d78c 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Score bar */
.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 24px;
}

.score-label { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.score-value { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.score-bar .day-info { text-align: right; }
.day-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.day-date { font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; color: var(--text); }

/* Free clue */
.free-clue {
  background: linear-gradient(135deg, var(--surface) 0%, #1e2130 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.free-clue::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
}

.free-clue-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); margin-bottom: 8px; position: relative; }
.free-clue-text { font-family: 'DM Serif Display', serif; font-size: 1.4rem; line-height: 1.3; position: relative; }

/* Guess input */
.guess-section { margin-bottom: 28px; }
.guess-input-wrap { display: flex; gap: 10px; }

.guess-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.guess-input:focus { border-color: var(--accent); }
.guess-input::placeholder { color: var(--text-dim); }

.guess-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.guess-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.guess-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* Autocomplete */
.autocomplete-wrap { position: relative; }

.autocomplete-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-list.show { display: block; }
.autocomplete-item { padding: 10px 18px; cursor: pointer; font-size: 0.95rem; transition: background 0.15s; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--surface-hover); color: var(--accent); }

/* Guess log */
.guess-log { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.guess-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.82rem;
  color: var(--red);
  animation: chipIn 0.3s ease;
}

.guess-chip.correct { background: var(--green-dim); border-color: var(--green); color: var(--green); }

@keyframes chipIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

/* Hint shop */
.shop-title { font-family: 'DM Serif Display', serif; font-size: 1.2rem; margin-bottom: 14px; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.hint-card:hover:not(.bought):not(.locked) { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.3); }
.hint-card.bought { cursor: default; border-color: var(--accent); background: linear-gradient(135deg, var(--surface) 0%, #1e2130 100%); }
.hint-card.locked { opacity: 0.35; cursor: not-allowed; }

.hint-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.hint-name { font-weight: 600; font-size: 0.88rem; }

.hint-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--border);
}

.hint-cost.cheap { color: var(--cheap); }
.hint-cost.mid { color: var(--mid); }
.hint-cost.expensive { color: var(--red); }

.hint-desc { font-size: 0.75rem; color: var(--text-dim); }

.hint-reveal {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--accent);
  animation: fadeReveal 0.4s ease;
}

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

/* Result overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
  animation: fadeIn 0.3s;
}

.overlay.show { display: flex; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.result-title { font-family: 'DM Serif Display', serif; font-size: 1.6rem; margin-bottom: 4px; }
.result-country { color: var(--accent); font-family: 'DM Serif Display', serif; font-size: 1.3rem; margin-bottom: 16px; }
.result-score-row { display: flex; justify-content: center; gap: 24px; margin-bottom: 20px; }
.result-stat { text-align: center; }
.result-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.result-stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.share-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 8px;
}

.share-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }

/* States */
.loading { text-align: center; padding: 60px 20px; color: var(--text-dim); font-size: 1rem; }
.error-msg { text-align: center; padding: 40px 20px; color: var(--red); font-size: 0.95rem; }

/* Toast */
.score-change {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 8px 20px;
  border-radius: 100px;
  z-index: 300;
  animation: toastPop 1.2s ease forwards;
  pointer-events: none;
}

.score-change.negative { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.score-change.positive { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

@keyframes toastPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
