/* Base styles for Sweep pages. Pages link src/tokens.css and the Google Fonts stylesheet before this file. */
/* Shell aliases onto the design-system tokens (design/tokens.json → shared/tokens.css). */
:root {
  --bg: var(--void);
  --panel-2: var(--panel-raised);
  --line: var(--grid-line);
  --text: var(--ink);
  --muted: var(--ink-muted);
  --accent: var(--player);
  --good: var(--player-ink);
  --bad: var(--alert);
  --info: var(--player-ink);
  --radius: var(--radius-1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 var(--font-body);
  min-height: 100vh;
}
/* Faint background grid at the space-8 pitch. */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: 0.5;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--space-8) var(--space-8);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus:not(:focus-visible) { outline: none; }
a { color: var(--info); }
.wrap { max-width: 760px; margin: 0 auto; padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right)) var(--space-12) max(var(--space-4), env(safe-area-inset-left)); }

/* Header */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 0 14px; position: relative; z-index: 2; }
.topbar .back { text-decoration: none; color: var(--muted); font-size: 15px; }
.topbar h1 { display: inline-flex; align-items: center; gap: 9px; font: 400 24px/32px var(--font-display); margin: 0; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar .brand-mark { flex: none; display: block; }
.topbar .date { margin-left: auto; color: var(--muted); font: 500 13px/16px var(--font-mono); text-align: right; text-transform: uppercase; }
.icon-btn {
  display: inline-grid; place-items: center; padding: 0;
  background: var(--panel-2); border: var(--stroke-hairline) solid var(--grid-line-strong); border-radius: var(--radius-1);
  width: 38px; height: 38px; color: var(--ink);
  transition: transform 90ms cubic-bezier(.2, .9, .3, 1), border-color 140ms ease, color 140ms ease;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }
.tagline { color: var(--muted); margin: -8px 0 16px; }
a.icon-btn { display: inline-grid; place-items: center; text-decoration: none; color: inherit; }

/* Generic pieces */
.panel { background: var(--panel); border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-0); padding: var(--space-4); }
.btn {
  background: var(--panel-2); border: var(--stroke-line) solid var(--grid-line-strong); border-radius: var(--radius-1);
  padding: var(--space-3) var(--space-4); font-weight: 600; letter-spacing: 0.04em; min-height: 48px;
  transition: transform 90ms cubic-bezier(.2, .9, .3, 1), border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(0.985) translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--player); color: var(--on-player); border-color: transparent; box-shadow: var(--glow-player); text-transform: uppercase; letter-spacing: 0.14em; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.primary:active:not(:disabled) { transform: scale(0.982) translateY(1.5px); filter: brightness(0.96); }
.btn:focus-visible, .icon-btn:focus-visible { outline: var(--stroke-line) solid var(--player); outline-offset: 2px; }
.btn.primary:focus-visible { outline-color: var(--truth); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.muted { color: var(--muted); }
.big { font: 400 36px/44px var(--font-display); font-variant-numeric: tabular-nums; }
.progress { display: flex; gap: 6px; margin: 0 0 14px; }
.progress span { flex: 1; height: 4px; border-radius: 0; background: var(--grid-line); }
.progress span.done { background: var(--player); box-shadow: var(--glow-player); }
input.guess {
  min-width: 0;
  width: 100%; font: inherit; font-size: 22px; padding: var(--space-3); border-radius: var(--radius-1);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
input.guess:focus { outline: var(--stroke-line) solid var(--player); outline-offset: 1px; }
.story { border-left: var(--stroke-line) solid var(--grid-line-strong); padding: var(--space-1) 0 var(--space-1) var(--space-3); margin: var(--space-3) 0; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex;
  align-items: flex-start; justify-content: center; padding: 20px 16px max(36px, calc(16px + env(safe-area-inset-bottom))); overflow-y: auto; z-index: 80;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade-in .18s ease-out;
}
.overlay .panel { width: 100%; max-width: 520px; animation: rise-in .28s cubic-bezier(.2, .9, .3, 1.1); }
.overlay h2 { margin: 0 0 var(--space-2); font: 400 20px/26px var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; }
.overlay ul { padding-left: 1.2em; margin: 0 0 var(--space-4); display: grid; gap: var(--space-2); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* Result screen */
.result { display: grid; gap: var(--space-4); }
.result-head { display: flex; gap: var(--space-6); align-items: center; }
.result-score .big .of { font: 500 16px/1 var(--font-mono); color: var(--muted); white-space: nowrap; }
.result-score { min-width: 0; }
.result-title { font: 600 13px/16px var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; }
.result-tier { font: 600 14px/18px var(--font-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: var(--space-1); }
.result .verdict { font-size: 18px; }
.share-box {
  white-space: pre-wrap; background: var(--panel-2); border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-1); padding: var(--space-3);
  font: 500 14px/1.5 var(--font-mono);
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.stats div { text-align: center; background: var(--panel-2); border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-1); padding: var(--space-2); font: 600 12px/16px var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stats b { display: block; font: 400 22px/30px var(--font-display); color: var(--text); letter-spacing: 0; }
.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: var(--radius-1); font-weight: 600; z-index: 60; animation: rise-in .2s ease-out;
}

/* Stickers: foil cards, up to the rainbow Perfect finish (src/badge.js). */
.sticker {
  --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg;
  position: relative; flex: none; width: var(--w); aspect-ratio: 5 / 7; border-radius: calc(var(--w) * 0.08);
  transform: perspective(700px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .25s ease-out, box-shadow .25s; transform-style: preserve-3d;
  animation: sticker-deal .7s cubic-bezier(.2, 1.4, .4, 1) both, sticker-float 5s ease-in-out .7s infinite;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45), 0 2px 0 rgba(255, 255, 255, .15) inset;
  background: var(--foil-base); overflow: hidden; isolation: isolate; cursor: grab; touch-action: none;
}
.sticker.live { transition: transform .05s linear; animation: sticker-deal .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.sticker-face {
  position: absolute; inset: calc(var(--w) * 0.08); border-radius: calc(var(--w) * 0.05);
  background: rgba(10, 8, 7, .8); display: grid; grid-template-rows: 1fr auto auto; place-items: center;
  padding: calc(var(--w) * 0.06) 0 calc(var(--w) * 0.07); color: #fff; z-index: 1;
}
.sticker-emblem { grid-area: 1 / 1; width: 78%; height: auto; filter: drop-shadow(0 0 6px hsl(var(--hue) 90% 60% / .6)); }
.sticker-emblem polygon { fill: hsl(var(--hue) 85% 55%); stroke: var(--foil-hi); stroke-width: 3; stroke-linejoin: round; }
.sticker-emoji { grid-area: 1 / 1; font-size: calc(var(--w) * 0.2); position: relative; z-index: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.sticker-date { font: 700 calc(var(--w) * 0.11) / 1 var(--font-mono); letter-spacing: 0.04em; }
.sticker-tier { font: 600 calc(var(--w) * 0.075) / 1 var(--font-body); letter-spacing: 0.18em; text-transform: uppercase; color: var(--foil-hi); margin-top: calc(var(--w) * 0.03); }
.sticker-foil, .sticker-glare { position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit; }
.sticker-foil {
  background: linear-gradient(115deg, transparent 20%, rgba(255, 255, 255, .55) 38%, transparent 46%, transparent 60%, rgba(255, 255, 255, .3) 68%, transparent 76%);
  background-size: 250% 250%; background-position: var(--mx) var(--my); mix-blend-mode: overlay;
  animation: sheen 4.5s ease-in-out infinite;
}
.sticker.live .sticker-foil { animation: none; }
.sticker-glare { background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, .5), transparent 55%); mix-blend-mode: soft-light; opacity: 0; transition: opacity .2s; }
.sticker.live .sticker-glare { opacity: 1; }
.tier-bronze { --foil-base: linear-gradient(135deg, #4a230c, #b86a2c 30%, #6e3714 50%, #f0b17a 70%, #5a2a0e); --foil-hi: #f0b17a; }
.tier-silver { --foil-base: linear-gradient(135deg, #5d6873, #e9eef3 30%, #808b96 50%, #ffffff 70%, #69747f); --foil-hi: #f4f7fa; }
.tier-gold { --foil-base: linear-gradient(135deg, #6b4a00, #ffd659 30%, #a87900 50%, #fff3b8 70%, #7a5600); --foil-hi: #ffe58a; box-shadow: 0 10px 30px rgba(255, 200, 60, .35), 0 2px 0 rgba(255, 255, 255, .3) inset; }
.tier-none { --foil-base: repeating-linear-gradient(45deg, #1d1a18 0 8px, #24201d 8px 16px); --foil-hi: #6b625b; filter: grayscale(1); opacity: .7; animation: none; }
.tier-none .sticker-emblem polygon { fill: #3a3430; }
/* Perfect: rainbow foil that shifts with the pointer, plus sparkle. */
.tier-diamond {
  --foil-hi: #ffffff;
  --foil-base: conic-gradient(from 0deg at var(--mx) var(--my), #ff4d8d, #ffb84d, #f9ff6b, #4dffb2, #4dc3ff, #9a6bff, #ff4d8d);
  box-shadow: 0 0 34px rgba(170, 120, 255, .55), 0 10px 30px rgba(0, 0, 0, .5);
}
.tier-diamond::before {
  content: ''; position: absolute; inset: 0; z-index: 0; mix-blend-mode: color-dodge; opacity: .55;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0) 0 6px, rgba(255, 255, 255, .55) 7px, rgba(255, 255, 255, 0) 9px 16px);
  background-size: 200% 200%; background-position: var(--mx) var(--my);
}
.tier-diamond::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; mix-blend-mode: screen;
  background:
    radial-gradient(circle at 18% 22%, #fff 0 1.5px, transparent 2.5px), radial-gradient(circle at 78% 14%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 86% 62%, #fff 0 1.5px, transparent 2.5px), radial-gradient(circle at 12% 78%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 52% 90%, #fff 0 1.5px, transparent 2.5px), radial-gradient(circle at 64% 40%, #fff 0 1px, transparent 2px);
  animation: twinkle 1.6s ease-in-out infinite alternate;
}
.tier-diamond .sticker-face { background: rgba(10, 8, 7, .4); }
.tier-diamond .sticker-tier { background: linear-gradient(90deg, #ff4d8d, #ffb84d, #4dffb2, #4dc3ff, #9a6bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tier-diamond:not(.live) { animation: sticker-deal .7s cubic-bezier(.2, 1.4, .4, 1) both, sticker-float 5s ease-in-out .7s infinite, perfect-drift 6s linear infinite; }
@keyframes sticker-deal { 0% { transform: perspective(700px) translateY(40px) rotateZ(-14deg) scale(.4); opacity: 0; } 60% { opacity: 1; } }
@keyframes sticker-float { 50% { transform: perspective(700px) rotateX(4deg) rotateY(-6deg) rotateZ(1.5deg) translateY(-3px); } }
@keyframes sheen { 0%, 100% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } }
@keyframes perfect-drift { 0% { --mx: 20%; --my: 20%; } 25% { --mx: 80%; --my: 30%; } 50% { --mx: 70%; --my: 80%; } 75% { --mx: 25%; --my: 70%; } 100% { --mx: 20%; --my: 20%; } }
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }
@property --mx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --my { syntax: '<percentage>'; inherits: true; initial-value: 50%; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  .topbar { gap: 6px; padding: 4px 0 10px; }
  .topbar h1 { font-size: 18px; line-height: 26px; white-space: nowrap; gap: 7px; }
  .topbar .date { font-size: 11px; }
  .icon-btn { width: 40px; height: 40px; }
  .big { font-size: 28px; line-height: 36px; }
  .result-head { gap: var(--space-4); }
}
@media (max-width: 420px) {
  .topbar .date { display: none; }
  .result-head .sticker { --w: 112px !important; }
  .result-score .big .of { display: block; margin-top: var(--space-1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Account: header button and sign-in dialog (src/account.js). */
.acct-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; flex: none;
  background: transparent; color: var(--player-ink); border: var(--stroke-line) solid var(--player); border-radius: var(--radius-1);
  font: 600 12px/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  transition: transform 90ms cubic-bezier(.2, .9, .3, 1), background-color 140ms ease, box-shadow 140ms ease;
}
.acct-btn:hover { background: color-mix(in srgb, var(--player) 14%, transparent); box-shadow: var(--glow-player); }
.acct-btn:active { transform: scale(0.95); }
.acct-btn:focus-visible { outline: var(--stroke-line) solid var(--player); outline-offset: 2px; }
/* Signed in: the player's initial on the Perfect rainbow foil, with the same sheen, drift and sparkle. */
.acct-btn.signed-in {
  --mx: 30%; --my: 30%;
  position: relative; overflow: hidden; isolation: isolate; padding: 0; width: 38px; justify-content: center;
  color: #0a0807; border-color: transparent; font: 400 17px/1 var(--font-display); letter-spacing: 0;
  background: conic-gradient(from 0deg at var(--mx) var(--my), #ff4d8d, #ffb84d, #f9ff6b, #4dffb2, #4dc3ff, #9a6bff, #ff4d8d);
  box-shadow: 0 0 14px rgba(170, 120, 255, .45);
  animation: perfect-drift 6s linear infinite;
}
.acct-btn.signed-in::before {
  content: ''; position: absolute; inset: 0; z-index: -1; mix-blend-mode: color-dodge; opacity: .5;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0) 0 5px, rgba(255, 255, 255, .6) 6px, rgba(255, 255, 255, 0) 8px 13px);
  background-size: 200% 200%; background-position: var(--mx) var(--my);
}
.acct-btn.signed-in::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at 22% 24%, #fff 0 1px, transparent 2px), radial-gradient(circle at 80% 30%, #fff 0 1px, transparent 2px), radial-gradient(circle at 70% 82%, #fff 0 1px, transparent 2px);
  animation: twinkle 1.6s ease-in-out infinite alternate;
}
.acct-btn.signed-in span { position: relative; z-index: 1; text-shadow: 0 0 6px rgba(255, 255, 255, .85); }
.acct-btn.signed-in:hover { background: conic-gradient(from 0deg at var(--mx) var(--my), #ff4d8d, #ffb84d, #f9ff6b, #4dffb2, #4dc3ff, #9a6bff, #ff4d8d); box-shadow: 0 0 22px rgba(170, 120, 255, .75); }
.acct-form { display: grid; gap: var(--space-3); margin: var(--space-4) 0; }
.acct-form form { display: grid; gap: var(--space-2); }
.acct-form label { font: 600 12px/16px var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.acct-form input {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; padding: var(--space-3); min-height: 48px;
  border: var(--stroke-hairline) solid var(--grid-line-strong); border-radius: var(--radius-1); background: var(--panel-2); color: var(--text);
}
.acct-form input:focus { outline: var(--stroke-line) solid var(--player); outline-offset: 1px; }
.acct-google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.acct-or { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font: 600 12px/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; }
.acct-or::before, .acct-or::after { content: ''; flex: 1; border-top: var(--stroke-hairline) solid var(--grid-line); }
.acct-msg { margin: 0; min-height: 1.4em; }
.acct-msg:empty { display: none; }
.acct-legal { margin: 0; font-size: 13px; }
.acct-delete { margin: var(--space-4) 0 0; text-align: center; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--alert); }
.btn.danger { background: var(--alert); color: #fff; border-color: transparent; }
/* Phones: brand and icon buttons on the first row; the date picker and Sign up on the second. */
.topbar > .icon-btn { flex: none; }
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar:has(.date)::after { content: ''; order: 8; flex-basis: 100%; height: 0; }
  .topbar h1 { margin-right: auto; }
  .topbar .date, .topbar .date.day-picker { order: 9; display: inline-flex; margin: 0 auto 0 -6px; }
  .acct-btn { height: 36px; padding: 0 12px; }
  .topbar:has(.date) .acct-btn { order: 10; }
  .acct-btn.signed-in { width: 36px; }
}

/* Footer: privacy link and content credit. */
.site-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: var(--space-6) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); color: var(--muted); font: 500 12px/18px var(--font-body); letter-spacing: 0.04em; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--ink); }
