:root {
  --bg: #01031f;
  --panel: #0a1142;
  --panel-2: #111b5c;
  --text: #eef3ff;
  --muted: #8796cc;
  --accent: #1f6bff;
  --accent-2: #5aa8ff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 520px at 50% -8%, #00105e 0%, transparent 65%),
    radial-gradient(800px 400px at 100% 40%, #061a6b55 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h2 { font-family: "Russo One", sans-serif; font-weight: 400; font-size: 1.3rem; margin: 32px 0 14px; letter-spacing: .5px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(1, 3, 31, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #ffffff12;
}
.logo { display: block; flex-shrink: 0; }
.logo img { display: block; height: 30px; width: auto; filter: drop-shadow(0 0 12px #1f6bff66); }
#search {
  flex: 1; max-width: 460px; margin-left: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid #ffffff1a; border-radius: 999px;
  padding: 10px 18px; font: inherit; outline: none;
}
#search:focus { border-color: var(--accent); }

.btn {
  border: 0; cursor: pointer; font: 600 .9rem Inter, sans-serif;
  padding: 10px 18px; border-radius: 999px; white-space: nowrap;
  background: var(--accent); color: #fff;
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 22px #1f6bff66; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid #ffffff2a; }
.btn.ghost:hover { box-shadow: none; border-color: var(--accent); }

main { padding: 0 clamp(16px, 4vw, 40px) 40px; max-width: 1400px; margin: 0 auto; }

/* Hero */
.hero {
  margin-top: 24px; border-radius: 22px; overflow: hidden; position: relative;
  padding: clamp(22px, 4vw, 44px) clamp(16px, 4vw, 44px);
  background:
    radial-gradient(ellipse 70% 80% at 50% 40%, #00105c88 0%, #01031fcc 75%),
    url("images/hero-bg.jpg") center / cover;
  border: 1px solid #1f6bff33;
  box-shadow: inset 0 0 80px #1f6bff22, 0 20px 60px #0007;
  text-align: center;
}
.hero .brand {
  display: block; width: min(820px, 100%); height: auto; margin: 0 auto;
  filter: drop-shadow(0 0 28px #1f6bffaa); margin-bottom: 26px !important;
}
.hero .tagline { color: #b9c6f2; margin: 4px 0 22px; font-size: 1.05rem; }
.featured {
  display: inline-flex; align-items: center; gap: 14px; text-align: left;
  background: #0a1142cc; border: 1px solid #1f6bff44; border-radius: 999px;
  padding: 8px 8px 8px 8px;
}
.featured .thumb { width: 46px; height: 46px; border-radius: 50%; background-size: cover; background-position: center; display: grid; place-items: center; font-family: "Russo One", sans-serif; font-size: .9rem; }
.featured .tag { color: var(--accent-2); font-weight: 800; letter-spacing: 2px; font-size: .65rem; }
.featured .t { font-weight: 800; }
.featured .btn { margin-left: 6px; }

/* Categories */
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.cats button {
  background: var(--panel); color: var(--muted); border: 1px solid #ffffff12;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font: 600 .85rem Inter, sans-serif;
}
.cats button.on, .cats button:hover { color: #fff; background: var(--accent); border-color: var(--accent); }

/* Game grid */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card {
  background: var(--panel); border-radius: var(--radius); overflow: hidden;
  border: 1px solid #ffffff10; transition: transform .18s, box-shadow .18s, border-color .18s;
  display: block;
}
.card:hover { transform: translateY(-4px) scale(1.02); border-color: var(--accent); box-shadow: 0 10px 30px #1f6bff40; }
.cover {
  aspect-ratio: 1 / 1; background-size: cover; background-position: center;
  display: grid; place-items: center; position: relative;
}
.cover .initials { font-family: "Russo One", sans-serif; font-size: 2.2rem; color: #ffffffdd; text-shadow: 0 2px 12px #0006; }
.cover .soon {
  position: absolute; top: 8px; right: 8px; font-size: .65rem; font-weight: 800;
  background: #000a; padding: 3px 8px; border-radius: 999px; color: var(--muted);
}
.card .meta { padding: 10px 12px 12px; }
.card .name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cat { color: var(--muted); font-size: .75rem; margin-top: 2px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 30px 0 40px; }

/* Play page */
.game-title { font-family: "Russo One", sans-serif; font-weight: 400; font-size: 1.15rem; margin: 0 auto; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }
.stage-wrap { padding-top: 20px; }
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 78vh;
  background: #000; border-radius: 18px; overflow: hidden;
  border: 1px solid #ffffff1a; box-shadow: 0 20px 60px #0008;
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.loader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: var(--muted); z-index: 2; background: #000; transition: opacity .3s; }
.loader.done { opacity: 0; pointer-events: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #ffffff22; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { color: var(--muted); font-size: .8rem; margin: 10px 4px 0; }
.hint a { color: var(--accent-2); text-decoration: underline; }
body.window-full .hint { display: none; }


/* Browser-window fullscreen: game fills the tab, page chrome hides */
body.window-full { overflow: hidden; }
body.window-full .topbar, body.window-full .stage-wrap > h2, body.window-full #more { display: none; }
body.window-full .stage {
  position: fixed; inset: 0; z-index: 50; width: 100vw; height: 100vh; height: 100dvh;
  max-height: none; aspect-ratio: auto; border-radius: 0; border: 0;
}
.exit-full {
  display: none; position: absolute; top: 10px; right: 10px; z-index: 3;
  background: #000a; color: #fff; border: 1px solid #ffffff33; border-radius: 999px;
  padding: 6px 12px; font: 600 .8rem Inter, sans-serif; cursor: pointer; opacity: .35; transition: opacity .2s;
}
.exit-full:hover, .exit-full:focus { opacity: 1; }
body.window-full .exit-full { display: block; }

/* Version picker (e.g. Normal / Hacked) */
.versions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.versions .vlabel { font-weight: 600; font-size: .85rem; color: var(--muted); }
.versions .vnote { color: var(--muted); font-size: .8rem; }
body.window-full .versions { display: none; }

/* Favorites */
.fav {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center; padding: 0;
  background: #000a; color: #fff; font-size: 1.05rem; line-height: 1;
  opacity: .0; transition: opacity .15s, transform .15s, background .15s;
}
.card:hover .fav, .fav:focus-visible, .fav.on { opacity: 1; }
@media (hover: none) { .fav { opacity: .85; } }
.fav:hover { transform: scale(1.12); }
.fav.on { background: #ff3d6e; color: #fff; box-shadow: 0 0 14px #ff3d6e88; }
.fav-btn { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; width: auto; height: auto; position: static; border-radius: 999px; opacity: 1; padding: 10px 16px; font-size: .9rem; }
.fav-btn.on { background: #ff3d6e; border-color: #ff3d6e; box-shadow: none; }
.fav.pop { animation: favpop .3s ease; }
@keyframes favpop { 50% { transform: scale(1.3); } }
.fav-heart { color: #ff3d6e; }

/* Settings */
.icon-btn { padding: 8px 12px; font-size: 1.05rem; line-height: 1; }
.settings-backdrop { position: fixed; inset: 0; z-index: 100; background: #000a; backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.settings-backdrop[hidden] { display: none; }
.settings {
  width: min(440px, 100%); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid #1f6bff55; border-radius: 18px;
  box-shadow: 0 20px 60px #000a, inset 0 0 40px #1f6bff14; padding: 18px 20px 14px;
}
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings h3 { font-family: "Russo One", sans-serif; font-weight: 400; margin: 0; font-size: 1.25rem; }
.settings .x { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px; }
.settings .x:hover { color: #fff; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid #ffffff10; font-size: .92rem; flex-wrap: wrap; }
.settings .row b { color: var(--accent-2); font-weight: 600; margin-left: 6px; }
.settings input[type=range] { flex: 1 1 180px; accent-color: var(--accent); }
.settings input[type=checkbox] { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: #ffffff22; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.settings input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.settings input[type=checkbox]:checked { background: var(--accent); }
.settings input[type=checkbox]:checked::after { transform: translateX(18px); }
.settings .toggle { cursor: pointer; }
.seg { display: inline-flex; background: #ffffff10; border-radius: 999px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font: 600 .8rem Inter, sans-serif; padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.btn.small { padding: 6px 14px; font-size: .8rem; }
.settings small { color: var(--muted); font-size: .75rem; }
.settings .note { color: var(--muted); font-size: .75rem; margin: 6px 0 0; line-height: 1.4; }

/* Reduce animations */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition: none !important; animation-duration: .01ms !important; }
.reduce-motion .card:hover { transform: none; }

@media (max-width: 640px) {
  .logo img { height: 24px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  #search { order: 3; max-width: none; flex-basis: 100%; margin-left: 0; }
  #requestLink { margin-left: auto; padding: 8px 14px; }
  .featured { border-radius: 18px; flex-wrap: wrap; justify-content: center; text-align: center; }
  .actions .btn { padding: 8px 12px; }
  .fav-btn .lbl { display: none; }
  .game-title { display: none; }
  .play-page .actions { margin-left: auto; }
  .stage { aspect-ratio: 3 / 4; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* Play page on touch screens: no gray tap flash, no text selection / long-press menu, no double-tap zoom over the game */
body.play-page { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.play-page .stage, .play-page .stage * {
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
