:root {
  --bg: #0e0a09;
  --card: #1b120e;
  --card-2: #241712;
  --stroke: #442b20;
  --text: #fbf4ec;
  --muted: #d6baa7;
  --accent: #fb923c;
  --amber: #fbbf24;
  --sky: #7dd3fc;
  --radius: 20px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(850px 520px at 10% -10%, rgba(239, 68, 68, .18), transparent 60%),
    radial-gradient(700px 480px at 100% 0%, rgba(251, 191, 36, .13), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  padding: 0 16px 48px;
}

a { color: #fde68a; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--amber);
  color: #14100a;
  padding: 10px 16px;
  border-radius: 0 0 12px 0;
  font-weight: 700;
  z-index: 10;
}
.skip:focus { left: 0; }

.topbar {
  max-width: 780px;
  margin: 0 auto;
  padding: 14px 0 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.brand-arrow { color: var(--amber); }
.brand-tld { color: var(--muted); font-weight: 500; }

.badge {
  color: var(--muted);
  border: 1px solid var(--stroke);
  background: rgba(27, 18, 14, .85);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .78rem;
}

main {
  max-width: 780px;
  margin: 0 auto;
}

.hero { padding: 10px 0 4px; }
h1 {
  margin: 0;
  font-size: clamp(2rem, 6.5vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -.02em;
  color: #fde68a;
}
.lead {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 62ch;
}

.game-card {
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(36, 23, 18, .97), rgba(27, 18, 14, .97));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 24px 65px rgba(0, 0, 0, .4);
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  background: rgba(14, 10, 9, .65);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-label {
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.stat-value {
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

canvas#stage {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  border: 2px solid var(--stroke);
  background: #140d0a;
  touch-action: none;
  outline: none;
}
canvas#stage:focus-visible { box-shadow: 0 0 0 3px var(--amber); }

.status {
  margin: 10px auto 0;
  min-height: 2.6em;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(14, 10, 9, .65);
  border: 1px solid var(--stroke);
  text-align: center;
  color: var(--text);
  font-size: .92rem;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 66px);
  grid-template-rows: repeat(3, 48px);
  gap: 7px;
  justify-content: center;
  margin: 12px auto 0;
}
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; font-size: .9rem !important; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.dpad-btn {
  border: 1px solid var(--stroke);
  background: var(--card-2);
  color: var(--text);
  border-radius: 13px;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s ease, border-color .12s ease;
}
.dpad-btn:hover { border-color: var(--amber); }
.dpad-btn:active { transform: scale(.95); }
.dpad-center {
  background: #9a3412;
  border-color: #fb923c;
  color: #ffffff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.btn {
  appearance: none;
  border: 1px solid var(--stroke);
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 15px;
  min-height: 44px;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .12s ease, transform .08s ease;
}
.btn:hover { border-color: var(--amber); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(180deg, #fcd34d, #f59e0b);
  border-color: #f59e0b;
  color: #1c1002;
}

.quick-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.chip {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(14, 10, 9, .7);
  color: #fde68a;
  border-radius: 999px;
  padding: 7px 13px;
  min-height: 38px;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { border-color: var(--amber); }

.toggles {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(14, 10, 9, .55);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.toggles-legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: .92rem;
  color: var(--text);
  min-height: 36px;
}
.toggle-featured { font-weight: 700; color: #fde68a; }
.toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
  cursor: pointer;
}

.help {
  margin-top: 12px;
  border-top: 1px solid var(--stroke);
  padding-top: 10px;
}
.help summary {
  cursor: pointer;
  color: #fde68a;
  font-weight: 700;
  padding: 4px 0;
}
.help-body { color: var(--muted); font-size: .92rem; }
.help-body ul { padding-left: 20px; }
.help-body li { margin: 5px 0; }

kbd {
  font: inherit;
  font-size: .82em;
  border: 1px solid var(--stroke);
  border-bottom-width: 2px;
  background: #140d0a;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
}

.foot {
  max-width: 780px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

body.blind-mode .status {
  border-color: var(--amber);
  background: #22150e;
  font-size: 1.02rem;
  font-weight: 600;
}
body.blind-mode .dpad-btn { border-width: 2px; }
body.blind-mode .btn { min-height: 50px; }

/* Высокий контраст WCAG AAA */
body.high-contrast {
  background: #000000;
  color: #ffffff;
  --bg: #000000;
  --card: #000000;
  --card-2: #000000;
  --stroke: #ffffff;
  --text: #ffffff;
  --muted: #f5f5f5;
  --amber: #ffe600;
}
body.high-contrast h1,
body.high-contrast a,
body.high-contrast .help summary,
body.high-contrast .toggle-featured,
body.high-contrast .brand-arrow { color: #ffe600; }
body.high-contrast .game-card,
body.high-contrast .stat,
body.high-contrast .status,
body.high-contrast .toggles,
body.high-contrast .badge,
body.high-contrast .chip,
body.high-contrast .btn,
body.high-contrast .dpad-btn {
  background: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: none;
}
body.high-contrast .btn-primary,
body.high-contrast .dpad-center {
  background: #ffe600;
  color: #000000;
  border: 2px solid #ffffff;
}

@media (max-width: 700px) {
  body { padding: 0 10px 32px; }
  .topbar { padding: 10px 0 4px; }
  .badge { font-size: .72rem; padding: 4px 10px; }
  .hero { padding: 4px 0 0; }
  h1 { font-size: 1.65rem; }
  .lead { display: none; }
  .game-card { margin-top: 8px; padding: 12px; border-radius: 16px; }
  .hud { gap: 6px; margin-bottom: 8px; }
  .stat { padding: 5px 8px; }
  .stat-value { font-size: .88rem; }
  .status { margin-top: 8px; min-height: 2.3em; padding: 6px 10px; font-size: .86rem; }
  .dpad {
    grid-template-columns: repeat(3, 62px);
    grid-template-rows: repeat(3, 44px);
    gap: 6px;
    margin-top: 10px;
  }
  .actions .btn { flex: 1 1 44%; padding: 9px 10px; font-size: .88rem; }
}
