/* ==========================================================================
   LUDORA — casual games portal UI
   Layout follows the pattern players already know from the big arcade sites:
   a fixed icon rail on the left, a search-first top bar, and a dense grid of
   rounded square game tiles that fills the whole viewport.
   Two skins: [data-theme="light"] (default) and [data-theme="dark"].
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens */
:root {
  --bg:         #f2f3f9;
  --surface:    #ffffff;
  --surface-2:  #eceef7;
  --surface-3:  #dfe2f0;
  --text:       #16161f;
  --text-dim:   #5f6178;
  --text-mute:  #8d90a8;
  --line:       #e2e4f0;

  --brand:      #6a4cff;
  --brand-2:    #8b74ff;
  --brand-ink:  #ffffff;
  --brand-soft: rgba(106, 76, 255, .12);

  --pink:   #ff4d8d;
  --orange: #ff7a29;
  --lime:   #22c55e;
  --cyan:   #14b8d4;
  --yellow: #ffc619;
  --red:    #f43f5e;

  --r-xl: 26px;
  --r-lg: 20px;
  --r:    14px;
  --r-sm: 10px;
  --r-pill: 999px;

  --shadow-sm: 0 2px 6px rgba(22, 22, 31, .06);
  --shadow:    0 6px 18px rgba(22, 22, 31, .09);
  --shadow-lg: 0 18px 44px -14px rgba(22, 22, 31, .28);
  --shadow-tile-hover: 0 14px 28px -10px rgba(22, 22, 31, .32);

  --font-display: "Fredoka", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --font-body:    "Nunito Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --rail-w:     232px;
  --rail-mini:  76px;
  --top-h:      64px;
  --gap:        14px;
  --pad:        clamp(14px, 2vw, 22px);
}

[data-theme="dark"] {
  --bg:         #101017;
  --surface:    #1a1a24;
  --surface-2:  #22222f;
  --surface-3:  #2c2c3c;
  --text:       #f3f3f8;
  --text-dim:   #a9abc2;
  --text-mute:  #767992;
  --line:       #2a2a38;

  --brand:      #8b74ff;
  --brand-2:    #a893ff;
  --brand-ink:  #12101c;
  --brand-soft: rgba(139, 116, 255, .18);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .4);
  --shadow:    0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 44px -14px rgba(0, 0, 0, .7);
  --shadow-tile-hover: 0 14px 30px -10px rgba(0, 0, 0, .75);
}

/* Accent presets chosen in the admin panel */
[data-accent="blue"]   { --brand: #2f7dff; --brand-2: #5c9bff; --brand-soft: rgba(47,125,255,.14); }
[data-accent="pink"]   { --brand: #ff4d8d; --brand-2: #ff77a8; --brand-soft: rgba(255,77,141,.14); }
[data-accent="orange"] { --brand: #ff7a29; --brand-2: #ff9a5c; --brand-soft: rgba(255,122,41,.14); }
[data-accent="green"]  { --brand: #17b871; --brand-2: #3fd38f; --brand-soft: rgba(23,184,113,.14); }
[data-accent="cyan"]   { --brand: #0fb2cf; --brand-2: #3fcbe4; --brand-soft: rgba(15,178,207,.14); }

/* ---------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}
img, svg, video, iframe { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.15; font-family: var(--font-display); font-weight: 600; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.2em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand); color: var(--brand-ink); }
kbd {
  font: 700 .8em/1 var(--font-body);
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; padding: .2em .45em; display: inline-block;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand); color: var(--brand-ink); padding: 12px 18px;
  border-radius: 0 0 var(--r) 0; font-weight: 800;
}
.skip-link:focus { left: 0; }
.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;
}

/* ---------------------------------------------------------------- Shell */
.shell { display: flex; min-height: 100vh; }
.shell__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.page { padding: var(--pad); flex: 1 1 auto; }
.page--narrow { max-width: 880px; margin-inline: auto; width: 100%; }

/* ------------------------------------------------------------ Left rail */
.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  z-index: 40;
}
.rail::-webkit-scrollbar { width: 6px; }

.rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; height: var(--top-h); flex: 0 0 var(--top-h);
}
.rail__mark {
  width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center;
  border-radius: 12px; color: var(--brand-ink);
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 4px 12px -2px var(--brand-soft);
  transition: transform .2s cubic-bezier(.2,.9,.3,1.5);
}
.rail__brand:hover .rail__mark { transform: rotate(-8deg) scale(1.08); }
.rail__name {
  font-family: var(--font-display); font-weight: 600;
  font-size: 21px; letter-spacing: -.01em; white-space: nowrap;
}
.rail__logo { max-height: 34px; width: auto; }

.rail__nav { padding: 6px 10px 18px; display: flex; flex-direction: column; gap: 2px; }
.rail__label {
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-mute); padding: 16px 12px 6px; white-space: nowrap;
}
.railitem {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r);
  font-weight: 700; font-size: 14.5px; color: var(--text-dim);
  white-space: nowrap; transition: background .14s, color .14s, transform .14s;
}
.railitem svg { width: 20px; height: 20px; flex: 0 0 20px; }
.railitem:hover { background: var(--surface-2); color: var(--text); }
.railitem[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.railitem__dot {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 9px;
  display: grid; place-items: center; color: #fff;
  background: var(--dot, var(--brand));
}
.railitem__dot svg { width: 15px; height: 15px; }
.railitem__count { margin-left: auto; font-size: 11.5px; font-weight: 800; color: var(--text-mute); }

.rail__foot {
  margin-top: auto; padding: 14px 16px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-mute);
}
.rail__foot a { display: inline-block; padding: 3px 0; }
.rail__foot a:hover { color: var(--brand); }
.rail__social { display: flex; gap: 6px; margin-bottom: 10px; }
.rail__social a {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border-radius: 10px; background: var(--surface-2); color: var(--text-dim);
}
.rail__social a:hover { background: var(--brand); color: var(--brand-ink); }
.rail__social svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky; top: 0; z-index: 35;
  height: var(--top-h); flex: 0 0 var(--top-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--pad);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: none; align-items: center; gap: 8px; }
.topbar__spacer { flex: 1 1 auto; }

.searchbox { position: relative; flex: 1 1 460px; max-width: 520px; }
.searchbox input {
  width: 100%; height: 42px; padding: 0 44px 0 42px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  font-size: 14.5px; font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.searchbox input::placeholder { color: var(--text-mute); font-weight: 500; }
.searchbox input:focus {
  outline: 0; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.searchbox__icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-mute); pointer-events: none;
}
.searchbox__icon svg { width: 18px; height: 18px; }
.searchbox button {
  position: absolute; right: 5px; top: 5px; width: 32px; height: 32px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
}
.searchbox button svg { width: 16px; height: 16px; }
.searchbox__results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 70;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  max-height: 62vh; overflow: auto; display: none; padding: 6px;
}
.searchbox__results.is-open { display: block; }
.searchbox__results a {
  display: flex; gap: 10px; align-items: center; padding: 7px 8px;
  border-radius: var(--r); font-size: 14px; font-weight: 700;
}
.searchbox__results a:hover { background: var(--surface-2); }
.searchbox__results img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }

.iconbtn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 50%;
  transition: background .14s, color .14s, transform .12s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn--menu { display: none; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px;
  transition: transform .14s cubic-bezier(.2,.9,.3,1.4), box-shadow .14s, background .14s, filter .14s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(.98); }
.btn svg { width: 17px; height: 17px; }
.btn--primary {
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-2) 100%);
  color: var(--brand-ink); border-color: transparent;
  box-shadow: 0 6px 16px -6px var(--brand);
}
.btn--primary:hover { filter: brightness(1.06); box-shadow: 0 12px 24px -8px var(--brand); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); box-shadow: none; transform: none; }
.btn--soft { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn--big { padding: 15px 30px; font-size: 17px; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--block { width: 100%; }

/* ---------------------------------------------------------------- Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 800; font-size: 13.5px; color: var(--text-dim);
  transition: .14s;
}
.chip svg { width: 15px; height: 15px; }
a.chip:hover { background: var(--surface-2); color: var(--text); transform: translateY(-2px); }
.chip.is-on, .chip--solid { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.chip--colour { color: #fff; border-color: transparent; background: var(--c, var(--brand)); }
.chip--colour:hover { color: #fff; filter: brightness(1.08); }

/* ---------------------------------------------------------------- Sections */
.section { margin-bottom: 30px; }
.section__head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.section__head h2 {
  margin: 0; font-size: clamp(19px, 2.2vw, 24px);
  display: flex; align-items: center; gap: 10px;
}
.section__head h2 .ico {
  width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; background: var(--ico, var(--brand));
}
.section__head h2 .ico svg { width: 18px; height: 18px; }
.section__head p { margin: 2px 0 0; font-size: 13.5px; color: var(--text-mute); font-weight: 600; }
.section__head .spacer { flex: 1 1 auto; }
.section__more {
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--brand);
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px;
  border-radius: var(--r-pill); background: var(--brand-soft);
}
.section__more:hover { filter: brightness(1.05); }
.section__more svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: var(--gap);
  grid-auto-flow: dense;
}
.tiles--sm { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); }
.tiles--lg { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.tile {
  position: relative; display: block;
  aspect-ratio: 1 / 1; border-radius: var(--r-lg);
  overflow: hidden; background: var(--surface-3);
  box-shadow: var(--shadow-sm);
  transform: translateZ(0);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.5), box-shadow .18s;
}
.tile:hover, .tile:focus-visible { transform: translateY(-5px) scale(1.02); box-shadow: var(--shadow-tile-hover); z-index: 2; }
.tile--wide { grid-column: span 2; aspect-ratio: 2 / 1; }
.tile--big  { grid-column: span 2; grid-row: span 2; aspect-ratio: 1 / 1; }
@media (max-width: 560px) {
  .tile--big { grid-column: span 2; grid-row: span 2; }
  .tile--wide { grid-column: span 2; }
}

.tile img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s cubic-bezier(.2,.7,.3,1);
}
.tile:hover img { transform: scale(1.07); }
.tile__veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10,10,16,0) 40%, rgba(10,10,16,.82) 100%);
}
.tile__name {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 10px 12px 11px; color: #fff;
  font-family: var(--font-display); font-weight: 600;
  font-size: 14px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 6px rgba(0,0,0,.55);
}
.tile--big .tile__name { font-size: 22px; padding: 16px 18px 18px; }
.tile--wide .tile__name { font-size: 17px; }

.tile__tags { position: absolute; top: 9px; left: 9px; z-index: 3; display: flex; gap: 5px; }
.tag {
  font-family: var(--font-display); font-weight: 600;
  font-size: 10.5px; letter-spacing: .02em;
  padding: 4px 9px; border-radius: var(--r-pill); color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.tag--hot { background: linear-gradient(140deg, #ff5a2b, #ff2d55); }
.tag--new { background: linear-gradient(140deg, #22c55e, #12a150); }
.tag--top { background: linear-gradient(140deg, #ffc619, #ff9500); color: #2a1a00; }

.tile__stat {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(10,10,16,.58); backdrop-filter: blur(4px);
  color: #fff; font-size: 11px; font-weight: 800;
  padding: 4px 8px; border-radius: var(--r-pill);
}
.tile__stat svg { width: 11px; height: 11px; }

.tile__play {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  opacity: 0; transition: opacity .18s;
}
.tile:hover .tile__play { opacity: 1; }
.tile__play span {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(255,255,255,.94); color: #16161f;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.5);
  transform: scale(.7); transition: transform .2s cubic-bezier(.2,.9,.3,1.6);
}
.tile:hover .tile__play span { transform: scale(1); }
.tile__play svg { width: 22px; height: 22px; margin-left: 3px; }
.tile--big .tile__play span { width: 74px; height: 74px; }

/* Horizontal shelf */
.shelf { position: relative; }
.shelf__track {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: minmax(154px, 1fr);
  gap: var(--gap); overflow-x: auto;
  padding: 4px 2px 10px; scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.shelf__track::-webkit-scrollbar { display: none; }
.shelf__track > * { scroll-snap-align: start; }
.shelf__nav { display: flex; gap: 6px; }

/* ------------------------------------------------------------ Category cards */
.cats { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.cat {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg); padding: 16px;
  min-height: 116px; display: flex; flex-direction: column; justify-content: flex-end;
  color: #fff; background: linear-gradient(150deg, var(--c, var(--brand)) 0%, color-mix(in srgb, var(--c, var(--brand)) 62%, #000) 100%);
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.5), box-shadow .18s;
}
.cat:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cat::after {
  content: ""; position: absolute; right: -26px; top: -26px;
  width: 108px; height: 108px; border-radius: 50%;
  background: rgba(255,255,255,.14);
  transition: transform .35s;
}
.cat:hover::after { transform: scale(1.3); }
.cat__icon {
  position: relative; width: 38px; height: 38px; margin-bottom: auto;
  display: grid; place-items: center; border-radius: 12px;
  background: rgba(255,255,255,.22); backdrop-filter: blur(3px);
}
.cat__icon svg { width: 20px; height: 20px; }
.cat h3 { position: relative; font-size: 17px; margin: 10px 0 1px; }
.cat span { position: relative; font-size: 12.5px; font-weight: 700; opacity: .85; }

/* ---------------------------------------------------------------- Game page */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 1180px) { .play { grid-template-columns: 1fr; } }

.crumbs {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--text-mute); margin-bottom: 12px;
}
.crumbs a:hover { color: var(--brand); }
.crumbs i { font-style: normal; opacity: .5; }

.stage {
  border-radius: var(--r-lg); overflow: hidden;
  background: #0c0c12; box-shadow: var(--shadow);
}
.stage__frame { position: relative; aspect-ratio: var(--ratio, 16 / 10); background: #0c0c12; }
.stage__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage:fullscreen { border-radius: 0; }
.stage:fullscreen .stage__frame { aspect-ratio: auto; height: calc(100vh - 58px); }

.stage__cover { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; overflow: hidden; }
.stage__cover > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scale(1.08); filter: blur(14px) saturate(1.2) brightness(.5);
}
.stage__cover-inner {
  position: relative; text-align: center; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: 420px;
}
.stage__cover-art {
  width: 128px; height: 128px; border-radius: 26px; object-fit: cover;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.8);
}
.stage__cover h2 { color: #fff; font-size: clamp(21px, 3vw, 30px); margin: 0; }
.stage__cover p { color: rgba(255,255,255,.75); font-size: 13.5px; margin: 0; font-weight: 600; }
.stage__cover .btn--primary { box-shadow: 0 10px 26px -8px var(--brand); }

.stage__bar {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: #14141c; color: #fff;
}
.stage__bar b { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; }
.stage__live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 800; color: #4ade80;
}
.stage__live i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; animation: blip 1.6s infinite; }
@keyframes blip { 50% { opacity: .25; transform: scale(.7); } }
.stage__tools { margin-left: auto; display: flex; gap: 6px; }
.stage__tool {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border-radius: 11px; border: 0; color: #fff;
  background: rgba(255,255,255,.1); transition: .14s;
}
.stage__tool:hover { background: var(--brand); color: var(--brand-ink); }
.stage__tool.is-active { background: #4ade80; color: #08210f; }
.stage__tool svg { width: 17px; height: 17px; }

/* ------------------------------------------------------- End-of-run card */
.endcard {
  position: absolute; inset: 0; z-index: 8;
  display: grid; place-items: center;
  padding: 16px; overflow-y: auto;
  background: rgba(10, 10, 16, .9); backdrop-filter: blur(6px);
  animation: endcardIn .22s ease-out;
}
.endcard[hidden] { display: none; }
@keyframes endcardIn { from { opacity: 0; } }
.endcard__inner { width: min(100%, 560px); text-align: center; }
.endcard__close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .12);
}
.endcard__close:hover { background: var(--brand); }
.endcard h3 {
  color: #fff; font-size: clamp(20px, 3.4vw, 28px); margin: 0 0 12px;
}
.endcard__scores { display: flex; gap: 26px; justify-content: center; margin-bottom: 16px; }
.endcard__scores div { display: flex; flex-direction: column; gap: 2px; }
.endcard__scores span {
  font-size: 10.5px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: rgba(255, 255, 255, .55);
}
.endcard__scores b { font-size: 26px; color: #fff; font-variant-numeric: tabular-nums; }
.endcard__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.endcard__actions .btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; }
.endcard__actions .btn--primary { background: linear-gradient(140deg, var(--brand), var(--brand-2)); }
.endcard__ad { margin: 0 auto 18px; max-width: 340px; }
.endcard__ad .ad-slot { margin: 0; background: rgba(255, 255, 255, .07); }
.endcard__ad .ad-slot__label { color: rgba(255, 255, 255, .45); }
.endcard__label {
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255, 255, 255, .55); margin: 0 0 10px;
}
.endcard__tiles {
  display: grid; gap: 10px;
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 520px) { .endcard__tiles { grid-template-columns: repeat(3, 1fr); } }
.endcard__tile { display: block; }
.endcard__tile img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px;
  transition: transform .16s cubic-bezier(.2,.9,.3,1.5);
}
.endcard__tile:hover img { transform: translateY(-4px) scale(1.04); }
.endcard__tile span {
  display: block; margin-top: 5px; font-size: 11.5px; font-weight: 700; color: rgba(255,255,255,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.gamehead {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; margin-top: 14px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.gamehead__art { width: 62px; height: 62px; border-radius: 16px; object-fit: cover; flex: 0 0 62px; }
.gamehead__meta { min-width: 0; flex: 1 1 220px; }
.gamehead__meta h1 { font-size: clamp(19px, 2.4vw, 25px); margin: 0 0 3px; }
.gamehead__sub { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; font-weight: 700; color: var(--text-mute); }
.gamehead__sub span { display: inline-flex; align-items: center; gap: 5px; }
.gamehead__sub svg { width: 14px; height: 14px; }
.gamehead__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.gamehead__actions .iconbtn.is-active { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

/* Panels */
.panel { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel__head {
  display: flex; align-items: center; gap: 9px; padding: 13px 16px;
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.panel__head svg { width: 17px; height: 17px; color: var(--brand); }
.panel__head .num { margin-left: auto; font-family: var(--font-body); font-size: 12px; font-weight: 800; color: var(--text-mute); }
.panel__body { padding: 16px; }
.panel__foot { padding: 12px 16px; border-top: 1px solid var(--line); }

.prose { font-size: 15px; line-height: 1.75; color: var(--text-dim); }
.prose h2 { font-size: 19px; margin: 1.4em 0 .5em; color: var(--text); }
.prose h3 { font-size: 16.5px; margin: 1.3em 0 .4em; color: var(--text); }
.prose strong { color: var(--text); }
.prose a { color: var(--brand); font-weight: 700; }
.prose li { margin-bottom: .3em; }
.prose blockquote {
  margin: 1.2em 0; padding: 12px 16px; border-left: 4px solid var(--brand);
  background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0;
}
.prose code { background: var(--surface-2); padding: .15em .4em; border-radius: 6px; font-size: .9em; }

.spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.spec div { background: var(--surface-2); border-radius: var(--r); padding: 10px 13px; }
.spec dt { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); }
.spec dd { margin: 3px 0 0; font-weight: 700; font-size: 14px; }

.sidecol { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--top-h) + 14px); }
@media (max-width: 1180px) { .sidecol { position: static; } }

/* Compact list row */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; gap: 11px; align-items: center; padding: 7px;
  border-radius: var(--r); transition: background .14s, transform .14s;
}
.row:hover { background: var(--surface-2); transform: translateX(3px); }
.row__num { font-family: var(--font-display); font-size: 16px; width: 22px; text-align: center; color: var(--text-mute); }
.row img { width: 52px; height: 52px; border-radius: 13px; object-fit: cover; flex: 0 0 52px; }
.row__body { min-width: 0; flex: 1 1 auto; }
.row__title { font-weight: 800; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__meta { font-size: 11.5px; font-weight: 700; color: var(--text-mute); }

/* Stars */
.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 16px; height: 16px; }
.stars--input svg { width: 30px; height: 30px; cursor: pointer; transition: transform .12s; }
.stars--input svg:hover { transform: scale(1.2) rotate(-6deg); }
.star-on { fill: #ffc619; }
.star-off { fill: none; stroke: var(--text-mute); stroke-width: 1.6; }

/* Leaderboard */
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th {
  text-align: left; padding: 9px 14px; font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute);
  border-bottom: 1px solid var(--line);
}
.board td { padding: 9px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.board tr:last-child td { border-bottom: 0; }
.board tr:hover td { background: var(--surface-2); }
.board__rank {
  width: 44px; font-family: var(--font-display); font-size: 15px;
}
.board tbody tr:nth-child(1) .board__rank { color: #ffb020; }
.board tbody tr:nth-child(2) .board__rank { color: #9aa0b4; }
.board tbody tr:nth-child(3) .board__rank { color: #cd7f32; }
.board__score { text-align: right; font-variant-numeric: tabular-nums; }

/* Comments */
.comment { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 14px;
  display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); font-size: 16px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
}
.comment__head { display: flex; gap: 9px; align-items: baseline; }
.comment__name { font-weight: 800; font-size: 14px; }
.comment__time { font-size: 12px; color: var(--text-mute); font-weight: 700; }
.comment p { margin: 3px 0 0; font-size: 14.5px; color: var(--text-dim); }

/* Forms */
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; font-weight: 800; font-size: 13px; }
.input, .textarea, .select {
  width: 100%; padding: 11px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 14.5px; transition: .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: 0; background: var(--surface); border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--text-mute); margin-top: 5px; }
.error-text { color: var(--red); font-size: 12.5px; font-weight: 800; margin-top: 5px; }

.alert {
  display: flex; gap: 10px; padding: 12px 16px; margin-bottom: 14px;
  border-radius: var(--r); font-weight: 700; font-size: 14px;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.alert--success { background: rgba(34,197,94,.13); color: #12a150; }
.alert--error { background: rgba(244,63,94,.13); color: var(--red); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 18px;
  border-radius: var(--r-pill); font-weight: 800; font-size: 13.5px;
  box-shadow: var(--shadow-lg); max-width: 320px;
  animation: pop .24s cubic-bezier(.2,.9,.3,1.5);
}
@keyframes pop { from { transform: translateY(14px) scale(.9); opacity: 0; } }

/* Pagination */
.pager { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.pager a, .pager span {
  min-width: 42px; height: 42px; display: grid; place-items: center; padding: 0 14px;
  border-radius: var(--r-pill); background: var(--surface);
  font-weight: 800; font-size: 14px; box-shadow: var(--shadow-sm);
  transition: .14s;
}
.pager a:hover { background: var(--surface-2); transform: translateY(-2px); }
.pager .is-current { background: var(--brand); color: var(--brand-ink); }
.pager .is-gap { background: none; box-shadow: none; }

/* Filter bar */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filters__spacer { flex: 1 1 auto; }
.filters__count { font-size: 13px; font-weight: 800; color: var(--text-mute); }

/* Ads */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px; margin: 16px 0; min-height: 60px;
  background: var(--surface-2); border-radius: var(--r-lg);
  overflow: hidden;
}
.ad-slot__label {
  font-size: 9.5px; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: var(--text-mute);
}
.ad-slot__body { width: 100%; display: flex; justify-content: center; }
.ad-tile { grid-column: span 2; margin: 0; aspect-ratio: 2 / 1; justify-content: center; }
.ad-anchor {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; margin: 0;
  border-radius: 0; background: var(--surface); box-shadow: 0 -6px 20px rgba(0,0,0,.14);
}
.ad-anchor__close {
  position: absolute; right: 8px; top: -14px; width: 28px; height: 28px;
  display: grid; place-items: center; cursor: pointer; border: 0;
  background: var(--text); color: var(--bg); border-radius: 50%; font-size: 15px;
}
.ad-sticky { position: sticky; top: calc(var(--top-h) + 14px); }

.interstitial {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center;
  background: rgba(10,10,16,.8); backdrop-filter: blur(6px); padding: 20px;
}
.interstitial__panel {
  background: var(--surface); border-radius: var(--r-xl); padding: 22px;
  max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
}
.interstitial__count { font-size: 12.5px; font-weight: 800; color: var(--text-mute); }

/* Consent */
.consent {
  position: fixed; left: 16px; bottom: 16px; z-index: 120; max-width: 380px;
  background: var(--surface); border-radius: var(--r-xl); padding: 18px;
  box-shadow: var(--shadow-lg);
}
.consent p { font-size: 13.5px; margin: 0 0 14px; color: var(--text-dim); }
.consent__actions { display: flex; gap: 8px; }

/* Empty state */
.empty {
  text-align: center; padding: 60px 20px; color: var(--text-mute);
  background: var(--surface); border-radius: var(--r-xl);
}
.empty svg { width: 54px; height: 54px; margin: 0 auto 12px; opacity: .4; }
.empty h3 { font-size: 20px; color: var(--text); }

/* Footer */
.footer {
  margin-top: 10px; padding: 26px var(--pad) 34px;
  border-top: 1px solid var(--line);
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  font-size: 13px; color: var(--text-mute); font-weight: 600;
}
.footer a:hover { color: var(--brand); }
.footer__links { display: flex; gap: 14px; flex-wrap: wrap; }
.footer .spacer { flex: 1 1 auto; }
.footer__credit {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand); font-weight: 800;
}
.footer__credit a { color: inherit; }
.footer__credit:hover { filter: brightness(1.05); }

/* Mobile drawer */
.drawer__scrim {
  position: fixed; inset: 0; z-index: 45; background: rgba(10,10,16,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drawer__scrim.is-open { opacity: 1; pointer-events: auto; }

/* ==========================================================================
   Phone layout
   Below 900px the site stops being a narrow desktop and becomes its own
   thing: a thumb-reachable tab bar instead of the rail, a full-screen search
   sheet instead of an inline field, and an edge-to-edge player.
   ========================================================================== */

.tabbar { display: none; }
.searchsheet { display: none; }
.rotate-hint { display: none; }

@media (max-width: 900px) {
  :root { --tabbar-h: 60px; }

  body {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }

  /* ------------------------------------------------------------ Tab bar */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    display: flex; align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar__item {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; cursor: pointer;
    font-family: inherit; font-size: 10.5px; font-weight: 800;
    color: var(--text-mute); text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar__item span:last-child {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .tabbar__icon {
    position: relative; display: grid; place-items: center;
    width: 34px; height: 26px; border-radius: 999px;
    transition: background .16s, color .16s;
  }
  .tabbar__icon svg { width: 21px; height: 21px; }
  .tabbar__item:active .tabbar__icon { transform: scale(.92); }
  .tabbar__item[aria-current="page"] { color: var(--brand); }
  .tabbar__item[aria-current="page"] .tabbar__icon { background: var(--brand-soft); }
  .tabbar__dot {
    position: absolute; top: 1px; right: 4px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--pink); border: 2px solid var(--surface);
  }
  .tabbar__search .tabbar__icon { background: var(--brand); color: #fff; width: 40px; }
  .tabbar__search .tabbar__icon svg { width: 20px; height: 20px; }

  /* -------------------------------------------------- Full-screen search */
  .searchsheet {
    position: fixed; inset: 0; z-index: 120;
    display: flex; flex-direction: column;
    background: var(--bg);
    padding-top: env(safe-area-inset-top, 0px);
    animation: sheetIn .18s ease-out;
  }
  .searchsheet[hidden] { display: none; }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(10px); } }
  .searchsheet__bar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .searchsheet__bar input {
    flex: 1 1 auto; min-width: 0; height: 44px; padding: 0 16px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid transparent; border-radius: var(--r-pill);
    font-size: 16px; /* 16px stops iOS zooming the page on focus */
    font-weight: 600;
  }
  .searchsheet__bar input:focus { outline: 0; border-color: var(--brand); background: var(--surface); }
  .searchsheet__body { flex: 1 1 auto; overflow-y: auto; padding: 10px 12px 30px; }
  .searchsheet__hint { color: var(--text-mute); font-size: 13.5px; text-align: center; padding: 30px 10px; }
  .searchsheet__row {
    display: flex; gap: 12px; align-items: center; padding: 9px;
    border-radius: var(--r); color: inherit;
  }
  .searchsheet__row:active { background: var(--surface-2); }
  .searchsheet__row img { width: 54px; height: 54px; border-radius: 14px; object-fit: cover; flex: 0 0 54px; }
  .searchsheet__row b { font-size: 14.5px; font-weight: 800; display: block; }
  .searchsheet__row span { font-size: 12px; color: var(--text-mute); font-weight: 700; }

  /* ------------------------------------------------------- Chrome tweaks */
  .topbar .searchbox { display: none; }
  .topbar { gap: 8px; }
  .topbar__brand { display: flex; flex: 1 1 auto; min-width: 0; }
  .topbar .btn--soft { display: none; }

  /* The anchor ad has to clear the tab bar, or it covers it. */
  .ad-anchor { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .consent { left: 10px; right: 10px; max-width: none; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); left: 16px; }
  .toast { max-width: none; text-align: center; }

  /* ------------------------------------------------------- Player screen */
  /* Edge to edge: on a phone the frame should own the width. */
  .play > div:first-child > .stage {
    margin-left: calc(var(--pad) * -1);
    margin-right: calc(var(--pad) * -1);
    border-radius: 0;
  }
  .stage__frame { aspect-ratio: var(--ratio, 16/10); max-height: 62vh; }
  .stage__cover-art { width: 92px; height: 92px; border-radius: 20px; }
  .gamehead { flex-wrap: wrap; }
  .gamehead__actions {
    width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .gamehead__actions::-webkit-scrollbar { display: none; }
  .gamehead__actions > * { flex: 0 0 auto; }

  /* Landscape games in a portrait hand */
  .rotate-hint {
    display: none; position: absolute; inset: 0; z-index: 9;
    place-items: center; text-align: center; padding: 24px;
    background: rgba(10, 10, 16, .92); color: #fff;
  }
  .rotate-hint.is-on { display: grid; }
  .rotate-hint svg { width: 48px; height: 48px; margin: 0 auto 14px; animation: tilt 1.8s ease-in-out infinite; }
  @keyframes tilt { 40% { transform: rotate(-90deg); } 60% { transform: rotate(-90deg); } }
  .rotate-hint p { font-size: 14px; color: rgba(255,255,255,.75); margin: 0 0 16px; }
  .rotate-hint .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }

  .endcard__tiles { grid-template-columns: repeat(4, 1fr); }
  .footer { padding-bottom: 24px; }
}

@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles--sm { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles--lg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { margin-bottom: 24px; }
  .section__head h2 { font-size: 18px; }
  .shelf__track { grid-auto-columns: minmax(116px, 1fr); }
  .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .endcard__tiles { grid-template-columns: repeat(3, 1fr); }
  .panel__body { padding: 14px; }
  /* Comfortable thumb targets on the smallest screens */
  .btn { padding: 12px 20px; }
  .chip { padding: 9px 15px; }
}

/* --------------------------------------------------------- Responsive */
@media (max-width: 1200px) {
  :root { --rail-w: var(--rail-mini); }
  .rail__name, .rail__label, .railitem span, .railitem__count, .rail__foot .rail__links { display: none; }
  .rail__brand { justify-content: center; padding: 14px 8px; }
  .railitem { justify-content: center; padding: 11px; }
  .rail__social { justify-content: center; flex-wrap: wrap; }
  .rail__foot { padding: 12px 8px; text-align: center; }
}
@media (max-width: 900px) {
  .rail {
    position: fixed; left: 0; top: 0; z-index: 50; width: 264px; flex-basis: 264px;
    transform: translateX(-102%); transition: transform .24s cubic-bezier(.3,.8,.3,1);
    box-shadow: var(--shadow-lg);
  }
  .rail.is-open { transform: none; }
  .rail .rail__name, .rail .rail__label, .rail .railitem span,
  .rail .railitem__count, .rail .rail__foot .rail__links { display: block; }
  .rail .rail__brand { justify-content: flex-start; padding: 14px 16px; }
  .rail .railitem { justify-content: flex-start; padding: 9px 12px; }
  .rail .rail__social { justify-content: flex-start; }
  .rail .rail__foot { padding: 14px 16px 18px; text-align: left; }
  .iconbtn--menu { display: grid; }
  .topbar__brand { display: flex; }
}
@media (max-width: 640px) {
  :root { --gap: 10px; --top-h: 58px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .tile { border-radius: var(--r); }
  .tile__name { font-size: 12px; padding: 8px 9px 9px; }
  .tile--big .tile__name { font-size: 16px; }
  .searchbox { flex-basis: auto; }
  .topbar__brand .rail__name { font-size: 18px; }
  .topbar__label { display: none; }
  .gamehead__actions { margin-left: 0; width: 100%; }
  .section__head h2 .ico { width: 28px; height: 28px; border-radius: 9px; }
  .cats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 420px) {
  .searchbox input { padding-left: 38px; font-size: 13.5px; }
  .topbar__brand .rail__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
