/* ============================================================
   Campus Arcade — design tokens and primitives
   ============================================================ */
:root {
  --bg: #070a17;
  --bg-soft: #0b1024;
  --panel: rgba(22, 28, 58, .58);
  --panel-solid: #141a34;
  --panel-2: rgba(31, 39, 78, .5);
  --line: rgba(255, 255, 255, .085);
  --line-strong: rgba(255, 255, 255, .16);
  --ink: #f5f7ff;
  --muted: #a7b0d3;
  --dim: #8b95bd;
  --violet: #8b7dff;
  --indigo: #6172ff;
  --amber: #ffb547;
  --amber-ink: #2a1a00;
  --mint: #3ddc97;
  --coral: #ff6b81;
  --sky: #56ccf2;
  --grad-brand: linear-gradient(120deg, #8b7dff, #5b8cff 52%, #35d0c0);
  --grad-warm: linear-gradient(120deg, #ffb547, #ff7b6b);
  --grad-panel: linear-gradient(160deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .012));
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .75);
  --shadow-sm: 0 10px 26px -14px rgba(0, 0, 0, .7);
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --font: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --topbar-h: 68px;
}

* { box-sizing: border-box; }
*::selection { background: rgba(139, 125, 255, .35); color: #fff; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-playing { overscroll-behavior: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; letter-spacing: -.025em; font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
canvas { display: block; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 6px;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 200;
  padding: 10px 16px; border-radius: 10px; background: var(--amber); color: #211500;
  font-weight: 700; transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- atmosphere ---------- */
.atmosphere {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(93, 78, 255, .22), transparent 60%),
    radial-gradient(900px 600px at 92% 8%, rgba(255, 181, 71, .10), transparent 62%),
    linear-gradient(180deg, #070a17 0%, #080c1c 48%, #060913 100%);
}
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.orb-a { width: 44vw; height: 44vw; left: -14vw; top: 24vh; background: radial-gradient(circle, rgba(120, 90, 255, .5), transparent 70%); animation: drift 26s ease-in-out infinite; }
.orb-b { width: 34vw; height: 34vw; right: -8vw; top: 54vh; background: radial-gradient(circle, rgba(53, 208, 192, .32), transparent 70%); animation: drift 32s ease-in-out -8s infinite reverse; }
.orb-c { width: 26vw; height: 26vw; left: 52vw; top: -8vw; background: radial-gradient(circle, rgba(255, 181, 71, .22), transparent 70%); animation: drift 24s ease-in-out -4s infinite; }
.grid-glow {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 25%, transparent 75%);
  opacity: .7;
}
@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3vw, -4vh, 0) scale(1.08); }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 clamp(14px, 4vw, 38px);
  background: rgba(8, 11, 26, .72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; color: #fff;
  background: var(--grad-brand);
  box-shadow: 0 8px 22px -8px rgba(124, 108, 255, .9), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-size: 17px; letter-spacing: -.02em; }
.brand-text em { font-style: normal; font-size: 10px; letter-spacing: .32em; text-transform: uppercase; color: var(--amber); margin-top: 3px; }
.topnav { display: flex; gap: 4px; margin-left: 10px; }
.topnav a {
  padding: 9px 14px; border-radius: 999px; color: var(--muted);
  font-size: 14px; font-weight: 600; transition: color .2s, background .2s;
}
.topnav a:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.topnav a.active { color: var(--ink); background: rgba(139, 125, 255, .16); box-shadow: inset 0 0 0 1px rgba(139, 125, 255, .32); }
.topbar-side { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hud-chip {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 999px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--muted);
  transition: border-color .2s, background .2s;
}
.hud-chip:hover { border-color: var(--line-strong); background: rgba(255,255,255,.07); }
.hud-chip-label { color: var(--ink); font-size: 12px; letter-spacing: .02em; }
.hud-chip-bar { width: 46px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.hud-chip-bar span { display: block; height: 100%; width: 0; background: var(--grad-brand); border-radius: inherit; transition: width .6s var(--ease); }
.hud-streak { color: var(--amber); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.045);
  color: var(--muted); cursor: pointer; transition: .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .mute-slash { opacity: 0; }
.icon-btn[aria-pressed="false"] { color: var(--dim); }
.icon-btn[aria-pressed="false"] .mute-slash { opacity: 1; }
.icon-btn[aria-pressed="false"] .wave-1 { opacity: 0; }

/* ---------- layout ---------- */
#view { min-height: calc(100vh - var(--topbar-h) - 120px); outline: none; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 72px; }
.shell.narrow { width: min(880px, calc(100% - 32px)); }
.shell.game { width: min(860px, calc(100% - 24px)); padding-top: 22px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber);
}
.eyebrow.violet { color: var(--violet); }
.lead { color: var(--muted); font-size: 16px; max-width: 62ch; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(28px, 3.4vw, 40px); }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 56ch; }

/* ---------- panels & cards ---------- */
.card {
  position: relative;
  background: var(--grad-panel), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card.pad { padding: 22px; }
.card-hover { transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.card-hover:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.section { margin-top: 38px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { font-size: 20px; }
.section-head a { font-size: 13px; font-weight: 700; color: var(--amber); }
.section-head a:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: rgba(255,255,255,.06);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--btn-bg); color: var(--ink);
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  cursor: pointer; transition: transform .18s var(--ease), box-shadow .2s, background .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.09); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--grad-brand); border-color: transparent; color: #0b0d1c;
  box-shadow: 0 12px 30px -12px rgba(110, 110, 255, .9), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-primary:hover { background: var(--grad-brand); box-shadow: 0 16px 36px -10px rgba(110, 110, 255, .95); }
.btn-warm {
  background: var(--grad-warm); border-color: transparent; color: #2b1700;
  box-shadow: 0 12px 30px -14px rgba(255, 150, 60, .9), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn-warm:hover { background: var(--grad-warm); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-icon { width: 46px; padding: 0; }
.btn .ico { font-size: 16px; line-height: 1; }

/* ---------- pills, chips & tabs ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; color: var(--muted);
  white-space: nowrap;
}
.pill.amber { background: rgba(255,181,71,.13); border-color: rgba(255,181,71,.3); color: #ffce7a; }
.pill.mint { background: rgba(61,220,151,.12); border-color: rgba(61,220,151,.28); color: #77f0bd; }
.pill.violet { background: rgba(139,125,255,.14); border-color: rgba(139,125,255,.32); color: #c1b8ff; }
.pill.coral { background: rgba(255,107,129,.12); border-color: rgba(255,107,129,.28); color: #ff9aa8; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.04);
  color: var(--muted); border-radius: 999px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .2s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: rgba(139,125,255,.18); border-color: rgba(139,125,255,.45); color: #d6d0ff; }
.chip.amber[aria-pressed="true"] { background: rgba(255,181,71,.16); border-color: rgba(255,181,71,.42); color: #ffd894; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; transition: .2s;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: rgba(139,125,255,.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(139,125,255,.35); }

/* ---------- progress & meters ---------- */
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.075); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--grad-brand); transition: width .7s var(--ease); }
.bar.warm > span { background: var(--grad-warm); }
.bar.thin { height: 5px; }
.meter-row { display: grid; grid-template-columns: 96px 1fr 42px; align-items: center; gap: 12px; font-size: 12.5px; }
.meter-row .meter-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-row .meter-val { text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- avatars ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 19px;
  background: linear-gradient(150deg, rgba(139,125,255,.5), rgba(53,208,192,.28));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.avatar.lg { width: 66px; height: 66px; font-size: 31px; border-width: 2px; }
.avatar.sm { width: 32px; height: 32px; font-size: 15px; }

/* ---------- fx, toasts, modal ---------- */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 120; }
.toast-stack {
  position: fixed; right: 18px; bottom: 18px; z-index: 130;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 240px; max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px; border-radius: 16px;
  background: rgba(20, 26, 52, .96);
  border: 1px solid rgba(139,125,255,.3);
  box-shadow: var(--shadow);
  animation: toast-in .4s var(--ease) both;
  pointer-events: auto;
}
.toast.out { animation: toast-out .3s var(--ease) both; }
.toast-ico {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: rgba(255,181,71,.15); font-size: 17px;
}
.toast strong { display: block; font-size: 13.5px; line-height: 1.25; }
.toast > div span { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

.modal-back {
  position: fixed; inset: 0; z-index: 140; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 6, 14, .72); backdrop-filter: blur(8px);
  animation: fade-in .2s ease both;
}
.modal {
  width: min(460px, 100%); padding: 26px; border-radius: var(--r-lg);
  background: #141a34; border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: pop-in .3s var(--ease) both;
}
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.empty { padding: 34px 20px; text-align: center; color: var(--dim); font-size: 14px; }
.kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 6px; background: rgba(255,255,255,.07); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.site-foot {
  width: min(1180px, calc(100% - 32px)); margin: 0 auto;
  padding: 24px 0 34px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--dim);
}
.foot-links { display: flex; gap: 10px; flex-wrap: wrap; }
.foot-links a:hover { color: var(--ink); }

/* ---------- embed mode ---------- */
body.embed .topbar, body.embed .site-foot { display: none; }
body.embed .shell { padding-top: 8px; }
body.embed { --topbar-h: 0px; background: transparent; }
body.embed .shell, body.embed .shell.narrow, body.embed .shell.game { width: 100%; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  /* The level chip wraps its label next to the nav before the topbar runs out of room. */
  #xpChip { display: none; }
}
@media (max-width: 780px) {
  :root { --topbar-h: 60px; }
  .brand-text { display: none; }
  .topnav { margin-left: 0; gap: 0; }
  .topnav a { padding: 8px 10px; font-size: 13px; }
  .hud-chip { padding: 0 10px; height: 32px; }
  .shell { padding-top: 22px; }
  .site-foot { flex-direction: column; }
}
@media (max-width: 560px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .brand-mark { width: 34px; height: 34px; }
  .topnav a { padding: 8px 4px; font-size: 11.5px; }
  #streakChip { display: none; }
  .hud-credits { padding: 0 9px; font-size: 11px; }
  .shell, .shell.narrow, .shell.game { width: calc(100% - 20px); }
  .card.pad { padding: 17px; }
  .page-head h1 { font-size: 26px; }
  .btn { min-height: 44px; padding: 0 18px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
}
@media (max-width: 400px) {
  /* Credits live on the Rewards page too; on the narrowest phones the topbar keeps only mute. */
  #creditsChip { display: none; }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .orb { animation: none; }
}
