/* Archon game layer (game.js): top-bar streak, XP ring and league chip, the Play view and
   celebrations. Game colours never appear on a chart, so a chart line is never read as a
   game mark. Only transform and opacity animate on hot paths; confetti has its own canvas. */

:root {
  --earned: #c9b6ff;
  --streak: #ff7a45;
  --freeze: #7cc7ff;
  --gold: #f5c84c;
  --zone-up: rgba(80, 210, 193, .12);
  --zone-down: rgba(237, 112, 136, .12);
  --confetti: #97fce4, #c9b6ff, #f5c84c, #ff7a45, #7cc7ff, #50d2c1;
  --bronze: #d08b5b;
  --silver: #b9c6cb;
  --platinum: #9fe7dd;
  --diamond: #7cc7ff;
  --dur-xp: 700ms;
  --ease-out: cubic-bezier(.22, .8, .2, 1);
  --spring: linear(0, .22 8%, .6 18%, .88 30%, 1.02 44%, 1.03 52%, 1.01 66%, 1);
  --spring-pop: linear(0, .35 10%, .85 22%, 1.12 36%, 1.06 48%, .98 62%, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    --earned: #6b4fd8;
    --streak: #b13d0a;
    --freeze: #1f6fb2;
    --gold: #8a6500;
    --zone-up: rgba(10, 140, 125, .10);
    --zone-down: rgba(190, 40, 70, .10);
    --bronze: #8f4f22;
    --silver: #56666c;
    --platinum: #1d7a6d;
    --diamond: #1f6fb2;
  }
}
.tier-bronze { --tier: var(--bronze); }
.tier-silver { --tier: var(--silver); }
.tier-gold { --tier: var(--gold); }
.tier-platinum { --tier: var(--platinum); }
.tier-diamond { --tier: var(--diamond); }
.tier-archon { --tier: var(--accent-edge); }

/* ---------------------------------------------------------------- top bar */
.game-bar { display: flex; align-items: center; gap: 4px; }
.game-bar a { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.game-bar a:hover { background: var(--inset); }
.g-flame svg { width: 22px; height: 22px; fill: var(--streak); transform-origin: 50% 90%; }
.g-flame.cold svg { fill: var(--ink-3); opacity: .7; }
.g-flame.out svg { fill: none; stroke: var(--ink-3); stroke-width: 1.6; }
.g-ring { position: relative; padding: 0 5px !important; }
.g-ring svg { display: block; transform: rotate(-90deg); }
.g-ring circle { fill: none; stroke-width: 3.5; }
.g-ring .track { stroke: var(--line); }
.g-ring .fill { stroke: var(--earned); stroke-linecap: round; transition: stroke-dashoffset var(--dur-xp) var(--spring); }
.g-ring .g-lv { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; }
.g-ring.pop svg { animation: g-pop 420ms var(--spring-pop); }
.g-league svg { width: 20px; height: 20px; fill: var(--tier, var(--ink-3)); }
.g-league b { font-size: 14px; }

/* The Play tab's count of quests left, or "!" when the chest or the streak needs a visit. */
nav.main a[data-nav="play"] { position: relative; }
.nav-pip { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--streak); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }

/* ---------------------------------------------------------------- Play */
.g-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.g-main, .g-side { display: grid; gap: 20px; min-width: 0; }
.g-off { display: none; }
.g-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.g-play .card .btn { margin-top: 12px; }

.g-bar { height: 8px; border-radius: 4px; background: var(--inset); overflow: hidden; margin: 12px 0 8px; }
.g-bar i { display: block; height: 100%; border-radius: 4px; background: var(--earned); transform-origin: 0 50%; transition: transform var(--dur-xp) var(--spring); }
.g-bar.thin { height: 6px; margin: 6px 0 4px; }

.g-streak-head, .g-level-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.g-flame.big svg { width: 48px; height: 48px; }
.g-flame.big, .g-flame.huge { display: inline-grid; }
.g-big { font-size: 34px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; }
.g-big span { font-size: 17px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.g-freezes { display: flex; align-items: center; gap: 2px; margin-top: 4px; }
.g-ice svg { width: 16px; height: 16px; color: var(--freeze); display: block; }
.g-freezes .g-ice:last-of-type { margin-right: 6px; }
.g-saver { border-radius: var(--radius-sm); padding: 14px; background: var(--warn-soft); display: grid; gap: 4px; }
.g-saver b { color: var(--streak); }
.g-hosted { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-2); }
.g-hosted b { color: var(--ink); }
.g-disc { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--earned); color: #160b33; font-weight: 700; font-size: 18px; flex: none; }

.g-quest-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.g-quest { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--divider); border-radius: var(--radius-sm); }
.g-q-title { font-weight: 600; }
.g-quest.g-done .g-q-title { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.g-quest.g-done .g-bar i { background: var(--pos); }
.g-check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); position: relative; }
.g-quest.g-done .g-check { background: var(--pos); border-color: var(--pos); }
.g-quest.g-done .g-check::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid var(--on-accent); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.g-xp { color: var(--earned); font-size: 15px; white-space: nowrap; }
.g-chest { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--inset); }
.g-chest p { flex: 1; min-width: 160px; }
.g-chest-art svg { width: 48px; height: 40px; display: block; overflow: visible; }
.g-chest-art .body { fill: var(--gold); opacity: .85; }
.g-chest-art .lid { fill: var(--gold); transform-origin: 4px 17px; transition: transform 600ms var(--spring-pop); }
.g-chest-art .latch { fill: var(--panel); }
.g-chest:not(.ready) .g-chest-art { filter: grayscale(1); opacity: .55; }
.g-chest.ready { background: color-mix(in srgb, var(--gold) 12%, var(--inset)); }
.g-chest-art.open .lid { transform: translateY(-6px) rotate(-18deg); }

.g-lg-head { align-items: center; justify-content: flex-start; flex-wrap: nowrap; }
.g-crest svg { width: 40px; height: 40px; fill: var(--tier); display: block; }
.g-place { margin-left: auto; text-align: right; }
.g-place b { font-size: 26px; font-weight: 700; }
.g-gap { margin: 0 0 12px; font-weight: 600; }
.g-table { list-style: none; margin: 0; padding: 0; position: relative; }
.g-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.g-row + .g-row { box-shadow: inset 0 1px 0 var(--divider); }
.g-row.up { background: var(--zone-up); }
.g-row.down { background: var(--zone-down); }
.g-row.you { outline: 2px solid var(--accent-edge); outline-offset: -2px; background: var(--panel); position: sticky; top: calc(72px + env(safe-area-inset-top, 0px)); bottom: calc(var(--tabbar) + 8px); z-index: 1; box-shadow: var(--shadow); }
.g-row.you.up { background: color-mix(in srgb, var(--pos) 14%, var(--panel)); }
.g-row.you.down { background: color-mix(in srgb, var(--neg) 14%, var(--panel)); }
.g-row em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--on-accent); background: var(--accent); padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.g-rank { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 600; }
.g-crown svg { width: 16px; height: 16px; fill: var(--gold); display: block; }
.g-handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.g-wxp { font-weight: 600; }
.g-band { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 12px 12px 6px; color: var(--ink-2); }
.g-band.up { color: var(--pos); }
.g-band.down { color: var(--neg); }
.g-rule { margin-top: 14px; }

.g-shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 10px; }
.g-badge { display: grid; justify-items: center; text-align: center; gap: 4px; font-size: 14px; line-height: 1.3; }
.g-badge b { font-weight: 600; }
.g-medal { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; border: 2px dashed var(--line); }
.g-medal svg { width: 30px; height: 30px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linejoin: round; }
.g-badge.earned .g-medal { border: 0; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--gold) 55%, #fff), var(--gold) 60%, color-mix(in srgb, var(--gold) 70%, #000)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }
.g-badge.earned .g-medal svg { fill: #fff; stroke: none; }

.g-pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.g-pick { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 8px; }
.g-pick-head { display: flex; align-items: center; gap: 10px; }
.g-window { width: 28px; height: 28px; border-radius: 50%; flex: none; background: conic-gradient(var(--earned) calc(var(--f) * 360deg), var(--inset) 0); mask: radial-gradient(circle, transparent 9px, #000 10px); }
.g-pick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g-pick-btns .chip { min-height: 44px; text-align: center; }
.g-your { color: var(--ink-2); }
.g-your b { color: var(--ink); }

.g-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-top: 6px; font-weight: 500; }

/* ---------------------------------------------------------------- toasts, seal, XP flight */
.game-toasts { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
/* A sheet holds the bottom of the screen, so toasts move up out of its way. */
body:has(.g-cel.modal) .game-toasts { bottom: auto; top: calc(76px + env(safe-area-inset-top, 0px)); }
.g-toast { pointer-events: auto; border: 1px solid var(--line); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); border-radius: 999px; padding: 10px 18px; font: 600 15px var(--sans); font-variant-numeric: tabular-nums; cursor: pointer; animation: g-rise 260ms var(--ease-out); max-width: 100%; }
.g-toast.xp { border-color: color-mix(in srgb, var(--earned) 50%, var(--line)); }
.g-toast.seal { border-color: var(--accent-edge); }
.g-toast.out { opacity: 0; transform: translateY(6px); transition: opacity 180ms, transform 180ms; }
.g-chip { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; padding: 4px 10px; border-radius: 999px; background: var(--earned); color: #160b33; font-weight: 700; font-size: 14px; will-change: transform, opacity; }
.g-seal { animation: g-seal 950ms var(--ease-out); }

/* ---------------------------------------------------------------- celebrations */
.g-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 55; }
.g-cel { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: calc(88px + env(safe-area-inset-top, 0px)) 16px 16px; pointer-events: none; }
.g-cel.modal { place-items: center; pointer-events: auto; background: rgba(4, 6, 12, .62); animation: g-fade 200ms ease-out; }
.g-cel-card { pointer-events: auto; width: min(380px, 100%); text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); padding: 28px 24px 24px; display: grid; justify-items: center; gap: 8px; animation: g-in 520ms var(--spring-pop); }
.g-cel-card .btn { margin-top: 10px; width: 100%; }
.g-cel-art { margin-bottom: 4px; perspective: 600px; }
.g-reward { font-size: clamp(36px, 9vw, 56px); line-height: 1; font-weight: 700; letter-spacing: -.03em; }
.g-cel-line { font-size: 17px; }
.g-cel-sound { margin-top: 4px; }
.g-disc.huge { width: 96px; height: 96px; font-size: 42px; box-shadow: 0 0 0 6px color-mix(in srgb, var(--earned) 25%, transparent); }
.g-flame.huge svg { width: 96px; height: 96px; fill: var(--streak); animation: g-ignite 700ms var(--spring-pop); }
.g-medal.huge { width: 96px; height: 96px; border: 0; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--gold) 55%, #fff), var(--gold) 60%, color-mix(in srgb, var(--gold) 70%, #000)); animation: g-reveal 900ms var(--spring-pop); }
.g-medal.huge.xp { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--earned) 55%, #fff), var(--earned) 65%); }
.g-medal.huge svg { width: 46px; height: 46px; fill: #fff; stroke: none; }
.g-chest-art.huge svg { width: 96px; height: 80px; }
.g-chest-art.huge .lid { transform: translateY(-10px) rotate(-22deg); }
.g-cel.out { opacity: 0; transition: opacity 180ms; }
/* Reduced motion: no confetti and no travel; the card cross-fades in with a still glow. */
.g-cel.calm .g-cel-card, .g-cel.calm .g-cel-art * { animation: g-fade 150ms linear; }
.g-cel.calm .g-cel-card { box-shadow: 0 0 0 1px var(--accent-edge), 0 0 48px -8px color-mix(in srgb, var(--accent) 45%, transparent); }

@keyframes g-pop { 0% { transform: rotate(-90deg) scale(1); } 40% { transform: rotate(-90deg) scale(1.22); } 100% { transform: rotate(-90deg) scale(1); } }
@keyframes g-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes g-fade { from { opacity: 0; } }
@keyframes g-in { from { opacity: 0; transform: translateY(12px) scale(.9); } }
@keyframes g-ignite { from { transform: scale(.6); opacity: .4; } }
@keyframes g-reveal { 0% { transform: scale(.4) rotate(-25deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes g-seal { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 900px) {
  .g-grid { grid-template-columns: minmax(0, 1fr); }
  .g-main, .g-side { display: contents; }
  .g-streak { order: 1; } .g-level { order: 2; } .g-quests { order: 3; } .g-league { order: 4; }
  .g-picks { order: 5; } .g-badges { order: 6; } .g-dial { order: 7; }
}
@media (max-width: 640px) {
  /* On a phone the game sits where the wordmark was; the mark stays as the home link. */
  body.game-on .brand { font-size: 0; gap: 0; }
  .top-right { gap: 4px; }
  .game-bar { gap: 0; }
  .game-bar a { padding: 0 5px; font-size: 14px; }
  .nav-pip { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
  .g-row.you { top: calc(64px + env(safe-area-inset-top, 0px)); }
  .g-cel { padding-top: calc(72px + env(safe-area-inset-top, 0px)); }
  .g-cel.modal { place-items: end center; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .g-ring .fill, .g-bar i, .g-chest-art .lid { transition: none; }
  .g-ring.pop svg, .g-seal, .g-toast, .g-flame.huge svg, .g-medal.huge { animation: none; }
}
@media (forced-colors: active) {
  .g-row.up, .g-row.down { border-left: 2px solid CanvasText; }
  .nav-pip, .g-disc { forced-color-adjust: none; }
}
