/* Quarterlight — prototype shared brand system
   Canonical palette from _brand/brand_kit.md §9. Restraint rule: never
   more than four active colours on one surface (each game adds ONE hue). */

:root {
  --petrol:   #1F3D4A;  /* dark ground */
  --petrol-2: #17313c;  /* deeper panel */
  --petrol-3: #12252e;  /* deepest well */
  --graphite: #22262E;  /* near-black */
  --ivory:    #F1EDE3;  /* primary text on dark */
  --brass:    #B89968;  /* single brand accent */
  --smoke:    #7B8088;  /* secondary text / inactive */

  --hue: var(--brass);  /* each game overrides this */

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:  "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --ease: cubic-bezier(0.33, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body { height: 100%; }

body {
  background: var(--petrol-3);
  color: var(--ivory);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px 16px 20px;
  position: relative;
  overflow-x: hidden;
}

/* --- night-sky atmosphere --------------------------------------------- */
/* Depth: a soft glow rising from just above centre, falling to a dark well
   at the edges — the horizon-light of a real night sky. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(45% 32% at 28% 34%, rgba(184,153,104,0.07), transparent 70%),
    radial-gradient(40% 30% at 76% 22%, rgba(111,168,199,0.06), transparent 70%),
    radial-gradient(130% 90% at 50% 32%, #295061 0%, #1f3d4a 34%, #17313c 64%, #10222b 100%);
  background-size: 200% 200%, 220% 220%, 100% 100%;
  background-position: 0% 0%, 100% 0%, 0 0;
  animation: sky-drift 42s ease-in-out infinite;
}
@keyframes sky-drift {
  0%,100% { background-position: 0% 0%, 100% 0%, 0 0; }
  50%     { background-position: 60% 40%, 30% 70%, 0 0; }
}
/* A faint, non-repeating scatter of stars + two brighter brass motes.
   Tiny hand-placed points; big tile so repetition never reads on a phone. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(241,237,227,0.55), transparent 60%),
    radial-gradient(1px 1px at 27% 42%, rgba(241,237,227,0.35), transparent 60%),
    radial-gradient(1.2px 1.2px at 41% 12%, rgba(241,237,227,0.45), transparent 60%),
    radial-gradient(1px 1px at 58% 30%, rgba(241,237,227,0.30), transparent 60%),
    radial-gradient(1.6px 1.6px at 68% 8%,  rgba(184,153,104,0.55), transparent 60%),
    radial-gradient(1px 1px at 74% 48%, rgba(241,237,227,0.35), transparent 60%),
    radial-gradient(1.3px 1.3px at 86% 22%, rgba(241,237,227,0.45), transparent 60%),
    radial-gradient(1px 1px at 92% 60%, rgba(241,237,227,0.28), transparent 60%),
    radial-gradient(1px 1px at 9% 66%,  rgba(241,237,227,0.30), transparent 60%),
    radial-gradient(1.5px 1.5px at 33% 78%, rgba(184,153,104,0.40), transparent 60%),
    radial-gradient(1px 1px at 48% 88%, rgba(241,237,227,0.25), transparent 60%),
    radial-gradient(1.2px 1.2px at 63% 72%, rgba(241,237,227,0.35), transparent 60%),
    radial-gradient(1px 1px at 82% 84%, rgba(241,237,227,0.28), transparent 60%),
    radial-gradient(1px 1px at 19% 92%, rgba(241,237,227,0.22), transparent 60%);
  /* a gentle vignette so the corners fall into dark */
  mask-image: radial-gradient(120% 100% at 50% 40%, #000 55%, rgba(0,0,0,0.5) 100%);
  -webkit-mask-image: radial-gradient(120% 100% at 50% 40%, #000 55%, rgba(0,0,0,0.5) 100%);
  animation: twinkle 7s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: 0.82; } 50% { opacity: 1; } }

/* --- shared masthead --------------------------------------------------- */
.ql-mast {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
}
.ql-wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.34em;
  font-size: 14px;
  color: var(--ivory);
  text-decoration: none;
  padding-left: 0.34em;
}
.ql-wordmark .notch { color: var(--brass); }
.ql-back {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--smoke);
  text-decoration: none;
  transition: color 0.3s var(--ease);
}
.ql-back:hover { color: var(--brass); }

.ql-rule {
  width: 100%;
  max-width: 480px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass) 12%, var(--brass) 88%, transparent);
  opacity: 0.45;
}

/* --- the play area: everything between rule and footer, optically centred */
.play {
  flex: 1 1 auto;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  gap: 0;
}

/* --- game titles ------------------------------------------------------- */
.game-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
  margin-bottom: 7px;
}
.game-title .lead { color: var(--hue); }   /* jewelled first letter */
.game-sub {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--smoke);
  text-align: center;
  margin-bottom: 26px;
}

/* --- the board panel: a framed viewport onto the sky ------------------- */
.board {
  position: relative;
  border-radius: 14px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,0.035), transparent 70%),
    linear-gradient(180deg, rgba(23,49,60,0.55), rgba(16,34,43,0.65));
  border: 1px solid rgba(184,153,104,0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 0 40px rgba(0,0,0,0.28),
    0 18px 40px -24px rgba(0,0,0,0.7);
  padding: 20px;
}

/* --- buttons ----------------------------------------------------------- */
button, .btn {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ivory);
  background: transparent;
  border: 1px solid var(--brass);
  border-radius: 3px;
  padding: 11px 22px;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), box-shadow 0.3s var(--ease), opacity 0.3s var(--ease);
}
button:hover, .btn:hover {
  background: var(--brass);
  color: var(--graphite);
  box-shadow: 0 6px 20px -8px rgba(184,153,104,0.6);
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.3; cursor: default; box-shadow: none; }
button:disabled:hover { background: transparent; color: var(--ivory); }

/* a soft-primary button tinted to the game hue */
.btn-hue { border-color: var(--hue); }
.btn-hue:hover { background: var(--hue); color: var(--graphite); box-shadow: 0 6px 20px -8px var(--hue); }

.hint { color: var(--smoke); font-size: 12.5px; line-height: 1.6; max-width: 420px; text-align: center; }
.stat { color: var(--brass); font-variant-numeric: tabular-nums; }

/* --- footer strip ------------------------------------------------------ */
.foot {
  width: 100%;
  max-width: 480px;
  text-align: center;
  color: var(--smoke);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  padding-top: 14px;
  opacity: 0.8;
}

canvas { display: block; touch-action: none; }

/* --- floating mute toggle --------------------------------------------- */
.ql-mute {
  position: fixed; left: 14px; bottom: 12px; z-index: 30;
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 1px solid rgba(184,153,104,0.28); border-radius: 50%;
  background: rgba(18,37,46,0.6); color: var(--smoke);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.ql-mute:hover { color: var(--ivory); border-color: var(--brass); background: rgba(18,37,46,0.85); box-shadow: none; }
.ql-mute:active { transform: translateY(1px); }
.ql-info {
  position: fixed; right: 14px; bottom: 12px; z-index: 30;
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 1px solid rgba(184,153,104,0.28); border-radius: 50%;
  background: rgba(18,37,46,0.6); color: var(--smoke);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.ql-info:hover { color: var(--ivory); border-color: var(--brass); background: rgba(18,37,46,0.85); box-shadow: none; }
.ql-info:active { transform: translateY(1px); }

/* how-to list inside the info card */
.howto-list { text-align: left; margin: 4px 0 22px; padding: 0; list-style: none; counter-reset: step; }
.howto-list li {
  position: relative; padding: 8px 0 8px 34px; font-size: 13.5px; line-height: 1.45;
  color: var(--ivory); opacity: 0.9; border-top: 1px solid rgba(255,255,255,0.05);
}
.howto-list li:first-child { border-top: none; }
.howto-list li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 7px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--hue); border: 1px solid color-mix(in srgb, var(--hue) 50%, transparent);
}

/* --- entrance motion --------------------------------------------------- */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise-in 0.6s var(--ease-out) both; }
.rise-1 { animation-delay: 0.05s; }
.rise-2 { animation-delay: 0.13s; }
.rise-3 { animation-delay: 0.22s; }

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

/* --- hub cards --------------------------------------------------------- */
.cards { width: 100%; max-width: 480px; display: grid; gap: 12px; }
.card {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background:
    radial-gradient(140% 120% at 0% 50%, rgba(255,255,255,0.03), transparent 60%),
    linear-gradient(180deg, rgba(23,49,60,0.6), rgba(16,34,43,0.7));
  border: 1px solid rgba(184,153,104,0.18);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ivory);
  overflow: hidden;
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease);
}
/* the game's hue as a soft light bleeding in from the left edge */
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--hue, var(--brass));
  box-shadow: 0 0 18px 1px var(--hue, var(--brass));
  opacity: 0.75;
}
.card:hover { border-color: rgba(184,153,104,0.5); transform: translateY(-2px); box-shadow: 0 16px 36px -22px rgba(0,0,0,0.8); }
.card .glyph {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1;
  color: var(--hue, var(--brass));
  text-shadow: 0 0 20px color-mix(in srgb, var(--hue, var(--brass)) 75%, transparent),
               0 0 6px color-mix(in srgb, var(--hue, var(--brass)) 55%, transparent);
}
.card .cn { display: block; font-family: var(--serif); font-size: 24px; letter-spacing: 0.01em; line-height: 1.15; }
.card .cd { display: block; font-size: 12.5px; color: var(--smoke); letter-spacing: 0.01em; margin-top: 3px; line-height: 1.4; }
.card .cv { margin-left: auto; align-self: center; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); white-space: nowrap; }

/* --- daily framing (date + puzzle number, NYT-style) ------------------- */
.daily {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--smoke); text-align: center; margin-bottom: 22px;
}
.daily b { color: var(--brass); font-weight: 500; }

/* --- the result sheet (completion moment) ------------------------------ */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(9,19,24,0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.4s var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 360px; position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--hue) 14%, transparent), transparent 60%),
    linear-gradient(180deg, #1a3743, #12252e);
  border: 1px solid color-mix(in srgb, var(--hue) 34%, rgba(184,153,104,0.2));
  border-radius: 18px; padding: 30px 26px 26px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,0.85), 0 0 60px -30px var(--hue);
  text-align: center;
  transform: translateY(24px) scale(0.97); opacity: 0;
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
}
.scrim.open .sheet { transform: translateY(0) scale(1); opacity: 1; }
.sheet-x {
  position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; padding: 0;
  border: none; background: none; color: var(--smoke); font-size: 22px; line-height: 1; cursor: pointer;
}
.sheet-x:hover { background: none; color: var(--ivory); box-shadow: none; }
.sheet-eyebrow { font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--smoke); margin-bottom: 10px; }
.sheet-verdict { font-family: var(--serif); font-size: 30px; line-height: 1.12; color: var(--hue); margin-bottom: 6px; }
.sheet-sub { font-size: 13px; color: var(--ivory); opacity: 0.85; margin-bottom: 20px; letter-spacing: 0.01em; }
.sheet-grid { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-bottom: 22px; }
.sheet-row { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.sheet-cell { width: 22px; height: 22px; border-radius: 5px; background: rgba(255,255,255,0.05); display:grid; place-items:center; font-size: 12px; }
.sheet-stats { display: flex; justify-content: center; gap: 26px; margin-bottom: 20px; }
.sheet-stat { display: flex; flex-direction: column; gap: 3px; }
.sheet-stat .v { font-family: var(--serif); font-size: 26px; color: var(--ivory); line-height: 1; font-variant-numeric: tabular-nums; }
.sheet-stat .l { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--smoke); }
.sheet-next { font-size: 11px; letter-spacing: 0.08em; color: var(--smoke); margin-bottom: 18px; }
.sheet-next b { color: var(--ivory); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.sheet-actions { display: flex; gap: 10px; justify-content: center; }
.sheet-actions .btn { flex: 1; max-width: 180px; }
/* streak + freshly-earned badge line under the stats */
.sheet-note { margin: -6px 0 16px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.sk-streak { font-size: 12px; letter-spacing: 0.06em; color: var(--brass); }
.sk-badge {
  display: inline-block; margin: 0 3px; font-size: 11px; letter-spacing: 0.04em; color: var(--ivory);
  border: 1px solid color-mix(in srgb, var(--hue) 45%, transparent); border-radius: 999px;
  padding: 3px 11px; background: color-mix(in srgb, var(--hue) 12%, transparent);
  animation: badge-pop 0.6s var(--ease-out) both;
}
@keyframes badge-pop { 0%{transform:scale(0.6);opacity:0} 60%{transform:scale(1.08)} 100%{transform:scale(1);opacity:1} }
/* the quiet link down to the collection */
.sheet-sky {
  display: inline-block; margin-top: 16px; font-size: 11.5px; letter-spacing: 0.08em;
  color: var(--smoke); text-decoration: none; transition: color 0.3s var(--ease);
}
.sheet-sky:hover { color: var(--brass); }

/* --- the collection: "your sky" ---------------------------------------- */
.wide { max-width: 620px; }
.coll-head { text-align: center; margin-bottom: 24px; }
.coll-head h1 { font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1; margin-bottom: 8px; }
.coll-head .k { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--smoke); }

/* the headline streak — two big numbers */
.streaks { display: flex; justify-content: center; gap: 30px; margin-bottom: 30px; }
.streak-fig { text-align: center; min-width: 96px; padding: 16px 8px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(23,49,60,0.5), rgba(16,34,43,0.6)); border: 1px solid rgba(184,153,104,0.16); }
.streak-fig .v { font-family: var(--serif); font-size: 44px; line-height: 1; color: var(--brass); font-variant-numeric: tabular-nums; }
.streak-fig .l { display: block; margin-top: 6px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--smoke); }

.coll-section-k { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--brass); text-align: center; margin: 6px 0 16px; }

/* the constellation calendar — a grid of nights, filled stars = nights played */
.sky-cal { display: grid; grid-template-columns: repeat(auto-fill, 16px); gap: 6px; justify-content: center; margin-bottom: 8px; }
.sky-night { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(123,128,136,0.3); position: relative; }
.sky-night.lit { border-color: transparent; background: radial-gradient(circle at 50% 40%, #fff 0 1px, var(--brass) 2px, color-mix(in srgb, var(--brass) 40%, transparent) 60%, transparent 75%);
  box-shadow: 0 0 8px -1px var(--brass); }
.sky-night.today { outline: 1px solid var(--brass); outline-offset: 2px; }
.sky-legend { text-align: center; font-size: 11px; color: var(--smoke); letter-spacing: 0.04em; margin-bottom: 30px; }

/* per-game stat cards */
.gstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 30px; }
.gstat {
  padding: 18px; border-radius: 12px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(23,49,60,0.55), rgba(16,34,43,0.65)); border: 1px solid rgba(184,153,104,0.16);
}
.gstat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--hue); box-shadow: 0 0 16px 1px var(--hue); opacity: 0.8; }
.gstat-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.gstat-name { font-family: var(--serif); font-size: 22px; }
.gstat-name .lead { color: var(--hue); }
.gstat-tag { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--smoke); }
.gstat-row { display: flex; gap: 20px; margin-bottom: 12px; }
.gstat-fig .v { font-family: var(--serif); font-size: 24px; color: var(--ivory); font-variant-numeric: tabular-nums; line-height: 1; }
.gstat-fig .l { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--smoke); }
/* distribution histogram */
.dist { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--smoke); }
.dist-row .bk { width: 40px; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.dist-bar { height: 15px; border-radius: 3px; background: color-mix(in srgb, var(--hue) 55%, transparent); min-width: 3px;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; color: var(--graphite); font-size: 10px; font-variant-numeric: tabular-nums; }
.dist-bar.hot { background: var(--hue); }
.gstat-empty { font-size: 12px; color: var(--smoke); font-style: italic; opacity: 0.7; padding: 6px 0; }

/* badges shelf */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 30px; }
.badge {
  text-align: center; padding: 16px 10px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(23,49,60,0.4), rgba(16,34,43,0.5)); border: 1px solid rgba(184,153,104,0.12);
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease-out);
}
.badge.earned { border-color: rgba(184,153,104,0.4); }
.badge.locked { opacity: 0.5; }
.badge .bg { font-family: var(--serif); font-size: 26px; width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center; color: var(--brass); border: 1px solid color-mix(in srgb, var(--brass) 40%, transparent); }
.badge.earned .bg { color: var(--graphite); background: var(--brass); box-shadow: 0 0 20px -4px var(--brass); border-color: transparent; }
.badge.locked .bg { color: var(--smoke); border-color: rgba(123,128,136,0.3); }
.badge .bn { font-size: 12px; letter-spacing: 0.02em; color: var(--ivory); margin-bottom: 3px; }
.badge .bd { font-size: 10.5px; color: var(--smoke); line-height: 1.35; }

/* export / import row */
.vault-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.vault-note { text-align: center; font-size: 11px; color: var(--smoke); margin-top: 14px; line-height: 1.5; opacity: 0.8; }
