:root {
  --ink: #f4efff;
  --ink-dim: rgba(244, 239, 255, 0.62);
  --ink-faint: rgba(244, 239, 255, 0.34);
  --glass: rgba(40, 32, 88, 0.42);
  --glass-strong: rgba(30, 24, 70, 0.8);
  --line: rgba(244, 239, 255, 0.14);
  --peach: #ffc4a8;
  --mint: #a8f0d6;
  --lavender: #c9b8ff;
  --gold: #ffe3a3;
  --bg: #16123a;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink);
  font-family: 'Quicksand', 'Nunito', system-ui, -apple-system, sans-serif; font-weight: 400;
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(255, 180, 160, .16), transparent 60%),
    radial-gradient(ellipse 70% 60% at 90% 90%, rgba(150, 120, 255, .2), transparent 60%),
    radial-gradient(ellipse 60% 40% at 70% 30%, rgba(140, 230, 210, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
canvas#bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

main {
  position: relative; z-index: 1;
  width: 100%; max-width: 900px; margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 8px 4px 26px; }
h1 {
  margin: 0; font-weight: 300; font-size: clamp(34px, 7vw, 52px); letter-spacing: .02em; line-height: 1.05;
  background: linear-gradient(100deg, var(--peach), var(--gold) 40%, var(--mint) 70%, var(--lavender));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(255, 227, 163, .15);
}
.head p { margin: 10px 0 0; color: var(--ink-dim); font-size: 16px; }

.switches { display: flex; gap: 8px; flex: none; margin-top: 4px; }
.sw-btn {
  width: 44px; height: 44px; border-radius: 50%; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform .3s var(--ease-out), background .3s;
}
.sw-btn:active { transform: scale(.92); }
.sw-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sw-btn .off { display: none; }
.sw-btn[aria-pressed="false"] { background: rgba(20, 16, 50, .5); }
.sw-btn[aria-pressed="false"] svg { stroke: var(--ink-faint); }
.sw-btn[aria-pressed="false"] .on { display: none; }
.sw-btn[aria-pressed="false"] .off { display: inline; }

.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 420px)); justify-content: center; gap: 18px; }
.card {
  --accent: #c9b8ff;
  display: flex; flex-direction: column; gap: 14px; padding: 12px 12px 16px; border-radius: 28px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(8, 4, 26, .35);
  transition: transform .5s var(--ease-out), box-shadow .5s var(--ease-out);
  animation: rise .8s var(--ease-out) both;
}
.card:nth-child(2) { animation-delay: .08s; }
.card:nth-child(3) { animation-delay: .16s; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); box-shadow: 0 26px 70px rgba(8, 4, 26, .45), 0 0 50px color-mix(in srgb, var(--accent) 16%, transparent); }
}
.preview { display: block; position: relative; aspect-ratio: 16 / 10; border-radius: 20px; overflow: hidden; background: rgba(12, 9, 34, .6); cursor: pointer; }
.preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.info { display: flex; gap: 14px; align-items: center; padding: 0 6px; }
.icon { width: 56px; height: 56px; border-radius: 15px; flex: none; box-shadow: 0 6px 20px rgba(8, 4, 26, .4); }
.text h2 { margin: 0 0 4px; font-weight: 500; font-size: 20px; }
.desc { margin: 0; color: var(--ink-dim); font-size: 14px; line-height: 1.45; }

.progress { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.progress .bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(244, 239, 255, .1); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--gold)); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent); transition: width 1.2s var(--ease-out); }
.progress .label { font-size: 13px; color: var(--ink-dim); white-space: nowrap; font-weight: 500; }

.actions { display: flex; gap: 8px; padding: 0 6px; }
.btn {
  position: relative; height: 46px; padding: 0 20px; border-radius: 23px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  background: rgba(244, 239, 255, .1); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 16px;
  transition: transform .25s var(--ease-out), background .25s;
}
.btn:active { transform: scale(.96); }
.btn.play { flex: 1; color: #1b1640; border: 0; background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 85%, white), var(--gold)); box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: none; font-weight: 500; }
.install { font-size: 14px; }

.foot { margin: 34px 4px 8px; text-align: center; color: var(--ink-faint); font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.foot p { margin: 0; }
.foot .credits a { color: var(--ink-dim); }

.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: end center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(14, 10, 38, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: fade .35s var(--ease-out);
}
@media (min-width: 600px) { .overlay { place-items: center; } }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(100%, 420px); padding: 22px 20px 14px; border-radius: 28px;
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(8, 4, 26, .5);
  display: flex; flex-direction: column; gap: 14px; animation: rise .5s var(--ease-out);
}
.panel h3 { margin: 0; text-align: center; font-weight: 500; font-size: 21px; }
#sheet-body { color: var(--ink-dim); font-size: 15px; line-height: 1.55; }
#sheet-body ol { margin: 0; padding-left: 22px; }
#sheet-body li { margin: 6px 0; }
#sheet-body b { color: var(--ink); font-weight: 600; }
#sheet-body .btn { width: 100%; margin-top: 8px; }
.ios-share { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) { .card, .panel { animation: none; } }

/* ---------- Разделы коллекции (поле category в games.json) ---------- */
.cats { display: flex; flex-direction: column; gap: 34px; }
.cat-head { margin: 0 6px 16px; }
.cat-head h2 { margin: 0; font-weight: 400; font-size: 26px; letter-spacing: .03em; }
.cat-head p { margin: 6px 0 0; color: var(--ink-dim); font-size: 14px; }

/* «Тёмная сторона»: холоднее, темнее, с редким мерцанием. */
.cat-dark {
  position: relative; padding: 22px 12px 14px; margin: 0 -4px; border-radius: 32px;
  background: radial-gradient(120% 80% at 50% 0%, rgba(30, 44, 64, .55), rgba(4, 6, 10, .92) 70%);
  border: 1px solid rgba(127, 169, 214, .12);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .6), 0 24px 70px rgba(0, 0, 0, .45);
}
.cat-dark .cat-head h2 { color: #c4d6ea; text-shadow: 0 0 18px rgba(127, 169, 214, .35); animation: flicker 7s infinite steps(1); }
.cat-dark .cat-head p { color: rgba(196, 214, 234, .5); }
@keyframes flicker { 0%, 61%, 63.5%, 66%, 100% { opacity: 1; } 62% { opacity: .35; } 65% { opacity: .6; } 93% { opacity: .85; } }
.cat-dark .card { background: rgba(10, 14, 20, .78); border-color: rgba(127, 169, 214, .1); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.cat-dark .preview { background: #070a0e; }
.cat-dark .btn.play { color: #0b1118; background: linear-gradient(100deg, #9cc3e8, #6f93bb); box-shadow: 0 8px 26px rgba(90, 140, 200, .25); }
.cat-dark .progress .bar i { background: linear-gradient(90deg, #6f93bb, #c4d6ea); }
.age {
  display: inline-block; vertical-align: 3px; margin-left: 4px; padding: 1px 7px; border-radius: 7px;
  border: 1px solid #d97a7a; color: #e59a9a; font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
@media (prefers-reduced-motion: reduce) { .cat-dark .cat-head h2 { animation: none; } }
