:root {
  --ink: #1c0b4e;
  --ink-soft: #2b1470;
  --ink-line: #3c2295;
  --surface: #f5f2fe;
  --paper: #ffffff;
  --line: #e0d9f7;
  --text: #21104f;
  --muted: #6a5b9e;
  --pop: #ffe45c;
  --pop-ink: #2b1470;
  --violet: #4a22b8;
  --live: #21c98a;
  --amber: #ffc53d;
  --amber-bg: #fff4d6;
  --danger: #d62b4e;
  --danger-bg: #fdeaee;
  --display: "Fredoka", "Archivo", system-ui, sans-serif;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 14px;
  --shadow: 0 18px 40px -22px rgba(28, 11, 78, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface);
  color: var(--text);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--violet); }
code, .stamp { font-family: var(--mono); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }

button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
button:hover { border-color: var(--muted); }
button:active { transform: translateY(1px); }
.primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border: 1px solid #e9cb3f;
  border-radius: 999px;
  background: var(--pop);
  color: var(--pop-ink);
  padding: 11px 24px;
  font-weight: 700;
  cursor: pointer;
}
.primary:hover { background: #ffed94; border-color: #e9cb3f; }
.primary:disabled { opacity: 0.55; cursor: progress; }
button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }

/* ---------- top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 16px; }
.wordmark {
  display: inline-flex; align-items: center; gap: 9px; color: var(--pop); text-decoration: none;
  font-family: var(--display); font-size: 27px; font-weight: 600; letter-spacing: -0.01em; line-height: 1;
}
.wordmark img { width: 34px; height: 34px; display: block; }
.topbar a.quiet { color: #d6cdf6; }
.topbar .tag { font-family: var(--mono); font-size: 12px; color: #b9b1e0; border: 1px solid var(--ink-line); border-radius: 999px; padding: 3px 10px; }
.topbar .spacer { flex: 1; }
.topbar a.quiet { color: #cdc6ef; text-decoration: none; font-weight: 600; }
.topbar a.quiet:hover { color: #fff; }

/* ---------- hero ---------- */

.hero {
  position: relative; max-width: 1180px; margin: 24px auto 0; border-radius: 22px; overflow: hidden;
  background: var(--ink); min-height: 330px; display: grid; align-items: end; isolation: isolate;
}
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(95deg, rgba(28, 11, 78, 0.94) 12%, rgba(28, 11, 78, 0.6) 55%, rgba(28, 11, 78, 0.2) 100%);
}
.hero-copy { padding: 34px 36px; color: #fff; max-width: 720px; }
.hero-kicker { font-family: var(--mono); font-size: 12px; color: #b9b1e0; margin-bottom: 10px; }
.hero h1 { font-family: var(--display); font-size: clamp(34px, 6vw, 60px); font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.hero-mascot { position: absolute; right: 34px; bottom: 24px; width: clamp(82px, 13vw, 132px); opacity: 0.95; filter: drop-shadow(0 16px 30px rgba(0,0,0,0.45)); }
.hero p { margin: 10px 0 0; color: #ded6fb; max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
@media (max-width: 760px) { .hero-mascot { display: none; } }
.hero-actions .ghost {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: transparent; border: 1px solid #6a4fd0; border-radius: 999px;
  padding: 10px 20px; font-weight: 600; color: #fff; cursor: pointer;
}
.hero-actions .ghost:hover { border-color: #fff; }

/* ---------- layout ---------- */

.shell {
  max-width: 1180px; margin: 0 auto; padding: 28px 24px 72px;
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start;
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.section-head .count { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ---------- game cards ---------- */

.game-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 18px; }
.game-row {
  position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.game-row:hover, .game-row:focus-within { transform: translateY(-3px); border-color: transparent; box-shadow: var(--shadow); }
.cover { position: relative; aspect-ratio: 8 / 5; background: var(--ink); }
.cover canvas { display: block; width: 100%; height: 100%; }
.cover .play-link {
  position: absolute; right: 12px; bottom: 12px; background: var(--pop); color: var(--pop-ink); border-radius: 999px;
  padding: 8px 18px; font-weight: 700; font-size: 15px; text-decoration: none;
  box-shadow: 0 8px 20px -8px rgba(255, 228, 92, 0.85);
  opacity: 0; transform: translateY(6px); transition: opacity 0.15s ease, transform 0.15s ease;
}
.game-row:hover .play-link, .game-row:focus-within .play-link { opacity: 1; transform: none; }
@media (hover: none) { .cover .play-link { opacity: 1; transform: none; } }

.card-body { padding: 14px 16px 16px; display: grid; gap: 8px; }
.game-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.game-title:hover { color: var(--violet); }
.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.genre { display: inline-flex; align-items: center; gap: 6px; }
.genre .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--violet); }
.game-kind, .stamp { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--muted); }
.game-detail { margin: 0; font-size: 13px; color: var(--muted); }
.game-detail .flagged { display: block; margin-top: 6px; color: var(--danger); font-weight: 600; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- publish rail ---------- */

.publish { position: sticky; top: 86px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.publish h2 { font-family: var(--display); font-size: 20px; font-weight: 600; }
.publish .hint { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 22px 16px; text-align: center;
  background: #faf9ff; transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.over { border-color: var(--violet); background: #f1ebff; }
.dropzone strong { display: block; font-size: 15px; }
.dropzone span { font-size: 13px; color: var(--muted); }
.dropzone input[type="file"] { display: none; }
.dropzone .pick { margin-top: 12px; }
.publish form { display: grid; gap: 8px; margin-top: 14px; }
.publish label { font-size: 13px; font-weight: 600; }
.publish input[type="text"], .publish select, .publish textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); }
.publish textarea { font: 12.5px/1.5 var(--mono); min-height: 130px; resize: vertical; }
.publish .primary { justify-self: start; margin-top: 4px; }

.result { margin-top: 14px; font-size: 14px; }
.notice { border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.notice h3 { font-size: 14px; margin-bottom: 4px; }
.notice ul { margin: 0; padding-left: 18px; }
.notice.good { background: #e8fbf3; color: #0d7a52; }
.notice.caution { background: var(--amber-bg); }
.notice.alarm { background: var(--danger-bg); color: var(--danger); }

/* ---------- player ---------- */

.player { min-height: 100vh; background: var(--ink); color: #fff; display: grid; grid-template-rows: auto 1fr; }
.toolbar { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--ink-line); }
.toolbar .back { color: #cdc6ef; text-decoration: none; font-weight: 600; }
.toolbar h1 { font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.toolbar .game-id { font-family: var(--mono); font-size: 12px; color: #8e86bd; }
.toolbar .spacer { flex: 1; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar button { background: transparent; border-color: var(--ink-line); color: #fff; padding: 7px 14px; }
.toolbar button:hover { border-color: #fff; }
.toolbar button[aria-pressed="true"] { background: #fff; color: var(--ink); border-color: #fff; }
.segmented { display: inline-flex; background: #2b1470; border-radius: 999px; padding: 3px; gap: 3px; }
.segmented button { border: 0; padding: 6px 14px; }

.bay { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; padding: 18px 20px 24px; min-height: 0; }
.stage {
  position: relative; border-radius: 18px; overflow: hidden; background: #0b0818;
  border: 1px solid var(--ink-line); min-height: 420px;
}
.stage::before {
  content: ""; position: absolute; inset: -40% 30% 60% -10%;
  background: radial-gradient(closest-side, var(--stage-glow, #6c5ce7), transparent);
  opacity: 0.5; filter: blur(40px); pointer-events: none;
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage.stopped { border-color: var(--danger); }
.stopped-notice { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.stopped-notice h2 { font-family: var(--display); font-size: 25px; font-weight: 600; }
.stopped-notice p { margin: 0; max-width: 44ch; color: #cdc6ef; }
.stopped-notice button { background: #fff; color: var(--ink); border-color: #fff; }

.sidebar { display: grid; grid-template-rows: auto 1fr; gap: 14px; min-height: 0; }
.panel { background: #24115e; border: 1px solid var(--ink-line); border-radius: 16px; padding: 16px; min-height: 0; display: grid; grid-template-rows: auto auto 1fr; gap: 8px; }
.panel h2 { font-family: var(--display); font-size: 17px; font-weight: 600; }
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 3ch 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--ink-line); }
.board .rank { color: #8e86bd; font-variant-numeric: tabular-nums; }
.board strong { font-variant-numeric: tabular-nums; }
.muted { color: #9d95c9; font-size: 13px; margin: 6px 0 0; }
.meter { height: 6px; border-radius: 999px; background: #2a2354; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--live); width: 0%; transition: width 0.4s ease; }
.meter.done span { background: var(--pop); }
.panel .stamp { border-color: var(--ink-line); color: #b3a8e4; }

.traffic-log { list-style: none; margin: 0; padding: 0; overflow: auto; font: 12px/1.6 var(--mono); color: #c9c2ea; }
.traffic-log li { padding: 3px 0; border-bottom: 1px solid #251f4a; overflow-wrap: anywhere; }
.traffic-log time { color: #7a72ab; margin-right: 8px; }
.traffic-log .failed { color: #ff7d9e; }
.traffic-log .signal span { color: #9d95c9; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 999px;
  background: #fff; color: var(--text); box-shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.6);
  max-width: min(560px, calc(100vw - 32px));
}
.toast button { background: var(--pop); border-color: #e9cb3f; color: var(--pop-ink); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .publish { position: static; }
  .bay { grid-template-columns: 1fr; }
  .stage { height: 62vh; min-height: 0; }
  .player { min-height: 0; }
  .traffic-log { max-height: 240px; }
}
@media (max-width: 560px) {
  .hero { min-height: 260px; border-radius: 16px; margin-inline: 12px; }
  .hero-copy { padding: 22px 20px; }
  .shell { padding: 22px 16px 60px; }
  .topbar-inner { padding: 12px 16px; }
  .topbar .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .game-row:hover { transform: none; }
}


/* ---------- browsing and reactions ---------- */

.browse { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.tabs { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.tabs button { border: 0; padding: 7px 16px; background: transparent; border-radius: 999px; font-size: 14px; }
.tabs button[aria-pressed="true"] { background: var(--violet); color: #fff; }
.search { flex: 1; min-width: 180px; }
.search input {
  width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; background: var(--paper);
}
.card-foot { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.card-foot .plays { font-family: var(--mono); font-size: 11px; }
.like {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.like[aria-pressed="true"] { background: #f1ebff; border-color: var(--violet); color: var(--violet); }
.like .heart { font-size: 13px; }
.reactions { display: flex; flex-wrap: wrap; gap: 8px; }
.reactions button { padding: 6px 12px; font-size: 13px; background: transparent; border-color: var(--ink-line); color: #ded6fb; }
.reactions button[aria-pressed="true"] { background: var(--pop); color: var(--pop-ink); border-color: var(--pop); }
.reactions .tally { font-family: var(--mono); font-size: 11px; opacity: 0.8; margin-left: 4px; }
