/* Anglebot — styles
 * Visual identity: a drafting table. Graph-paper grid, ink-and-paper surfaces,
 * protractor-amber + ink-blue accents, geometric type (Space Grotesk).
 */
:root {
  --bg: #0c101d;
  --bg-soft: #131829;
  --card: #171d32;
  --line: #28304d;
  --grid: rgba(126, 148, 205, 0.07);
  --text: #f0f3ff;
  --muted: #97a2c4;
  --accent: #ffb224; /* protractor amber */
  --on-accent: #241a05;
  --accent-2: #5b9dff; /* ink blue */
  --good: #3ddc84;
  --bad: #ff5d6c;
  --ring: rgba(255, 178, 36, 0.32);
  --shadow: 0 18px 44px rgba(3, 6, 16, 0.5);
  --radius: 18px;
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body[data-theme="light"] {
  --bg: #f6f4ec;
  --bg-soft: #fdfbf4;
  --card: #ffffff;
  --line: #e2e4ee;
  --grid: rgba(72, 105, 182, 0.09);
  --text: #1c2338;
  --muted: #616c8e;
  --accent: #f59e0b;
  --on-accent: #241a05;
  --accent-2: #2f6fdb;
  --good: #1fa860;
  --bad: #e04355;
  --ring: rgba(245, 158, 11, 0.28);
  --shadow: 0 14px 34px rgba(60, 70, 110, 0.14);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  /* graph paper: a faint grid over a soft top-lit wash */
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    radial-gradient(1200px 700px at 50% -10%, var(--bg-soft), var(--bg));
  background-size: 26px 26px, 26px 26px, auto;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  width: 100%;
  max-width: 620px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-mark { display: block; }
.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 0;
}
.brand h1 .brand-dot { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Daily streak chip — the little habit flame */
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  animation: pop 0.25s ease;
}
.streak-chip[hidden] { display: none; }
.streak-chip b { color: var(--accent); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.icon-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--bg-soft); }

/* Header menu (consolidated secondary actions) */
.menu-wrap { position: relative; }
.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 184px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: menuIn 0.14s ease;
}
.menu-dropdown[hidden] { display: none; }
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.menu-item:hover { background: var(--card); }
.menu-item .mi-ico { font-size: 15px; width: 18px; text-align: center; }
a.menu-item { text-decoration: none; white-space: nowrap; }
a.menu-item[hidden] { display: none; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

.account-btn[hidden] { display: none; }
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  max-width: 150px;
}
.account-btn:hover { border-color: var(--accent); }
.account-btn img { width: 24px; height: 24px; border-radius: 50%; }
.account-btn .acc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn.is-login { background: linear-gradient(90deg, #5865f2, #7983f5); color: #fff; border: none; }

.stats-account {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.stats-account a, .stats-account button.link {
  color: var(--accent-2);
  font-family: inherit;
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.stats-account img { width: 22px; height: 22px; border-radius: 50%; }

.lb-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.lb-row .lb-rank { width: 22px; font-weight: 700; color: var(--muted); text-align: center; }
.lb-row.is-me { border-color: var(--accent); }
.lb-row img { width: 28px; height: 28px; border-radius: 50%; }
.lb-row .lb-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-stat { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }
.lb-row .lb-stat b { color: var(--text); }

.modes {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Segmented control: Daily | Unlimited with a sliding amber thumb */
.seg-group {
  position: relative;
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.seg-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  bottom: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 14px var(--ring);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.seg-group[data-active="unlimited"] .seg-thumb { transform: translateX(100%); }
.mode-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 96px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.2s ease;
}
.mode-tab.is-active { color: var(--on-accent); }

/* Hard mode: a toggle switch that matches the segmented control */
.hard-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px 7px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.hard-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.hard-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.18s ease;
  flex: none;
}
.hard-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.18s ease;
}
.hard-toggle input:checked + .hard-switch { background: var(--bad); }
.hard-toggle input:checked + .hard-switch::after {
  transform: translateX(16px);
  background: #fff;
}
.hard-toggle input:checked ~ .hard-label { color: var(--bad); }
.hard-toggle input:focus-visible + .hard-switch {
  box-shadow: 0 0 0 3px var(--ring);
}

.stage {
  width: 100%;
  max-width: 560px;
  padding: 14px 18px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.puzzle-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 14px 0 8px;
  min-height: 16px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
}
#angleCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}
.hint-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.guess-form { width: 100%; margin-top: 16px; }
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}
.input-row:focus-within { border-color: var(--accent); }
#guessInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 100%;
  -moz-appearance: textfield;
}
#guessInput::placeholder { color: var(--muted); opacity: 0.45; font-weight: 700; }
#guessInput::-webkit-outer-spin-button,
#guessInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-row .deg { font-size: 28px; font-weight: 700; color: var(--muted); }
#guessBtn {
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
#guessBtn:hover { box-shadow: 0 6px 20px var(--ring); }
#guessBtn:active { transform: translateY(1px); }
#guessBtn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.message { min-height: 18px; margin: 10px 2px 0; font-size: 14px; font-weight: 500; color: var(--bad); }

.guess-list {
  list-style: none;
  width: 100%;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.guess-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  animation: pop 0.25s ease;
}
@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.guess-row .gval { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.guess-row .gright { display: flex; align-items: center; gap: 10px; }
.guess-row .gdir { font-size: 13px; font-weight: 500; color: var(--muted); }
.thermo {
  width: 120px;
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
  border: 1px solid var(--line);
}
.thermo span { display: block; height: 100%; border-radius: 999px; }
.gtier { font-size: 13px; font-weight: 700; min-width: 90px; text-align: right; }

.end-panel {
  width: 100%;
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.end-headline { font-size: 23px; font-weight: 700; margin: 0 0 4px; }
.end-sub { color: var(--muted); margin: 0 0 12px; }
.share-grid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 0 auto 14px;
  display: inline-block;
  text-align: left;
}
.end-actions { display: flex; gap: 10px; justify-content: center; }
.primary {
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.primary:hover { box-shadow: 0 6px 20px var(--ring); }
.primary:active { transform: translateY(1px); }
.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--accent); }
.countdown { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin: 12px 0 0; }
.yesterday { color: var(--muted); font-size: 13px; margin: 4px 0 0; opacity: 0.85; }
.yesterday b { color: var(--accent-2); }

/* Modals */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin-top: 0; font-weight: 700; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.rules { padding-left: 18px; line-height: 1.6; }
.rules li { margin-bottom: 6px; }
.tip { color: var(--muted); font-size: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  margin-bottom: 18px;
}
.stat-grid > div { display: flex; flex-direction: column; }
.stat-num { font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-grid small { color: var(--muted); font-size: 11px; }
.dist-chart { display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist-row .dist-key { width: 16px; color: var(--muted); font-weight: 700; }
.dist-bar {
  background: var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: 700;
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dist-bar.is-current { background: var(--accent); color: var(--on-accent); }

.toast {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 80;
  box-shadow: var(--shadow);
}

/* Crawlable intro copy — a quiet tap-to-expand row below the game.
   (Collapsed <details> content is still in the DOM, so it stays indexable.) */
.about {
  width: 100%;
  max-width: 560px;
  padding: 8px 18px 0;
  margin-top: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
.about summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 8px 0;
  color: var(--muted);
  transition: color 0.15s ease;
}
.about summary::-webkit-details-marker { display: none; }
.about summary h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: inherit;
}
.about summary::after {
  content: "▾";
  font-size: 12px;
  transition: transform 0.15s ease;
}
.about[open] summary::after { transform: rotate(180deg); }
.about summary:hover { color: var(--text); }
.about p { margin: 4px 0 10px; }
.about b { color: var(--text); font-weight: 600; }

.footer {
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.footer .muted { opacity: 0.7; }

button:focus-visible, input:focus-visible, .account-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .thermo { width: 70px; }
  .gtier { min-width: 70px; font-size: 12px; }
  .brand h1 { font-size: 19px; }
  .streak-chip { height: 34px; padding: 0 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
