/* Parlee Games — "living-room arcade after dark".
   Layout: a sticky brand bar, one featured cabinet (hero) and a shelf of cartridge-like cards.
   Dark-first; the light theme is a cool daylight version of the same palette. */
:root {
  --night: #14122b;        /* page ground */
  --night-2: #1d1a3d;      /* raised surface */
  --night-3: #2a2656;      /* borders, wells */
  --chalk: #f3f0ff;        /* main text */
  --chalk-dim: #aaa3d6;    /* secondary text */
  --sun: #ffb938;          /* the one loud accent: play, brand */
  --sun-hot: #ffcd6b;
  --sun-text: #ffb938;     /* accent when used as text */
  --ink-on-sun: #24180a;
  --berry: #ff5d8f;        /* focus ring, small highlights */
  --shadow: 0 18px 40px -18px rgb(0 0 0 / .7);
  --game: #7c6cff;         /* overridden per game from game.json "color" */

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: .8125rem; --step-0: 1rem; --step-1: 1.25rem; --step-2: 1.6rem; --step-3: clamp(2rem, 4.4vw, 3.4rem);
  --r-card: 18px; --r-btn: 999px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --night: #f4f3fb; --night-2: #ffffff; --night-3: #dedbf1;
    --chalk: #1b1838; --chalk-dim: #5d5888;
    --sun: #f5a300; --sun-hot: #ffb938; --sun-text: #a35f00; --ink-on-sun: #241703; --berry: #d6336c;
    --shadow: 0 18px 36px -20px rgb(40 30 90 / .35);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --night: #f4f3fb; --night-2: #ffffff; --night-3: #dedbf1;
  --chalk: #1b1838; --chalk-dim: #5d5888;
  --sun: #f5a300; --sun-hot: #ffb938; --sun-text: #a35f00; --ink-on-sun: #241703; --berry: #d6336c;
  --shadow: 0 18px 36px -20px rgb(40 30 90 / .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--night); color: var(--chalk);
  font: 400 var(--step-0)/1.55 var(--f-body);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--night); }
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.eyebrow { margin: 0; font: 500 var(--step--1)/1.4 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--chalk-dim); }
.section-title { margin: 0; font: 800 var(--step-2)/1.1 var(--f-display); letter-spacing: -.01em; text-wrap: balance; }

/* Top bar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--night) 86%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--night-3); }
.topbar__inner { display: flex; align-items: center; gap: 20px; min-height: 64px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand__mark svg { width: 34px; height: 34px; stroke: none; display: block; }
.brand__word { font: 800 1.3rem/1 var(--f-display); letter-spacing: -.02em; }
.brand__word span { color: var(--sun-text); margin-left: .18em; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; display: flex; align-items: center; }
.search svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--chalk-dim); pointer-events: none; }
.search input { width: 100%; min-width: 0; height: 44px; padding: 0 44px 0 42px; border-radius: var(--r-btn); border: 1px solid var(--night-3); background: var(--night-2); outline: none; transition: border-color .15s; }
.search input::placeholder { color: var(--chalk-dim); }
.search input:focus { border-color: var(--sun); }
.search kbd { position: absolute; right: 12px; font: 500 .72rem/1 var(--f-mono); padding: 4px 7px; border-radius: 6px; border: 1px solid var(--night-3); color: var(--chalk-dim); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: var(--r-btn); font-weight: 700; text-decoration: none; border: 1px solid transparent; transition: transform .15s ease, background-color .15s; cursor: pointer; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.btn--play { background: var(--sun); color: var(--ink-on-sun); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--sun) 80%, transparent); }
.btn--play:hover { background: var(--sun-hot); transform: translateY(-1px); }
.btn--ghost { border-color: var(--night-3); background: var(--night-2); }
.btn--ghost:hover { border-color: var(--chalk-dim); }
.btn--big { min-height: 54px; padding: 0 28px; font-size: 1.08rem; }

/* Hero: the featured game, shown as a lit cabinet screen */
.hero { position: relative; overflow: hidden; padding-block: 36px 28px; }
.hero::before { content: ""; position: absolute; inset: -40% -10% auto; height: 120%; background: radial-gradient(60% 55% at 30% 40%, color-mix(in srgb, var(--game) 38%, transparent), transparent 70%); pointer-events: none; }
.hero__inner { position: relative; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 52px); align-items: center; }
.hero__media { display: block; border-radius: 22px; overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%; box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--game) 45%, transparent); }
.hero__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.hero__media:hover img { transform: scale(1.03); }
.hero__copy { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hero__title { margin: 0; font: 800 var(--step-3)/.98 var(--f-display); letter-spacing: -.03em; text-wrap: balance; }
.hero__tagline { margin: 0; font-size: var(--step-1); color: var(--chalk); max-width: 34ch; }
.hero__by { margin: 0; color: var(--chalk-dim); }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* Library */
.library { display: flex; flex-direction: column; gap: 18px; padding-block: 28px 56px; }
.library__head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.count { font: 500 .85rem/1 var(--f-mono); color: var(--chalk-dim); vertical-align: middle; margin-left: 6px; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--chalk-dim); font-size: var(--step--1); }
.sort select { height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--night-3); background: var(--night-2); color: var(--chalk); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 36px; padding: 0 16px; border-radius: var(--r-btn); border: 1px solid var(--night-3); background: transparent; color: var(--chalk-dim); font-weight: 600; cursor: pointer; transition: all .15s; }
.chip:hover { color: var(--chalk); border-color: var(--chalk-dim); }
.chip.is-on { background: var(--chalk); color: var(--night); border-color: var(--chalk); }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 22px; }
.card { position: relative; min-width: 0; }
.card__link { display: flex; flex-direction: column; height: 100%; text-decoration: none; border-radius: var(--r-card); background: var(--night-2); border: 1px solid var(--night-3); overflow: hidden; transition: transform .2s ease, border-color .2s, box-shadow .2s; }
.card__link:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--game) 70%, var(--night-3)); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--game) 50%, transparent); }
.card__media { display: block; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; background: color-mix(in srgb, var(--game) 30%, var(--night-3)); }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card__link:hover .card__media img { transform: scale(1.05); }
.card__body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; flex: 1; }
.card__title { font: 800 1.2rem/1.15 var(--f-display); letter-spacing: -.01em; }
.card__tagline { color: var(--chalk-dim); font-size: .95rem; line-height: 1.4; }
.card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; font-size: var(--step--1); color: var(--chalk-dim); }
.card__author { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card__play { position: absolute; top: 12px; right: 12px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--sun); color: var(--ink-on-sun); box-shadow: 0 8px 18px -8px rgb(0 0 0 / .6); opacity: 0; transform: scale(.85); transition: all .18s ease; }
.card__play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; margin-left: 2px; }
.card:hover .card__play, .card__play:focus-visible { opacity: 1; transform: none; }
@media (hover: none) { .card__play { opacity: 1; transform: none; } }

/* Ratings */
.rating { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; font: 500 .78rem/1 var(--f-mono); color: var(--chalk-dim); }
.rating__stars { position: relative; width: 70px; height: 13px; background: var(--night-3); -webkit-mask: var(--star-mask); mask: var(--star-mask); }
.rating__fill { position: absolute; inset: 0 auto 0 0; background: var(--sun); }
:root { --star-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 13'%3E%3Cg fill='%23000'%3E%3Cpath id='s' d='m6.5 0 1.9 4 4.1.5-3 2.9.8 4.1-3.8-2-3.8 2 .8-4.1-3-2.9 4.1-.5z'/%3E%3Cuse href='%23s' x='14.4'/%3E%3Cuse href='%23s' x='28.8'/%3E%3Cuse href='%23s' x='43.2'/%3E%3Cuse href='%23s' x='57.6'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat; }

/* Empty state */
.empty { padding: 48px 16px; text-align: center; border: 1px dashed var(--night-3); border-radius: var(--r-card); color: var(--chalk-dim); }
.empty__title { font: 800 var(--step-1)/1.2 var(--f-display); color: var(--chalk); margin: 0 0 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--sun-text); text-decoration: underline; cursor: pointer; }
code { font: .88em var(--f-mono); }

/* Detail page */
.detail { position: relative; padding-block: 22px 64px; }
.detail::before { content: ""; position: absolute; inset: 0 0 auto; height: 520px; background: radial-gradient(50% 70% at 30% 0%, color-mix(in srgb, var(--game) 30%, transparent), transparent 75%); pointer-events: none; }
.detail > .wrap { position: relative; display: flex; flex-direction: column; gap: 36px; }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: var(--step--1); color: var(--chalk-dim); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--chalk); text-decoration: underline; }
.detail__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(22px, 4vw, 48px); align-items: start; margin-top: -16px; }
.gallery { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.gallery__stage { position: relative; display: block; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--game) 40%, transparent); background: var(--night-2); }
.gallery__stage img { width: 100%; height: 100%; object-fit: cover; }
.gallery__play { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px 0 14px; border-radius: var(--r-btn); background: var(--sun); color: var(--ink-on-sun); font-weight: 700; box-shadow: 0 12px 28px -10px rgb(0 0 0 / .7); transition: transform .2s ease; }
.gallery__play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.gallery__stage:hover .gallery__play { transform: translateY(-2px); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.thumb { padding: 0; border: 2px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--night-2); aspect-ratio: 16 / 9; max-width: 100%; opacity: .7; transition: opacity .15s, border-color .15s; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: 1; }
.thumb.is-on { border-color: var(--sun); opacity: 1; }
.info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.info__title { margin: 0; font: 800 var(--step-3)/.98 var(--f-display); letter-spacing: -.03em; text-wrap: balance; }
.info__tagline { margin: 0; font-size: var(--step-1); }
.info__rate { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.info__rate .rating { font-size: .85rem; }
.info__rate .rating__stars { width: 96px; height: 18px; }
.plays { font: 500 .8rem/1 var(--f-mono); color: var(--chalk-dim); }
.info__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.my-rating { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; background: var(--night-2); border: 1px solid var(--night-3); }
.my-rating__label { font-weight: 700; }
.my-rating__stars { display: flex; gap: 2px; }
.my-rating__stars button { width: 36px; height: 36px; padding: 4px; border: 0; background: none; cursor: pointer; color: color-mix(in srgb, var(--chalk-dim) 40%, transparent); transition: transform .12s, color .12s; }
.my-rating__stars button svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
.my-rating__stars button.is-lit { color: var(--sun); }
.my-rating__stars button:hover { transform: scale(1.12); }
.my-rating__note { font-size: var(--step--1); color: var(--chalk-dim); }

.detail__lower { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(22px, 4vw, 48px); }
.prose { display: flex; flex-direction: column; gap: 14px; max-width: 68ch; min-width: 0; }
.prose p { margin: 0; font-size: 1.05rem; }
.prose .section-title { font-size: var(--step-1); margin-top: 10px; }
.controls { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.controls li { padding: 10px 14px; border-radius: 12px; background: var(--night-2); border: 1px solid var(--night-3); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font: 500 .75rem/1 var(--f-mono); padding: 7px 10px; border-radius: 8px; background: var(--night-3); color: var(--chalk); }
.facts { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.facts dl { margin: 0; display: grid; border-top: 1px solid var(--night-3); }
.facts dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--night-3); }
.facts dt { color: var(--chalk-dim); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.facts__title { margin: 0; font: 800 var(--step-1)/1.2 var(--f-display); }
.changes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.changes li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.changes__v { font: 500 .8rem/1.6 var(--f-mono); color: var(--sun-text); }
.changes__d { font-size: var(--step--1); color: var(--chalk-dim); line-height: 1.8; }
.changes p { grid-column: 1 / -1; margin: 0; font-size: .95rem; }

/* Player */
body.is-playing { background: #000; height: 100%; min-height: 0; }
body.is-playing::before { background: var(--night); }
.player { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: #07060f; }
.player__bar { display: flex; align-items: center; gap: 12px; min-height: 56px; padding-block: 6px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); background: var(--night); border-bottom: 1px solid var(--night-3); }
.player__back { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--night-2); border: 1px solid var(--night-3); flex-shrink: 0; }
.player__back svg { width: 20px; height: 20px; }
.player__title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.player__title strong { font: 800 1.1rem/1.2 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__title span { font: 400 .72rem/1.4 var(--f-mono); color: var(--chalk-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__tools { display: flex; gap: 6px; margin-left: auto; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--night-3); background: var(--night-2); cursor: pointer; color: var(--chalk); }
.iconbtn:hover { border-color: var(--chalk-dim); }
.iconbtn svg { width: 19px; height: 19px; }
.player__stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; }
.player__stage iframe { display: block; border: 0; background: #000; width: min(100%, calc((100dvh - 80px) * (var(--ratio-n, 1.7778)))); aspect-ratio: var(--ratio, 16 / 9); max-height: 100%; max-width: 100%; border-radius: 14px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--game) 40%, transparent), 0 30px 80px -30px color-mix(in srgb, var(--game) 60%, transparent); }
.player__stage--fill { padding: 0; }
.player__stage--fill iframe { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.player:fullscreen .player__stage, .player__stage:fullscreen { padding: 0; }

/* Footer */
.footer { border-top: 1px solid var(--night-3); color: var(--chalk-dim); font-size: var(--step--1); }
.footer__inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 22px calc(22px + env(safe-area-inset-bottom, 0px)); }
.footer a { color: var(--chalk-dim); }

@media (max-width: 860px) {
  .hero__inner, .detail__grid, .detail__lower { grid-template-columns: minmax(0, 1fr); }
  .detail__grid { margin-top: 0; }
}
@media (max-width: 560px) {
  .brand__word span { display: none; }
  .search kbd { display: none; }
  .search input { padding-right: 14px; }
  .hero { padding-block: 20px 8px; }
  .player__title span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
