/* Zibbo · dark portal theme */
:root {
  --bg: #0F1020;
  --surface: #181A30;
  --surface-2: #22253F;
  --line: #2C2F4D;
  --text: #F2F3FA;
  --muted: #A3A6C2;
  --accent: #FF5A3C;
  --accent-2: #FFD23F;
  --focus: #7AD3FF;
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 64px;
  --sidebar-w: 216px;
  --rail-w: 64px;
  --gap: 14px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; padding: 10px 16px; background: var(--accent); color: #fff; border-radius: 8px; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(15, 16, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; flex: none; }
.wordmark { font-weight: 900; font-size: 24px; letter-spacing: -0.6px; line-height: 1; color: var(--text); }
.logo:hover .wordmark { color: var(--accent-2); }
.menu-btn { display: none; background: none; border: 0; padding: 8px; border-radius: 10px; }
.menu-btn:hover { background: var(--surface-2); }
.search {
  flex: 1 1 auto; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--focus); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font: 600 15px var(--font); color: var(--text);
}
.search input::placeholder { color: var(--muted); }
.header-links { display: flex; gap: 6px; flex: none; }
.icon-link { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--muted); }
.icon-link:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Layout ---------- */
.layout { display: flex; flex: 1; align-items: flex-start; }
/* Sidebar: a compact icon rail that widens over the page on hover or keyboard focus. */
.sidebar {
  position: sticky; top: var(--header-h); z-index: 15;
  flex: 0 0 var(--rail-w);
  /* Fixed width (and min-width: 0, so the flexbox can't grow it to fit the
     open rail): the rail opens over the page instead of pushing it. */
  width: var(--rail-w); min-width: 0;
  height: calc(100vh - var(--header-h));
}
.rail {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  overflow-x: hidden; overflow-y: auto;
  padding: 12px 10px 24px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  scrollbar-width: none;
  transition: width .18s ease, box-shadow .18s ease;
}
.rail::-webkit-scrollbar { display: none; }
.sidebar:hover .rail, .sidebar:focus-within .rail {
  width: var(--sidebar-w);
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.45);
  transition-delay: .12s;
}
.nav-item {
  display: flex; align-items: center; gap: 14px;
  height: 44px; padding: 0 11px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 700; white-space: nowrap;
}
.nav-item > svg, .cat-icon { flex: none; width: 22px; height: 22px; }
.cat-icon { display: grid; place-items: center; color: var(--c); }
.nav-label { opacity: 0; transition: opacity .12s ease; }
.sidebar:hover .nav-label, .sidebar:focus-within .nav-label { opacity: 1; transition-delay: .12s; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; flex: none; }
.dot { width: 22px; height: 22px; border-radius: 7px; flex: none; display: inline-block; }
.cat-icon .dot { width: 14px; height: 14px; border-radius: 5px; background: var(--c); }
/* Big touch screens (like a tablet held sideways) can't hover, so show the full menu there. */
@media (hover: none) and (min-width: 901px) {
  .sidebar { flex-basis: var(--sidebar-w); width: var(--sidebar-w); }
  .rail { width: var(--sidebar-w); }
  .nav-label { opacity: 1; }
  body .site-footer { padding-left: calc(var(--sidebar-w) + 24px); }
}
.main { flex: 1; min-width: 0; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 32px; }

/* ---------- Headings ---------- */
.page-title { font-size: 26px; font-weight: 800; }
.page-head { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.page-head p { color: var(--muted); }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 20px; font-weight: 800; }
.section-head h2 a:hover { color: var(--accent-2); }
.see-all { color: var(--muted); font-weight: 700; font-size: 14px; }
.see-all:hover { color: var(--text); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.crumbs li + li::before { content: '›'; margin-right: 6px; }
.crumbs a:hover { color: var(--text); }
.crumbs + * { margin-top: -18px; }

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gap);
}
.grid.dense { grid-auto-flow: dense; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid.small { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  position: relative; display: block;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c, var(--surface-2));
  transition: transform .15s ease, box-shadow .15s ease;
  isolation: isolate;
}
.tile.big { grid-column: span 2; grid-row: span 2; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-title {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 26px 10px 9px;
  background: linear-gradient(transparent, rgba(8, 8, 20, 0.88));
  font-weight: 800; font-size: 14px; line-height: 1.25;
  opacity: 0; transform: translateY(6px);
  transition: opacity .15s ease, transform .15s ease;
}
.tile.big .tile-title { font-size: 18px; padding: 40px 14px 12px; }
.tile:hover, .tile:focus-visible { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(255, 255, 255, 0.85); z-index: 2; }
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; transform: none; }
/* Touch screens have no hover, so always show titles there. */
@media (hover: none) {
  .tile-title { opacity: 1; transform: none; }
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-size: 14px;
}
.chip .dot { width: 18px; height: 18px; border-radius: 6px; }
a.chip:hover { background: var(--surface-2); }
.chip.muted { color: var(--muted); padding-left: 14px; }

.empty { padding: 36px 24px; border-radius: var(--radius); background: var(--surface); text-align: center; color: var(--muted); font-weight: 600; }
.empty h1 { color: var(--text); font-size: 34px; margin-bottom: 8px; }
.empty a { color: var(--accent-2); }
.seo-text { max-width: 820px; color: var(--muted); }
.seo-text h2 { color: var(--text); font-size: 18px; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.game-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.player { border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - var(--header-h) - 120px);
  width: 100%;
  background: #000;
}
.stage:fullscreen { max-height: none; aspect-ratio: auto; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; overflow: hidden; background: var(--c); }
.cover-bg { position: absolute; inset: -10%; width: 120%; height: 120%; object-fit: cover; filter: blur(28px) brightness(0.55); }
.cover-art { position: relative; width: clamp(96px, 22%, 180px); height: auto; aspect-ratio: 1; border-radius: 22px; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5); }
.cover-title { position: relative; font-size: clamp(20px, 3vw, 30px); font-weight: 800; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.play-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 20px rgba(255, 90, 60, 0.45);
  transition: transform .15s ease;
}
.cover:hover .play-btn, .cover:focus-visible .play-btn { transform: scale(1.06); }
.player.playing .cover { display: none; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.player-bar > img { width: 40px; height: 40px; border-radius: 10px; background: var(--c); flex: none; }
.player-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.player-name strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-name a { color: var(--muted); font-size: 13px; font-weight: 600; }
.player-name a:hover { color: var(--text); }
.player-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text); }
.icon-btn:hover { background: #2E3254; }
.icon-btn.on { background: var(--accent); }
.icon-btn.on svg path { fill: currentColor; }
.game-info { display: flex; flex-direction: column; gap: 12px; padding: 22px 24px; border-radius: var(--radius); background: var(--surface); max-width: 900px; }
.game-info h1 { font-size: 28px; font-weight: 800; }
.game-info h2 { font-size: 17px; font-weight: 800; margin-top: 6px; }
.game-info p { color: #CDD0E4; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 20px;
  margin: 2px 0 4px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 700; }
.facts a { color: var(--accent-2); }
.game-info h3 { font-size: 15px; font-weight: 800; margin-top: 2px; }
.game-info ul { margin: 0; padding-left: 20px; color: #CDD0E4; display: flex; flex-direction: column; gap: 4px; }
.game-info .updated { color: var(--muted); font-size: 13px; }
.game-side { position: sticky; top: calc(var(--header-h) + 20px); }

/* ---------- Text pages ---------- */
.prose { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.prose h1 { font-size: 32px; font-weight: 800; }
.prose h2 { font-size: 20px; font-weight: 800; margin-top: 10px; }
.prose p { color: #CDD0E4; }
.prose a { color: var(--accent-2); text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer {
  display: flex; flex-direction: column; gap: 16px;
  padding: 28px 24px 32px calc(var(--rail-w) + 24px);
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.footer-top { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.footer-top p { max-width: 560px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; font-weight: 700; }
.site-footer nav a:hover { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-side { position: static; }
  .game-side .grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
@media (max-width: 900px) {
  :root { --header-h: 58px; }
  .menu-btn { display: grid; place-items: center; }
  .wordmark { font-size: 20px; }
  .site-header { padding: 0 12px; gap: 10px; }
  .sidebar {
    position: fixed; left: 0; top: var(--header-h); bottom: 0; z-index: 25;
    width: 260px; height: auto;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .rail, .sidebar:hover .rail, .sidebar:focus-within .rail { width: 260px; box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5); }
  .nav-label { opacity: 1; }
  .nav-open .sidebar { transform: none; }
  .nav-open::after { content: ''; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0, 0, 0, 0.5); z-index: 20; }
  .main { padding: 16px 14px 40px; gap: 26px; }
  .site-footer { padding: 24px 16px 28px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .grid.dense { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .stage { max-height: none; }
  .game-info { padding: 18px; }
  .game-info h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .wordmark { font-size: 18px; }
  .tile.big { grid-column: span 2; grid-row: span 2; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
