/* Daily Games — shared shell styling. Games scope their own CSS under .g-<id>. */

:root {
  --bg: #07080c;
  --panel: #11131b;
  --panel-2: #171a25;
  --line: #262a3a;
  --text: #e8ecf5;
  --muted: #8b93a9;
  --accent: #38e1ff;
  --accent-2: #a071ff;
  --good: #3ddc97;
  --warn: #ffcc66;
  --bad: #ff5f7e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(56, 225, 255, .10), transparent 60%),
    radial-gradient(800px 450px at 92% 4%, rgba(160, 113, 255, .10), transparent 60%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px; top: 12px;
  z-index: 60;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.offscreen { position: fixed; left: -9999px; opacity: 0; }

/* the router parks focus on the main region after a view change, so a
   keyboard user is not left at the top of the document with nothing
   announced; the region itself wants no ring for that */
#app:focus { outline: none; }

/* ---------- chrome ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 40px);
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; }
.brand-mark { color: var(--accent); text-shadow: 0 0 14px rgba(56, 225, 255, .8); }
.brand-name { font-size: 1.05rem; }
.brand-accent { color: var(--accent); }
.topnav { display: flex; gap: 8px; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 4px clamp(16px, 4vw, 40px) 40px;
  flex: 1;
}

.foot {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 32px;
  color: var(--muted);
  font-size: .85rem;
}

/* ---------- primitives ---------- */
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stack { display: flex; flex-direction: column; gap: 20px; }
.stack.tight { gap: 8px; }
.muted { color: var(--muted); margin: 0; }
.section-head { font-size: 1rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 8px 0 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;   /* a thumb-sized target; the padding alone came to 39.6px */
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, transform .12s ease, background .15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #06121a;
  box-shadow: 0 0 24px rgba(56, 225, 255, .25);
}
.btn.icon { width: 40px; padding: 10px 0; font-size: 1rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.chip {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(56, 225, 255, .14);
  color: var(--accent);
  border: 1px solid rgba(56, 225, 255, .35);
}
.chip.subtle { background: rgba(255, 255, 255, .05); color: var(--muted); border-color: var(--line); }

/* ---------- hero ---------- */
.hero {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: clamp(20px, 4vw, 34px);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -60% 55% -60% -20%;
  background: radial-gradient(closest-side, rgba(160, 113, 255, .16), transparent);
  pointer-events: none;
}
.hero-main { position: relative; display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.hero-title { display: flex; align-items: center; gap: 14px; font-size: clamp(1.7rem, 5vw, 2.6rem); font-weight: 800; }
.hero-emoji { font-size: clamp(2rem, 6vw, 3rem); filter: drop-shadow(0 0 16px rgba(56, 225, 255, .35)); }
.hero-tag { margin: 0; color: var(--muted); max-width: 46ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.done-note { color: var(--good); font-size: .9rem; }
.hero-side { text-align: right; position: relative; }
.countdown-label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.countdown {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(56, 225, 255, .4);
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { padding: 16px; text-align: center; }
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* ---------- library ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  transition: transform .15s ease, border-color .15s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile.is-today { border-color: rgba(56, 225, 255, .5); }
.tile-emoji { font-size: 1.9rem; }
.tile-body { flex: 1; min-width: 0; }
.tile-name { font-weight: 700; }
.tile-tag { font-size: .8rem; color: var(--muted); }
.tile-chips { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- archive ---------- */
.crumb { display: flex; }
.arch-row {
  display: grid;
  grid-template-columns: 110px 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: .9rem;
}
.arch-row:hover { border-color: var(--accent); }
.arch-date { color: var(--muted); }
.arch-name { font-weight: 600; }
.arch-state { color: var(--muted); font-size: .82rem; text-align: right; }
.arch-state.won { color: var(--good); }
.arch-state.lost { color: var(--bad); }

/* ---------- game shell ---------- */
.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.game-id { display: flex; flex-direction: column; min-width: 0; }
.game-name { font-weight: 700; }
.game-mode { font-size: .75rem; color: var(--muted); }
.score-slot {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
  font-size: .95rem;
  text-align: right;
}
.game-box { display: flex; justify-content: center; }
/* a module on its way, or one that never arrived (js/core/app.js, DG.registerLazy) */
.mount-loading, .mount-failed { width: 100%; text-align: center; padding: 48px 12px; }
.mount-loading { animation: dg-loading 1.6s ease-in-out infinite; }
.mount-failed .btn { margin-top: 12px; }
@keyframes dg-loading { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mount-loading { animation: none; } }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 9, .72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal-back.show { display: flex; }
.modal-box { padding: 24px; max-width: 440px; width: 100%; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
.modal-title { margin: 0 0 12px; font-size: 1.25rem; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.rules { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.rules p { margin: 0 0 10px; }
.rules kbd {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .85em;
  color: var(--text);
}
.result-summary { font-size: 1.05rem; margin: 0 0 10px; }
.result-grid {
  font-size: 1.1rem;
  line-height: 1.15;
  margin: 6px 0 12px;
  font-family: var(--font);
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-side { text-align: left; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .arch-row { grid-template-columns: 84px 24px 1fr; }
  .arch-state { grid-column: 1 / -1; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Design pass — backdrop, countdown ring, categories, heatmap
   ============================================================ */

.backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

kbd {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .82em;
  font-family: inherit;
  color: var(--text);
}

.topbar { position: relative; z-index: 2; }
.brand-mark { animation: dg-pulse 4s ease-in-out infinite; }
@keyframes dg-pulse {
  0%, 100% { opacity: .85; text-shadow: 0 0 12px rgba(56,225,255,.6); }
  50% { opacity: 1; text-shadow: 0 0 22px rgba(56,225,255,.95); }
}

/* ---------- hero ---------- */
.hero {
  border-top: 1px solid rgba(56, 225, 255, .35);
  gap: 30px;
}
.hero-side {
  display: flex;
  align-items: center;
  gap: 22px;
  position: relative;
}

.ring-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  flex: none;
  display: grid;
  place-items: center;
}
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 7; }
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(56, 225, 255, .55));
  transition: stroke-dashoffset 1s linear;
}
.ring-inner { text-align: center; line-height: 1.2; }
.ring-inner .countdown-label { font-size: .6rem; }
.ring-inner .countdown { font-size: 1.05rem; }

.upcoming { min-width: 132px; }
.upcoming-label {
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.upcoming-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.upcoming-list li {
  display: grid;
  grid-template-columns: 32px 20px 1fr;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  color: var(--muted);
}
.up-name { color: var(--text); font-weight: 600; }

/* ---------- library ---------- */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.lib-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-search {
  min-width: 210px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: .86rem;
  -webkit-appearance: none;
  appearance: none;
}
.lib-search::placeholder { color: var(--muted); }
.lib-search:hover { border-color: var(--accent); }
.lib-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lib-found { margin: 0; font-size: .82rem; color: var(--muted); }
.lib-found:empty { display: none; }
.lib-empty { padding: 22px 18px; text-align: center; color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter {
  min-height: 40px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.filter:hover { color: var(--text); border-color: var(--accent); }
.filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter.on {
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.library { display: flex; flex-direction: column; gap: 28px; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-title { margin: 0; font-size: 1.05rem; letter-spacing: .02em; }
.cat-blurb { color: var(--muted); font-size: .85rem; flex: 1; min-width: 180px; }
.cat-count { color: var(--muted); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; }

.tile { position: relative; overflow: hidden; }
.tile-glow {
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(56, 225, 255, .18), transparent);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.tile:hover .tile-glow, .tile:focus-visible .tile-glow { opacity: 1; }
.tile.cat-action:hover { border-color: var(--bad); }
.tile.cat-action .tile-glow { background: radial-gradient(closest-side, rgba(255, 95, 126, .20), transparent); }
.tile.cat-arcade:hover { border-color: var(--accent); }
.tile.cat-puzzle:hover { border-color: var(--accent-2); }
.tile.cat-puzzle .tile-glow { background: radial-gradient(closest-side, rgba(160, 113, 255, .20), transparent); }
.tile.cat-versus:hover { border-color: var(--warn); }
.tile.cat-versus .tile-glow { background: radial-gradient(closest-side, rgba(255, 204, 102, .20), transparent); }
.tile.is-today::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

/* ---------- archive heatmap ---------- */
.heat-card { padding: 18px; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.heat-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: clamp(.9rem, 3.4vw, 1.25rem);
  opacity: .6;
  transition: transform .12s ease, border-color .15s ease, opacity .15s ease;
}
.heat-cell:hover { transform: translateY(-2px); opacity: 1; border-color: var(--accent); }
.heat-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.heat-cell.none { opacity: .3; filter: grayscale(1); }
.heat-cell.lost { opacity: 1; border-color: rgba(255, 95, 126, .45); background: rgba(255, 95, 126, .07); }
.heat-cell.won { opacity: 1; border-color: rgba(61, 220, 151, .55); background: rgba(61, 220, 151, .09); }
.heat-cell.today { box-shadow: 0 0 0 2px var(--accent); }

.legend { display: flex; gap: 16px; margin-top: 14px; color: var(--muted); font-size: .78rem; flex-wrap: wrap; }
.sw {
  width: 12px; height: 12px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid var(--line);
}
.sw.won { background: rgba(61, 220, 151, .4); }
.sw.lost { background: rgba(255, 95, 126, .3); }
.sw.none { background: var(--panel); }

/* ---------- footer ---------- */
.foot p { margin: 0 0 8px; max-width: 68ch; }
.foot strong { color: var(--text); }
.foot-keys { opacity: .8; }
.foot-note { opacity: .75; }

/* ---------- watermark ---------- */
.watermark {
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
}


@media (max-width: 720px) {
  .hero-side { width: 100%; justify-content: space-between; }
  .ring-wrap { width: 108px; height: 108px; }
  .lib-head { align-items: flex-start; flex-direction: column; }
  .lib-tools { width: 100%; }
  .lib-search { flex: 1 1 100%; min-width: 0; }
}

/* ---------- storage choice sheet, install button, legal pages ---------- */
.consent {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  padding: 18px 20px;
  z-index: 55;
  font-size: .9rem;
}
.consent-title { margin: 0 0 8px; font-size: 1.05rem; }
.consent-text { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.consent-links { margin: 0 0 12px; color: var(--muted); font-size: .85rem; }
.consent-links a { color: var(--accent); }
.consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.foot-links { margin: 10px 0 0; }
.foot-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot-links a:hover { color: var(--accent); }
.btn.install { border-color: var(--accent); color: var(--accent); }
.ios-hint {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  padding: 14px 16px;
  z-index: 55;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.5;
}
.ios-hint strong { color: var(--text); }
.legal { max-width: 760px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 48px; line-height: 1.65; }
.legal h1 { font-size: 1.6rem; margin: 18px 0 4px; }
.legal .updated { color: var(--muted); font-size: .85rem; margin: 0 0 22px; }
.legal h2 { font-size: 1.1rem; margin: 26px 0 8px; }
.legal p, .legal li { color: var(--muted); }
.legal strong { color: var(--text); }
.legal a { color: var(--accent); }
.legal ul { padding-left: 20px; }
.legal code { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .9em; color: var(--text); }
@media (max-width: 480px) {
  .consent, .ios-hint { bottom: 8px; padding: 14px; }
  /* seven heat cells across a 360px phone came to 35px each; tighter card
     padding and gaps get them to a 40px tap target (326 inside the card
     border, less 20 padding and 24 of gaps, is 40.3 a cell) */
  .heat-card { padding: 10px; }
  .heat { gap: 4px; }
}
