:root {
  --bg: #e9e5da;
  --card: #ffffff;
  --glass: rgba(255, 255, 255, 0.9);
  --line: #d9d5ca;
  --text: #14161f;
  --muted: #5d6272;
  --violet: #6b4eff;
  --violet-deep: #4b32c9;
  --ban: #e5384f;
  --ban-text: #c0213a;
  --approve: #1fa971;
  --approve-text: #0f7a4f;
  --warn: #f2b100;
  --warn-text: #8a6400;
  --soft: #eeebe2;
  --scrim: rgba(233, 229, 218, 0.55);
  --scrim-strong: rgba(233, 229, 218, 0.9);
  --display: 'Space Grotesk', Inter, Arial, sans-serif;
  --body: Inter, system-ui, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --card: #1e2130;
    --glass: rgba(30, 33, 48, 0.92);
    --line: #33384d;
    --text: #f1efe8;
    --muted: #a3a8b8;
    --ban-text: #ff7d8f;
    --approve-text: #4fd3a0;
    --warn-text: #f2c64a;
    --soft: #262a3b;
    --scrim: rgba(14, 16, 23, 0.55);
    --scrim-strong: rgba(14, 16, 23, 0.88);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font: 16px/1.5 var(--body); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
h1, h2 { font-family: var(--display); line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; }
h2 { font-size: 15px; letter-spacing: 0.02em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; -webkit-user-select: none; user-select: none; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.grow { flex: 1; }
.pill { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; min-width: 0; }
.pill b { font-family: var(--display); font-size: 15px; font-variant-numeric: tabular-nums; }
.pill .k { font: 500 10px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pill .ico { flex: none; color: var(--muted); }
.pill.karma .ico { color: var(--violet); }
.pill.day, .pill.karma, .pill.susp { flex: none; }
.bar { display: block; width: 64px; height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--violet); border-radius: 3px; }
.pill.where { overflow: hidden; }
.pill.where b { overflow: hidden; text-overflow: ellipsis; }
.mood { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.mood.generous { color: var(--approve-text); }
.mood.irritable, .mood.petty { color: var(--warn-text); }
.mood.apocalyptic { color: var(--ban-text); font-weight: 600; }
.pill.susp .bar { width: 90px; }
.pill.susp .bar i { background: var(--approve); transition: background 200ms; }
.pill.susp.warm .bar i { background: var(--warn); }
.pill.susp.hot .bar i { background: var(--ban); }
.pill.susp.hot { border-color: var(--ban); }
.pill.susp b { min-width: 26px; text-align: right; }
.icon { pointer-events: auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); color: var(--text); padding: 0; flex: none; }
.icon:active { transform: scale(0.94); }

#toasts { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(460px, calc(100vw - 220px)); display: flex; flex-direction: column-reverse; gap: 6px; }
.toast { display: flex; gap: 8px; align-items: baseline; padding: 8px 12px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); border-left: 4px solid var(--violet); font-size: 13px; line-height: 1.35; animation: toast-in 220ms var(--ease); transition: opacity 240ms, transform 240ms; }
.toast b { flex: none; font: 700 10px/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.toast.boss { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--ban); }
.toast.good { border-left-color: var(--approve); }
.toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

#b-dash { pointer-events: auto; position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--violet); background: color-mix(in srgb, var(--violet) 82%, transparent); color: #fff; font: 700 15px var(--display); touch-action: none; -webkit-user-select: none; user-select: none; transition: transform 100ms, opacity 150ms; }
#b-dash:active { transform: scale(0.93); }
#b-dash.cooling { opacity: 0.45; }
@media (hover: hover) and (pointer: fine) { #b-dash { width: 64px; height: 64px; font-size: 13px; opacity: 0.85; } }

#stick { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
#stick::before { content: ''; position: absolute; left: -52px; top: -52px; width: 104px; height: 104px; border-radius: 50%; border: 2px solid var(--violet); background: color-mix(in srgb, var(--violet) 12%, transparent); }
#stick i { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; background: var(--violet); opacity: 0.85; }

/* Screens */
#screen { position: fixed; inset: 0; display: none; overflow-y: auto; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
#screen.on { display: flex; background: var(--scrim); }
#screen.on.over, #screen.on.collection { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { margin: auto; width: min(520px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22); animation: panel-in 320ms var(--ease); }
.panel.wide { width: min(980px, 100%); }
.panel.small-panel { width: min(360px, 100%); }
@keyframes panel-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.logo { display: flex; align-items: center; gap: 10px; font: 700 28px/1 var(--display); letter-spacing: -0.01em; }
.logo img { border-radius: 10px; }
.lede { font-size: 17px; color: var(--muted); }
.small { font-size: 13px; color: var(--muted); }
.eyebrow { font: 500 11px/1.5 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row .btn { flex: 1 1 auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.foot { font-size: 11px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; transition: transform 120ms var(--ease), background 120ms; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.primary:active { background: var(--violet-deep); }
.btn.big { width: 100%; min-height: 54px; font-size: 17px; font-family: var(--display); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font: 700 10px/1.6 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; background: var(--soft); color: var(--muted); }
.tag.rare { background: var(--violet); color: #fff; }
.tag.legendary { background: var(--warn); color: #14161f; }
.closing { font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ban-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; line-height: 1.4; min-height: 86px; }
.ban-card.locked { color: var(--muted); border-style: dashed; }
.ban-card.locked p { font-style: italic; }
.ban-card.got.rare { border-color: var(--violet); }
.ban-card.got.legendary { border-color: var(--warn); }

#note { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 10px; background: #14161f; color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 200ms, transform 200ms; white-space: pre-line; }
#note.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 620px) {
  h1 { font-size: 25px; }
  .panel { padding: 18px; gap: 12px; }
  .hud-top { gap: 6px; padding: 8px; }
  .pill { height: 36px; padding: 0 8px; gap: 6px; font-size: 12px; }
  .pill b { font-size: 13px; }
  .pill.day .bar { width: 28px; }
  .pill.where, .pill .k, #b-sound { display: none; }
  .pill.susp .bar { width: 46px; }
  .icon { width: 36px; height: 36px; }
  #toasts { top: 52px; bottom: auto; width: calc(100vw - 20px); flex-direction: column; }
  .toast { font-size: 12px; padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .toast { animation: none; }
}

/* Achievements */
:root { --lock-a: #dcd8ce; --lock-b: #cfcbc0; --lock-c: #c1bdb2; --lock-icon: #aeaa9e; }
@media (prefers-color-scheme: dark) {
  :root { --lock-a: #474c61; --lock-b: #3a3f52; --lock-c: #2e3344; --lock-icon: #555b73; }
}
.panel.ach { gap: 22px; }
.sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.sec-head h2 { font-size: 20px; letter-spacing: 0; }
.divider { font: 500 11px/1.5 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 14px; border-top: 1px solid var(--line); }
.link { border: 0; background: none; padding: 10px 4px; min-height: 44px; font-weight: 600; font-size: 15px; white-space: nowrap; border-radius: 8px; }
.link:hover { text-decoration: underline; }

.rail { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; padding: 4px 0; }
.rail::-webkit-scrollbar { display: none; }
.rail.snap { scroll-snap-type: x mandatory; }
.rail.all { flex-wrap: wrap; overflow: visible; row-gap: 18px; }
.rail-wrap { position: relative; }
.rail-btn { position: absolute; top: 34px; z-index: 1; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); padding: 0; transition: opacity 150ms, transform 120ms var(--ease); }
.rail-btn.prev { left: -10px; }
.rail-btn.next { right: -10px; }
.rail-btn:active { transform: scale(0.94); }
.rail-btn:disabled { opacity: 0; pointer-events: none; }
.dots { display: flex; justify-content: center; gap: 8px; min-height: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--text); }

.badge { flex: 0 0 20%; min-width: 132px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 10px; border: 0; border-radius: 14px; background: none; text-align: center; scroll-snap-align: start; transition: background 120ms, transform 160ms var(--ease); }
.badge:hover { background: var(--soft); }
.badge:hover .medal { transform: translateY(-3px) scale(1.04); }
.medal { display: block; flex: none; transition: transform 180ms var(--ease); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22)); }
.medal.locked { filter: none; }
.b-name { margin-top: 8px; font-weight: 700; font-size: 15px; line-height: 1.25; text-wrap: balance; }
.badge.locked .b-name { color: var(--muted); }
.b-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.b-bar { display: block; width: 84%; height: 5px; margin-top: 7px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.b-bar i { display: block; height: 100%; min-width: 3px; border-radius: 3px; background: var(--violet); }
.b-bar.wide { width: 100%; height: 7px; margin-top: 0; }

#detail { position: fixed; inset: 0; display: none; padding: 16px; }
#detail.on { display: grid; place-items: center; }
.detail-back { position: absolute; inset: 0; background: rgba(8, 9, 14, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.detail { position: relative; width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 24px 22px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4); text-align: center; animation: panel-in 260ms var(--ease); }
.detail .medal { animation: medal-in 520ms var(--ease); margin-bottom: 6px; }
.detail h2 { font-size: 24px; letter-spacing: 0; }
.d-desc { font-size: 16px; text-wrap: pretty; }
.detail .btn { align-self: stretch; margin-top: 8px; }
@keyframes medal-in { from { transform: scale(0.5) rotate(-18deg); opacity: 0; } 60% { transform: scale(1.08) rotate(4deg); opacity: 1; } }

.unlocks { display: grid; gap: 8px; }
.unlock { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); text-align: left; transition: background 120ms; }
.unlock:hover { background: var(--soft); }
.unlock.fresh { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 9%, var(--card)); }
.unlock.fresh .medal { animation: medal-in 560ms var(--ease) 200ms backwards; }
.unlock span { display: flex; flex-direction: column; min-width: 0; }
.unlock b { font-family: var(--display); font-size: 16px; line-height: 1.2; }
.unlock small { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

@media (max-width: 620px) {
  .badge { flex-basis: 38%; min-width: 118px; }
  .badge .medal { width: 88px; height: 88px; }
  .b-name { font-size: 14px; }
  .rail-btn { display: none; }
  .sec-head h2 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .detail, .detail .medal, .unlock.fresh .medal { animation: none; }
  .badge:hover .medal { transform: none; }
}

/* Title and end screens: few words, big targets */
#screen.on.title { background: radial-gradient(circle at 50% 45%, var(--scrim-strong) 0, var(--scrim) 70%); }
.hero { margin: auto; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; animation: panel-in 320ms var(--ease); }
.logo.big { font-size: 52px; gap: 14px; letter-spacing: -0.02em; }
.logo.big img { border-radius: 16px; }
.tagline { font: 600 19px/1.3 var(--display); color: var(--muted); }
.btn.play { width: 100%; min-height: 62px; border-radius: 16px; font: 700 20px var(--display); box-shadow: 0 6px 0 var(--violet-deep), 0 16px 30px rgba(75, 50, 201, 0.35); transition: transform 90ms, box-shadow 90ms; }
.btn.play:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--violet-deep); }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: 6px; }
kbd { padding: 3px 8px; border-radius: 7px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--card); color: var(--text); font: 700 12px var(--mono); }
.hero-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chipbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.chipbtn.static { color: var(--muted); }
button.chipbtn:active { transform: scale(0.96); }
.hero .foot { max-width: 300px; opacity: 0.8; }

.panel.result { width: min(400px, 100%); align-items: center; text-align: center; gap: 10px; padding: 22px; }
.result h1 { font-size: 28px; }
.result.ending h1 { color: var(--approve-text); }
.r-medal { border: 0; background: none; padding: 0; border-radius: 50%; margin-top: -4px; }
.r-medal .medal { animation: medal-in 560ms var(--ease) 120ms backwards; }
.r-medal.fresh .medal { filter: drop-shadow(0 0 18px rgba(107, 78, 255, 0.55)) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22)); }
.r-reason { font-size: 16px; color: var(--muted); text-wrap: pretty; max-width: 34ch; }
.r-story { text-align: left; align-self: stretch; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--soft); font: 600 13px var(--body); font-variant-numeric: tabular-nums; }
.chip svg { width: 14px; height: 14px; color: var(--muted); }
.chip.bad { background: color-mix(in srgb, var(--ban) 16%, var(--card)); color: var(--ban-text); }
.result .unlocks { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.result .unlock { gap: 8px; padding: 4px 12px 4px 4px; border-radius: 24px; border-color: var(--violet); background: color-mix(in srgb, var(--violet) 9%, var(--card)); }
.result .unlock b { font-size: 14px; }
.result .unlock .medal { animation: medal-in 560ms var(--ease) 300ms backwards; filter: none; }
.appeal-result { display: flex; align-items: center; gap: 10px; text-align: left; font-size: 13px; color: var(--muted); }
.appeal-result b { flex: none; padding: 2px 8px; border: 2px solid var(--ban); border-radius: 6px; color: var(--ban-text); font: 700 12px var(--mono); letter-spacing: 0.08em; transform: rotate(-6deg); }
.result .btn.play { margin-top: 8px; }
.iconrow { display: flex; justify-content: center; gap: 4px; align-self: stretch; margin-top: 6px; }
.iconbtn { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 52px; padding: 8px 4px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.iconbtn:hover { background: var(--soft); color: var(--text); }
.iconbtn:disabled { opacity: 0.4; pointer-events: none; }
.iconbtn svg { width: 20px; height: 20px; }
@media (max-width: 620px) {
  .logo.big { font-size: 42px; }
  .logo.big img { width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero, .r-medal .medal, .result .unlock .medal { animation: none; }
}
