/* Sonic Games — браузерные мини-игры. Без внешних шрифтов и запросов. */
:root {
  --bg: #fff6ea;
  --paper: #ffffff;
  --ink: #1d1a2b;
  --muted: #625c74;
  --line: #1d1a2b;
  --orange: #ff6a2b;
  --teal: #10b3a3;
  --yellow: #ffd23f;
  --pink: #ff5d8f;
  --violet: #6c4cff;
  --radius: 18px;
  --shadow: 5px 5px 0 var(--line);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17142a;
    --paper: #221e3a;
    --ink: #f5f1ff;
    --muted: #b3abcc;
    --line: #0b0917;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, svg, canvas { display: block; max-width: 100%; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

/* шапка */
.top { padding: 18px 0; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 900; font-size: 20px; letter-spacing: -.01em; }
.brand-mark { width: 38px; height: 38px; }
.nav { display: flex; gap: 6px; }
.nav a { text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 12px; }
.nav a:hover { background: color-mix(in srgb, var(--yellow) 45%, transparent); }
.brand, .nav a { white-space: nowrap; }
@media (max-width: 420px) { .brand { font-size: 18px; } .nav { gap: 0; } .nav a { padding: 8px; } }

/* первый экран */
.hero { padding: 36px 0 28px; }
.hero h1 { font-size: clamp(34px, 6vw, 60px); line-height: 1.14; letter-spacing: -.03em; margin: 0 0 16px; max-width: 18ch; }
.hero h1 em { font-style: normal; color: #1d1a2b; background: var(--yellow); padding: 0 .12em; border-radius: 10px;
  box-shadow: 3px 3px 0 var(--line); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hero p { color: var(--muted); font-size: 18px; max-width: 52ch; margin: 0 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 2px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 700; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }

/* карточки игр */
.section { padding: 26px 0 40px; }
.section h2 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 18px; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.game {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--paper); border: 2.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: transform .15s ease, box-shadow .15s ease;
}
a.game:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--line); }
.game-cover { aspect-ratio: 16 / 10; border-bottom: 2.5px solid var(--line); }
.game-body { padding: 14px 16px 16px; display: grid; gap: 6px; }
.game-title { font-weight: 900; font-size: 20px; }
.game-text { color: var(--muted); font-size: 15px; }
.game-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 8px; border: 2px solid var(--line); }
.game.soon { opacity: .7; }

.about { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.note { background: var(--paper); border: 2.5px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.note b { display: block; font-size: 17px; margin-bottom: 4px; }
.note p { margin: 0; color: var(--muted); }

.foot { padding: 28px 0 40px; color: var(--muted); font-size: 14px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }

/* страница игры */
.play { padding: 10px 0 40px; }
.play-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.play-head h1 { margin: 0; font-size: clamp(28px, 5vw, 40px); letter-spacing: -.02em; }
.back { text-decoration: none; font-weight: 700; color: var(--muted); }
.scores { display: flex; gap: 10px; }
.score { min-width: 92px; padding: 6px 12px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--paper); text-align: center; box-shadow: 3px 3px 0 var(--line); }
.score small { display: block; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.score b { font-size: 22px; }
.stage { position: relative; width: min(480px, 100%); margin: 0 auto; }
.board { width: 100%; aspect-ratio: 1; border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); touch-action: none; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: var(--radius);
}
.overlay h2 { margin: 0 0 6px; font-size: 26px; }
.overlay p { margin: 0 0 14px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--orange);
  color: #fff; font: inherit; font-weight: 800; cursor: pointer; box-shadow: 3px 3px 0 var(--line); text-decoration: none;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn.alt { background: var(--paper); color: var(--ink); }
.help { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.pad { display: none; grid-template-columns: repeat(3, 58px); gap: 8px; justify-content: center; margin: 16px auto 0; }
.pad button { height: 52px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); font-size: 20px; font-weight: 900; box-shadow: 3px 3px 0 var(--line); }
.pad button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
@media (pointer: coarse) { .pad { display: grid; } }

/* 2048 */
.grid2048 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 10px;
  background: #3a3354; touch-action: none; user-select: none;
}
.cell { border-radius: 12px; background: rgba(255, 255, 255, .1); display: grid; place-items: center; aspect-ratio: 1;
  font-weight: 900; font-size: clamp(20px, 6vw, 34px); color: var(--ink); }
.cell.v2 { background: #fff1d6; } .cell.v4 { background: #ffe1a8; }
.cell.v8 { background: #ffb36b; color: #fff; } .cell.v16 { background: #ff8a4c; color: #fff; }
.cell.v32 { background: #ff6a2b; color: #fff; } .cell.v64 { background: #ff4d4d; color: #fff; }
.cell.v128 { background: #ffd23f; font-size: clamp(18px, 5vw, 30px); }
.cell.v256 { background: #b9e769; font-size: clamp(18px, 5vw, 30px); }
.cell.v512 { background: #10b3a3; color: #fff; font-size: clamp(18px, 5vw, 30px); }
.cell.v1024 { background: #4c8dff; color: #fff; font-size: clamp(15px, 4.2vw, 25px); }
.cell.v2048, .cell.big { background: #6c4cff; color: #fff; font-size: clamp(15px, 4.2vw, 25px); }
.cell.pop { animation: pop .14s ease; }
@keyframes pop { from { transform: scale(.75); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .cell.pop { animation: none; } a.game { transition: none; } }

/* 404 */
.lost { padding: 60px 0 80px; text-align: center; }
.lost h1 { font-size: clamp(60px, 14vw, 120px); margin: 0; letter-spacing: -.04em; }
.lost p { color: var(--muted); margin: 6px 0 22px; }
