:root{
  color-scheme: dark;
  --ink:#f7f8ff;
  --muted:#b7bedd;
  --bg:#101024;
  --panel:#161830;
  --panel-2:#1d2140;
  --accent:#ffb347;
  --accent-2:#7c5cff;
  --good:#5be3a4;
  --warn:#ffd166;
  --line:rgba(255,255,255,.14);
  --radius:18px;
  --shadow:0 20px 60px rgba(0,0,0,.42);
  --font-display:"Rubik","Trebuchet MS",sans-serif;
  --font-body:"Inter","Segoe UI",Arial,sans-serif;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:var(--font-body);
  color:var(--ink);
  background:
    radial-gradient(circle at top left, rgba(124,92,255,.16), transparent 36%),
    radial-gradient(circle at top right, rgba(255,179,71,.12), transparent 30%),
    linear-gradient(180deg,#0d0e20 0%, #111328 58%, #141630 100%);
  min-height:100vh;
}
.container{width:min(1180px, calc(100% - 32px)); margin-inline:auto}
.site-header{
  position:sticky; top:0; z-index:50;
  backdrop-filter:blur(14px);
  background:rgba(14,15,34,.82);
  border-bottom:1px solid var(--line);
}
.nav{display:flex; align-items:center; justify-content:space-between; gap:16px; padding:18px 0}
.brand{display:flex; align-items:center; gap:10px; font-family:var(--font-display); font-weight:800; letter-spacing:.3px; font-size:1.25rem}
.brand-mark{width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,var(--accent),var(--accent-2));display:grid;place-items:center;color:#141527;font-weight:900}
.nav-links{display:flex; flex-wrap:wrap; gap:8px; color:var(--muted); font-size:.95rem}
.nav-links a{padding:8px 10px; color:inherit; text-decoration:none; border-radius:10px}
.nav-links a:hover{background:var(--panel-2); color:var(--ink)}
.btn{display:inline-flex; align-items:center; justify-content:center; border:0; cursor:pointer; border-radius:12px; padding:12px 16px; font-weight:700; text-decoration:none}
.btn-primary{background:linear-gradient(135deg,var(--accent),#ff8a3d); color:#1b130b; box-shadow:0 12px 30px rgba(255,179,71,.22)}
.btn-ghost{background:var(--panel-2); color:var(--ink); border:1px solid var(--line)}
.hero{padding:64px 0 32px}
.hero-copy{display:grid; grid-template-columns:1.2fr .8fr; gap:28px; align-items:center}
.kicker{color:var(--accent); font-weight:800; letter-spacing:.22em; text-transform:uppercase; font-size:.85rem; margin:0 0 14px}
h1,h2,h3{font-family:var(--font-display); line-height:1.06; margin:0}
h1{font-size:clamp(2.4rem, 5.2vw, 4.3rem)}
.lead{color:var(--muted); font-size:1.15rem; line-height:1.65; margin:18px 0 0; max-width:76ch}
.hero-card{background:var(--panel); border:1px solid var(--line); box-shadow:var(--shadow); border-radius:24px; padding:22px}
.hero-card h3{font-size:1.35rem}
.hero-card p{color:var(--muted); line-height:1.55; margin:10px 0 16px}
.stats{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:10px}
.stat{background:var(--panel-2); border:1px solid var(--line); border-radius:14px; padding:14px; text-align:center}
.stat strong{display:block; font-size:1.35rem; margin-bottom:6px}
.stat span{font-size:.86rem; color:var(--muted)}
section{padding:42px 0}
.section-title{display:flex; align-items:end; justify-content:space-between; gap:18px; margin-bottom:18px}
.section-title h2{font-size:clamp(1.7rem, 3.2vw, 2.6rem)}
.section-title p{margin:4px 0 0; color:var(--muted)}
.filters{display:flex; flex-wrap:wrap; gap:8px}
.chip{border:1px solid var(--line); background:var(--panel-2); color:var(--ink); padding:9px 12px; border-radius:999px; cursor:pointer; font-size:.88rem}
.chip.active{background:var(--accent); color:#191307; border-color:transparent}
.grid{display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:16px}
.card{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:16px; min-height:250px; display:flex; flex-direction:column; gap:12px; transition:transform .2s ease}
.card:hover{transform:translateY(-5px)}
.card .thumb{height:120px; border-radius:12px; background:linear-gradient(135deg, rgba(124,92,255,.32), rgba(255,179,71,.26)), var(--panel-2); display:grid; place-items:center; font-size:2.2rem}
.card h3{font-size:1.12rem}
.card p{margin:0; color:var(--muted); font-size:.92rem; line-height:1.45}
.badge-row{display:flex; flex-wrap:wrap; gap:6px}
.badge{font-size:.72rem; padding:4px 8px; border-radius:999px; background:rgba(255,255,255,.08); color:var(--ink)}
.card .btn{margin-top:auto; align-self:flex-start}
.featured{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:16px}
.game-page .hero{padding:14px 0 8px}
.game-page .hero h1{font-size:clamp(1.4rem,2.8vw,2rem)}
.game-page .hero .kicker{margin-bottom:6px}
.game-page .hero .lead{margin-top:6px; font-size:.95rem; line-height:1.4; max-width:90ch}
/* game pages: tighten vertical rhythm so board + controls fit one screen */
.game-page section{padding:14px 0}
.game-page main > section:first-of-type{padding-top:0}
.play-shell{gap:14px}
.game-page .play-stage{min-height:0; padding:14px}
.game-page .side-panel{padding:18px}
.game-page .game-controls{margin-top:10px}
/* Keep boards compact so the whole game fits within one viewport */
:root{--fit-board:auto; --fit-board-max:auto}
.game-page .board-grid,
.game-page .memory-grid,
.game-page .g2048,
.game-page .bs-grid,
.game-page .merge-grid,
.game-page .sud,
.game-page .whack-grid{
  width:var(--fit-board);
  max-width:var(--fit-board);
  margin-inline:auto;
}
.game-page .board-grid,.game-page .memory-grid,.game-page .g2048,.game-page .bs-grid,.game-page .merge-grid,.game-page .sud,.game-page .whack-grid{
  max-height:var(--fit-board-max);
}
/* aspect-ratio:auto pads (reflex-relay): give an explicit height so they stay tappable */
.game-page .memory-grid[style*="aspect-ratio:auto"]{width:var(--fit-board)}
.game-page .react-zone{max-height:var(--fit-board-max)}
.game-page .wm-pool{max-width:var(--fit-board)}
.play-shell{display:grid; grid-template-columns:1.15fr .85fr; gap:20px; align-items:start}
.play-stage{background:var(--panel); border:1px solid var(--line); border-radius:24px; padding:18px; min-height:0}
.play-stage canvas{width:100%; height:auto; border-radius:14px; background:#0a0b1c; display:block; max-width:560px; margin-inline:auto}
.board-grid{display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; width:320px; margin-inline:auto; aspect-ratio:1; max-width:100%}
.board-cell{aspect-ratio:1; border-radius:12px; display:grid; place-items:center; font-size:1.8rem; background:var(--panel-2); border:1px solid var(--line); cursor:pointer}
.board-cell.x{background:rgba(255,179,71,.18)}
.board-cell.o{background:rgba(91,227,164,.16)}
.board-cell.hit{background:rgba(124,92,255,.32)}
.memory-grid{display:grid; grid-template-columns:repeat(4, 1fr); gap:10px; width:380px; margin-inline:auto; aspect-ratio:1; max-width:100%}
.memory-card{aspect-ratio:1; border-radius:12px; background:var(--panel-2); border:1px solid var(--line); display:grid; place-items:center; font-size:1.6rem; cursor:pointer; transition:.18s; min-height:0}
.memory-card.open{background:rgba(255,179,71,.18); transform:scale(.96)}
.memory-card.done{background:rgba(91,227,164,.2)}
.hud{display:flex; flex-wrap:wrap; gap:10px; margin-bottom:12px}
.hud span{background:var(--panel-2); border:1px solid var(--line); padding:8px 12px; border-radius:12px; font-size:.88rem}
.hud span strong{color:var(--accent); margin-left:8px}
.side-panel{background:var(--panel); border:1px solid var(--line); border-radius:24px; padding:22px}
.side-panel h3{font-size:1.55rem}
.side-panel p{color:var(--muted); line-height:1.6}
.list{list-style:none; padding:0; margin:16px 0; display:grid; gap:10px}
.list li{padding:12px; background:var(--panel-2); border-radius:14px; border:1px solid var(--line)}
.game-controls{display:flex; flex-wrap:wrap; gap:10px; margin-top:14px}
.inline-note{font-size:.9rem; color:var(--muted)}
.quiz-panel{max-width:560px; margin-inline:auto; background:var(--panel); border:1px solid var(--line); border-radius:24px; padding:22px}
.quiz-panel h3{font-size:1.5rem}
.quiz-q{font-size:1.05rem; margin:16px 0; line-height:1.45}
.option-list{display:grid; gap:10px}
.option-list button{text-align:left; border:1px solid var(--line); background:var(--panel-2); color:var(--ink); padding:12px; border-radius:12px; cursor:pointer}
.option-list button.correct{background:rgba(91,227,164,.24)}
.option-list button.wrong{background:rgba(255,82,82,.24)}
.result-line{margin-top:14px; min-height:1.4em}
.snake-controls{display:flex; flex-wrap:wrap; gap:8px; margin-top:12px}
.snake-controls button{width:56px; height:44px; border-radius:12px; border:1px solid var(--line); background:var(--panel-2); color:var(--ink); font-size:1.1rem; cursor:pointer}
.snake-controls .wide{width:auto; padding:0 16px}
.footer{padding:44px 0 60px; border-top:1px solid var(--line); margin-top:40px; background:rgba(10,11,26,.55)}
.footer-grid{display:grid; grid-template-columns:1.3fr 1fr 1fr; gap:18px}
.footer h3{font-size:1.25rem; margin-bottom:8px}
.footer p{color:var(--muted); line-height:1.55}
.footer ul{list-style:none; padding:0; margin:12px 0 0; display:grid; gap:8px}
.footer a{color:var(--ink); text-decoration:none}
.footer a:hover{color:var(--accent)}
@media(max-width:960px){
  .hero-copy,.play-shell,.featured,.grid,.footer-grid{grid-template-columns:1fr}
  .hero-card{order:2}
  .nav{flex-direction:column; align-items:flex-start}
  .nav-links{width:100%}
  .section-title{align-items:flex-start; flex-direction:column}
}
