/* ============================================================
   Daily Games — shared design system (mockup)
   One system, four skins: games override --accent / --warm only.
   ============================================================ */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --subtle: #f4f4f5;          /* chips, hovers, tracks */
  --ink: #1b1b22;
  --muted: #6f6f7a;
  --border: #e5e5e8;
  --border-strong: #cfcfd6;
  --accent: #0d9488;          /* per-game override */
  --warm: #d97706;            /* per-game override */
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20,20,30,.04), 0 8px 24px rgba(20,20,30,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

/* Dark theme: explicit toggle wins; otherwise follow the system */
:root[data-theme="dark"] {
  --bg: #101014;
  --surface: #1b1b21;
  --subtle: #26262e;
  --ink: #ededf3;
  --muted: #9c9ca8;
  --border: #2a2a34;
  --border-strong: #40404c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101014;
    --surface: #1b1b21;
    --subtle: #26262e;
    --ink: #ededf3;
    --muted: #9c9ca8;
    --border: #2a2a34;
    --border-strong: #40404c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}

/* Theme toggle: show moon in light, sun in dark */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }

/* ---------- layout ---------- */

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px 110px;
}
.app.wide { max-width: 680px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(16px, 4.6vw, 20px);
  letter-spacing: .2px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wordmark .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}
.wordmark .mark svg { width: 18px; height: 18px; }
.spacer { flex: 1; }

.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.iconbtn:hover { background: var(--subtle); }
.iconbtn svg { width: 20px; height: 20px; }

/* On phones the tab bar already has Home — free up header space */
@media (max-width: 719px) {
  .home-btn { display: none; }
}

/* ---------- games menu (pure HTML dropdown) ---------- */

details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 230px;
  padding: 8px;
  z-index: 30;
}
.menu-panel a {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
}
.menu-panel a:hover { background: var(--subtle); }
.menu-panel .dot { width: 11px; height: 11px; border-radius: 4px; flex: none; }
.menu-panel hr { border: none; border-top: 1px solid var(--border); margin: 6px 4px; }

/* ---------- status row ---------- */

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 2px 2px;
  color: var(--muted);
  font-size: 13px;
}
.flame { font-weight: 700; color: var(--warm); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 14px 0;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

/* ---------- buttons / inputs / chips ---------- */

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: 600 15px/1 var(--font);
  padding: 14px 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
}
.btn.ghost:hover { background: var(--border); filter: none; }
.btn.block { width: 100%; }

.input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: 400 16px var(--font);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field { margin: 14px 0; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.hintline { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--subtle);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.chip.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 9%, var(--surface)); }
.chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.chip.warm { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 40%, transparent); background: color-mix(in srgb, var(--warm) 10%, var(--surface)); }

/* ---------- stats dialog ---------- */

dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(400px, calc(100vw - 40px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(8, 8, 14, .5); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 0;
}
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 10px 20px 22px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
  text-align: center;
}
.stat .num { font-size: 27px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- bottom tab bar (mobile app feel) ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  z-index: 25;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 12px;
  min-width: 62px;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); font-weight: 700; }

@media (min-width: 720px) {
  .tabbar { display: none; }
  .app { padding-bottom: 60px; }
}

/* ---------- misc ---------- */

.footer-note {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 26px 0 8px;
}
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- toast (achievement unlocks etc.) ---------- */

.bb-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 11px 20px;
  font: 600 14px var(--font);
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60;
  max-width: calc(100vw - 40px);
  white-space: nowrap;
}
.bb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 720px) { .bb-toast { bottom: 32px; } }
@media (prefers-reduced-motion: reduce) { .bb-toast { transition: opacity .25s ease; } }

/* ---------- segmented control ---------- */

.seg {
  display: inline-flex;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 13px var(--font);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- select ---------- */

.select {
  appearance: none;
  padding: 10px 34px 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink);
  font: 500 14px var(--font);
}

/* ---------- settings: high contrast ---------- */

:root[data-contrast="high"] {
  --border: #8f8f9a;
  --border-strong: #4c4c58;
  --muted: #44444f;
  --shadow: none;
}
:root[data-theme="dark"][data-contrast="high"] {
  --border: #6e6e7c;
  --border-strong: #a8a8b4;
  --muted: #c4c4d0;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-contrast="high"] {
    --border: #6e6e7c;
    --border-strong: #a8a8b4;
    --muted: #c4c4d0;
    --shadow: none;
  }
}

/* ---------- settings: reduced motion ---------- */

:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ---------- settings: text size (zoom keeps px layouts intact) ---------- */

:root[data-text="large"] body { zoom: 1.12; }
:root[data-text="xl"] body { zoom: 1.25; }

/* ---------- settings dialog rows ---------- */

.bb-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.bb-settings-row:last-child { border-bottom: none; }
.bb-settings-row label { font-size: 14px; font-weight: 600; }
.bb-settings-row .select { min-width: 170px; }

/* The hidden attribute must always win, even over classes that set display */
[hidden] { display: none !important; }

/* ---------- desktop: give the play column more room ---------- */

@media (min-width: 720px) {
  .app { max-width: 640px; }
  .app.wide { max-width: 780px; }
}

/* ---------- save-streak prompt (win moments, guests only) ---------- */

.save-streak {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
