/* GuessGauge styles — mobile first, vibrant dark theme */
:root {
  --bg: #1a1036;
  --bg2: #2b1460;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f6f3ff;
  --muted: #b7acd9;
  --accent: #ff5fa2;
  --accent2: #ffb347;
  --good: #3ee08f;
  --error: #ff6b6b;
  --radius: 16px;
  --heat-gradient: linear-gradient(90deg, #3b6cf6, #22c3d6, #facc15, #fb923c, #ef4444);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, #4b1d8f 0, transparent 45%),
                    radial-gradient(circle at 100% 30%, #7a1d6b 0, transparent 40%);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ---------- Ad placeholders (empty boxes for now) ---------- */
.ad-slot {
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.75rem; letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}
.ad-banner { height: 56px; margin: 8px auto 0; width: calc(100% - 16px); max-width: 728px; }
@media (min-width: 760px) { .ad-banner { height: 90px; } }
.ad-box { min-height: 110px; margin: 18px 0; padding: 10px; }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto; padding: 12px 16px 4px;
}
.logo {
  margin: 0; font-size: 2rem; font-weight: 900; letter-spacing: -0.02em;
}
.logo span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--card-border); background: var(--card);
  font-size: 1.15rem; font-weight: 800;
}
.icon-btn:active { transform: scale(0.94); }

.debug-bar {
  max-width: 560px; margin: 6px auto 0; padding: 8px 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: #ffd23f; color: #2b1460; border-radius: 12px; font-size: 0.85rem; font-weight: 600;
  width: calc(100% - 32px);
}
.debug-bar span { flex: 1 1 100%; }
.chip { border: 0; border-radius: 999px; padding: 6px 12px; background: #2b1460; color: #fff; font-size: 0.8rem; }

/* ---------- Main ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.status { text-align: center; color: var(--muted); margin: 6px 0 12px; font-weight: 600; }

.guess-form { display: flex; gap: 10px; }
.guess-input {
  flex: 1; min-width: 0;
  height: 64px; padding: 0 16px;
  font-size: 2rem; font-weight: 800; letter-spacing: 0.35em; text-transform: uppercase; text-align: center;
  color: var(--text); background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.25); border-radius: var(--radius);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.guess-input::placeholder { color: rgba(255, 255, 255, 0.25); }
.guess-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 95, 162, 0.25); }
.guess-input.shake { animation: shake 0.35s; border-color: var(--error); }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.btn {
  border: 0; border-radius: var(--radius); padding: 0 22px; height: 64px;
  font-weight: 800; font-size: 1.1rem;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #2a0b2e; }
.btn-ghost { background: var(--card); border: 1px solid var(--card-border); }
.wide { width: 100%; height: 54px; margin-top: 12px; }

.message { min-height: 1.4em; text-align: center; margin: 8px 0 0; font-weight: 600; }
.message.error { color: var(--error); }
.yesterday {
  width: fit-content; margin: 2px auto 0; padding: 5px 14px;
  font-size: 0.85rem; color: var(--muted);
  background: var(--card); border: 1px solid var(--card-border); border-radius: 999px;
}
.yesterday b { color: var(--text); letter-spacing: 0.08em; }

/* ---------- Result ---------- */
.result-card {
  margin-top: 14px; padding: 18px; text-align: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 95, 162, 0.25), rgba(255, 179, 71, 0.2));
  border: 1px solid rgba(255, 179, 71, 0.4);
}
.result-card h2 { margin: 0 0 6px; font-size: 1.5rem; }
.result-card p { margin: 0 0 14px; }
.result-actions { display: flex; gap: 10px; justify-content: center; }
.result-actions .btn { height: 52px; flex: 1; max-width: 180px; }

/* ---------- Guess list ---------- */
.guesses-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.guesses-head h2 { font-size: 1.1rem; margin: 0; }
.toggle { display: flex; background: var(--card); border: 1px solid var(--card-border); border-radius: 999px; padding: 3px; }
.toggle button { border: 0; background: none; padding: 8px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.toggle button.active { background: var(--text); color: var(--bg); }

.legend { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--muted); margin: 12px 0 6px; }
.legend-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--heat-gradient); }

.guess-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.guess {
  display: grid; grid-template-columns: 2.2em 5.2em 1fr; align-items: center; gap: 4px 10px;
  padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--card-border);
}
.guess.latest { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.guess.win { background: linear-gradient(135deg, rgba(62, 224, 143, 0.3), rgba(255, 179, 71, 0.25)); border-color: var(--good); }
.guess .num { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.guess .word { font-weight: 900; letter-spacing: 0.12em; font-size: 1.05rem; }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 1.3em 1fr 2.8em; align-items: center; gap: 6px; font-size: 0.8rem; }
.bar-row .ico { font-size: 0.85rem; }
.bar-track { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 4px; transition: width 0.5s ease-out; }
.bar-row .pct { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.empty { text-align: center; margin: 18px 0; }

.footer { text-align: center; font-size: 0.75rem; padding: 30px 16px 24px; line-height: 1.6; }

/* ---------- Popups ---------- */
.modal {
  width: min(92vw, 460px); max-height: 88vh; overflow: auto;
  border: 1px solid var(--card-border); border-radius: 20px; padding: 22px;
  background: #241250; color: var(--text);
}
.modal::backdrop { background: rgba(10, 4, 25, 0.7); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 12px; font-size: 1.4rem; }
.modal h3 { margin: 16px 0 6px; font-size: 1rem; }
.modal p { line-height: 1.5; margin: 8px 0; }
.modal .close { position: absolute; top: 12px; right: 12px; border: 0; background: none; font-size: 1.2rem; width: 40px; height: 40px; color: var(--muted); }
.modal form { margin: 0; }
.help-score { background: var(--card); border-radius: 14px; padding: 4px 14px; margin: 10px 0; }
.help-score h3 { margin-top: 10px; }
.example { font-size: 0.88rem; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stat-grid b { display: block; font-size: 1.7rem; }
.stat-grid span { font-size: 0.72rem; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: grid; grid-template-columns: 3.6em 1fr; gap: 8px; align-items: center; font-size: 0.82rem; }
.dist-bar { background: rgba(255, 255, 255, 0.15); border-radius: 4px; padding: 2px 6px; text-align: right; font-weight: 800; min-width: 1.8em; }
.dist-bar.current { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #2a0b2e; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: 700;
  padding: 10px 18px; border-radius: 999px; z-index: 100; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  max-width: calc(100% - 32px); text-align: center;
}
