:root {
  color-scheme: dark;
  --bg: #101415;
  --panel: #191f21;
  --panel-2: #22292c;
  --line: #344044;
  --text: #f4f7f8;
  --muted: #aebbc0;
  --green: #4fd36b;
  --cyan: #5ec7ff;
  --red: #ff6464;
  --yellow: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav a,
button,
.game-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  white-space: normal;
}

button:hover,
.game-link:hover,
.nav a:hover {
  border-color: var(--cyan);
}

button.primary,
.game-link.primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #071014;
}

.hero {
  min-height: calc(100vh - 88px);
  display: grid;
  align-content: center;
  gap: 28px;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(42px, 8vw, 88px);
  line-height: 1.08;
}

.hero p {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.game-card,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.game-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.game-card h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
}

.game-card p,
.status,
.score {
  color: var(--muted);
  line-height: 1.45;
}

.game-card p {
  margin: 0;
}

.play-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  align-items: start;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 170px);
  object-fit: contain;
  background: #0a0d0e;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.board-wrap {
  min-width: 0;
  width: 100%;
}

.stack {
  display: grid;
  gap: 12px;
}

.status {
  min-height: 22px;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  justify-content: center;
  gap: 8px;
}

.controls button {
  width: 58px;
  height: 48px;
  padding: 0;
}

.controls .wide {
  grid-column: span 3;
  width: auto;
}

.hidden {
  visibility: hidden;
}

@media (max-width: 820px) {
  body {
    min-width: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand {
    font-size: 18px;
  }

  .nav {
    width: 100%;
  }

  .nav a {
    flex: 1 1 0;
    text-align: center;
    padding-inline: 8px;
  }

  .game-grid,
  .play-layout {
    grid-template-columns: 1fr;
  }

  .play-layout {
    gap: 10px;
  }

  .shell {
    width: 100%;
    padding: 10px;
  }

  .hero {
    min-height: 100dvh;
    align-content: start;
    padding-top: 22px;
    gap: 18px;
  }

  .hero h1 {
    font-size: 36px;
    line-height: 1.12;
  }

  .hero p {
    font-size: 15px;
    line-height: 1.6;
  }

  .game-card,
  .panel {
    padding: 12px;
  }

  .game-card h2 {
    font-size: 21px;
    line-height: 1.3;
  }

  .game-link,
  button {
    width: 100%;
    min-height: 46px;
    text-align: center;
    line-height: 1.3;
    padding-block: 11px;
  }

  canvas {
    max-height: 52dvh;
    border-radius: 6px;
  }

  .panel {
    gap: 8px;
  }

  .status,
  .score {
    min-height: auto;
    font-size: 14px;
    line-height: 1.35;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(54px, 1fr));
    gap: 6px;
    width: 100%;
  }

  .controls button {
    width: 100%;
    height: 44px;
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding: 8px;
  }

  canvas {
    max-height: 48dvh;
  }

  .hero h1 {
    font-size: 30px;
    line-height: 1.16;
  }

  .game-card p {
    font-size: 14px;
    line-height: 1.55;
  }
}
