:root {
  color-scheme: light;
  --bg: #eef2f4;
  --panel: #ffffff;
  --text: #17202b;
  --muted: #667488;
  --line: #d8dee7;
  --board: #101820;
  --accent: #0f766e;
  --accent-dark: #0a5d57;
  --yellow: #f2b705;
  --shadow: 0 20px 52px rgba(23, 32, 43, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(300deg, rgba(242, 183, 5, 0.14), transparent 38%),
    var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.game-shell {
  width: min(1180px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.topbar,
.game-layout {
  display: flex;
  gap: 16px;
}

.topbar {
  align-items: start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eyebrow,
.panel-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}

.secondary-button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.secondary-button {
  background: #e9eef4;
  color: var(--text);
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.game-layout {
  align-items: stretch;
}

.board-wrap {
  flex: 1;
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--board);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #84d7ff;
}

.side-panel {
  width: min(280px, 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stats-grid div,
.keys {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.stats-grid div {
  min-height: 82px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  font-size: 26px;
}

.keys {
  padding: 14px;
}

.keys dl {
  margin: 0;
  display: grid;
  gap: 9px;
}

.keys div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.keys div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.keys dt,
.keys dd {
  margin: 0;
}

.keys dt {
  font-weight: 800;
}

.keys dd {
  color: var(--muted);
}

.touch-controls {
  display: grid;
  grid-template-columns: 64px 84px 84px 84px 92px 64px;
  gap: 8px;
  margin-top: 14px;
}

.touch-controls button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

@media (max-width: 860px) {
  .game-shell {
    padding: 18px;
  }

  .topbar,
  .game-layout {
    flex-direction: column;
  }

  .side-panel {
    width: 100%;
  }

  .touch-controls {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
