:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #141d33;
  --panel-soft: #1b2742;
  --text: #f4f7ff;
  --muted: #9aa8c4;
  --accent: #8b7cff;
  --accent-2: #47d7c2;
  --line: rgba(255,255,255,.09);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -15%, #26345d 0, var(--bg) 55%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, select { font: inherit; }
.app { width: min(100% - 28px, 760px); margin: 0 auto; padding: 20px 0 26px; }
.topbar, .brand, .game-toolbar, footer { display: flex; align-items: center; justify-content: space-between; }
.brand { gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, var(--accent), #5145c9); font-weight: 900; letter-spacing: -1px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .08em; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .16em; margin-top: 3px; }
.offline-pill { color: #9ce8d9; font-size: 10px; letter-spacing: .08em; border: 1px solid rgba(71,215,194,.25); border-radius: 99px; padding: 7px 10px; }
.offline-pill i { display: inline-block; width: 6px; height: 6px; background: var(--accent-2); border-radius: 50%; margin-right: 5px; }
.hero { text-align: center; padding: 38px 0 24px; }
.eyebrow { color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: .24em; }
h1 { font-size: clamp(34px, 8vw, 52px); line-height: 1.05; letter-spacing: -.05em; margin: 10px 0; }
h1 span { color: #a79cff; }
.intro { max-width: 440px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.6; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 14px; }
.stat { background: rgba(20,29,51,.9); border: 1px solid var(--line); border-radius: 13px; padding: 12px 8px; text-align: center; min-width: 0; }
.stat span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.stat strong { display: block; font-size: clamp(16px, 4vw, 21px); margin-top: 5px; font-variant-numeric: tabular-nums; }
.game-panel { background: rgba(20,29,51,.88); border: 1px solid var(--line); border-radius: 20px; padding: 15px; box-shadow: 0 18px 50px rgba(0,0,0,.22); }
.game-toolbar { gap: 9px; flex-wrap: wrap; }
.game-toolbar label { color: var(--muted); font-size: 12px; }
select { flex: 1; min-width: 125px; background: var(--panel-soft); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; outline: none; }
.button { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 750; cursor: pointer; transition: transform .15s, filter .15s; }
.button:active, .card:active { transform: scale(.97); }
.button-secondary { background: #293653; color: var(--text); }
.button-primary { background: linear-gradient(135deg, var(--accent), #6557e8); color: white; padding: 12px 22px; }
.message { min-height: 35px; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0 5px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(7px, 2vw, 12px); }
.board.medium { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.board.hard { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.card { border: 1px solid rgba(255,255,255,.09); border-radius: 12px; aspect-ratio: 1; min-width: 0; background: linear-gradient(145deg, #344267, #202c49); color: white; display: grid; place-items: center; font-size: clamp(22px, 6vw, 34px); cursor: pointer; box-shadow: inset 0 1px rgba(255,255,255,.08), 0 4px 9px rgba(0,0,0,.16); transition: transform .16s, background .16s, border-color .16s; user-select: none; -webkit-tap-highlight-color: transparent; }
.card::before { content: "?"; color: #aeb9d4; font-weight: 800; font-size: .8em; }
.card.revealed, .card.matched { background: linear-gradient(145deg, #f0f3ff, #dce4ff); color: #17213b; border-color: #c4ceff; }
.card.revealed::before, .card.matched::before { content: none; }
.card.matched { background: linear-gradient(145deg, #b6f4e8, #72d9c7); border-color: #72d9c7; cursor: default; }
.card:disabled { opacity: 1; }
.win-panel { text-align: center; padding: 22px 10px 12px; }
.win-panel[hidden] { display: none; }
.trophy { font-size: 42px; }
.win-panel h2 { margin: 8px 0; }
.win-panel p { color: var(--muted); font-size: 13px; }
footer { color: #74819d; font-size: 10px; padding: 18px 3px 0; }
@media (max-width: 390px) {
  .app { width: min(100% - 20px, 760px); padding-top: 14px; }
  .game-panel { padding: 11px; border-radius: 16px; }
  .stats { gap: 6px; }
  .stat { padding: 10px 4px; }
  .board { gap: 6px; }
  .card { border-radius: 9px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }