:root {
  --bg: #0e1016;
  --bg-2: #151821;
  --card: #1a1e29;
  --card-hover: #212636;
  --line: #2a2f3d;
  --fg: #e9ebf2;
  --muted: #8e94a6;
  --accent: #ffb547;
  --accent-2: #8b6cff;
  --ok: #4fd18b;
  --danger: #ff6b6b;
  --star: #ffc94d;
  --star-off: #3a4052;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding: 24px 0 48px; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 16, 22, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; white-space: nowrap; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #111; font-size: 18px;
}
.logo b { color: var(--accent); font-weight: 800; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav a:hover, .nav a.on { color: var(--fg); background: var(--card); }
.search { margin-left: auto; position: relative; flex: 0 1 320px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-2); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; color: var(--muted); }

/* ---------- catalog */
.hero { margin-bottom: 20px; }
.hero h1 { margin: 0 0 4px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 18px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--fg); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #17130a; }
.chip small { opacity: .7; margin-left: 4px; font-weight: 500; }
.sort select {
  height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 10px;
}
.count { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); background: var(--card-hover); border-color: #3a4152; }
.thumb { aspect-ratio: 4 / 3; background: var(--bg-2); position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 38px; font-weight: 800;
  color: rgba(255, 255, 255, .9); text-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.card .play-ico {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s;
  background: rgba(0, 0, 0, .35);
}
.card:hover .play-ico { opacity: 1; }
.play-ico span {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #111;
}
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; gap: 8px; }
.mini-stars { color: var(--star); white-space: nowrap; }
.mini-stars em { font-style: normal; color: var(--muted); }

.more { display: flex; justify-content: center; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--card-hover); }
.btn.primary { background: var(--accent); color: #17130a; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

.empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.empty .big { font-size: 48px; }
.empty h2 { color: var(--fg); margin: 8px 0; }

/* skeleton */
.sk { background: linear-gradient(90deg, var(--card) 0%, var(--card-hover) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- game page */
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.crumbs a:hover { color: var(--fg); }
.game-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.game-head h1 { margin: 0; font-size: clamp(22px, 3.5vw, 32px); letter-spacing: -.02em; }
.game-head .sub { color: var(--muted); }
.game-head .sub a { color: var(--accent); }
.stage-box { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.stage { position: relative; width: 100%; margin: 0 auto; background: #000; }
.stage ruffle-player, .stage ruffle-embed { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.start {
  position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer; border: 0; padding: 0;
  background: #000 center / cover no-repeat;
}
.start::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(0,0,0,.25), rgba(0,0,0,.75)); backdrop-filter: blur(3px); }
.start .go {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; color: #fff; font-weight: 800; font-size: 18px;
}
.start .go span {
  width: 84px; height: 84px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #111;
  box-shadow: 0 0 0 10px rgba(255, 181, 71, .2); transition: transform .15s;
}
.start:hover .go span { transform: scale(1.06); }
.stage-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-2); border-top: 1px solid var(--line); flex-wrap: wrap; }
.stage-bar .spacer { flex: 1; }
.stage-bar .btn { height: 36px; padding: 0 14px; font-size: 14px; }
.plays { color: var(--muted); font-size: 14px; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; margin-top: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel h2 { margin: 0 0 10px; font-size: 17px; }
.panel p { margin: 0 0 10px; white-space: pre-line; }
.panel .muted { color: var(--muted); }

.rate { display: flex; flex-direction: column; gap: 8px; }
.rate-score { display: flex; align-items: baseline; gap: 8px; }
.rate-score b { font-size: 34px; line-height: 1; }
.rate-score span { color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.stars button {
  background: none; border: 0; padding: 2px; cursor: pointer; color: var(--star-off); line-height: 0;
  transition: transform .1s, color .1s;
}
.stars button svg { width: 32px; height: 32px; }
.stars button.on { color: var(--star); }
.stars button:hover { transform: scale(1.12); }
.rate-note { font-size: 13px; color: var(--muted); min-height: 20px; }
.rate-note.ok { color: var(--ok); }
.rate-note.err { color: var(--danger); }

.side-list { display: flex; flex-direction: column; gap: 10px; }
.side-item { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 10px; }
.side-item:hover { background: var(--card-hover); }
.side-item .thumb { width: 88px; flex: none; border-radius: 8px; }
.side-item .t { font-weight: 700; font-size: 14px; line-height: 1.3; }
.side-item .meta { justify-content: flex-start; }

/* ---------- footer */
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ---------- responsive */
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .top .wrap { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .search { flex: 1 1 100%; order: 2; margin-left: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 8px 10px 10px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .sort select { width: 100%; }
}
