:root {
  --sky: #7ed7ff;
  --grass: #35b852;
  --ground: #b96f38;
  --brick: #d85037;
  --ink: #172039;
  --cream: #fff4c2;
  --panel: #fff8dc;
  --shadow: #612f24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, sans-serif;
  background:
    linear-gradient(transparent 68%, rgba(37, 111, 45, 0.18) 68%),
    linear-gradient(180deg, #7ed7ff 0%, #c7f1ff 58%, #5fd368 58%, #2da247 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: auto 0 0;
  height: 72px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 18px, transparent 18px 36px),
    linear-gradient(#c47a3d 0 16px, #8f4d2b 16px 100%);
  border-top: 6px solid #5e8f3d;
}

.game-shell {
  width: min(1040px, calc(100vw - 28px));
  min-height: min(720px, calc(100vh - 32px));
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(260px, 340px);
  gap: 24px;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: 24px;
}

.play-zone {
  position: relative;
  width: min(420px, 100%);
  margin-inline: auto;
  display: grid;
  place-items: center;
}

canvas {
  image-rendering: pixelated;
}

#board {
  width: min(100%, 360px);
  aspect-ratio: 1 / 2;
  height: auto;
  background: #1b2548;
  border: 8px solid var(--cream);
  outline: 6px solid var(--shadow);
  box-shadow: 0 12px 0 #3c211b;
}

.overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
  padding: 28px;
  background: rgba(23, 32, 57, 0.86);
  color: white;
  border: 4px solid var(--cream);
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 1;
  text-shadow: 4px 4px 0 #d85037, 8px 8px 0 #172039;
}

.overlay p {
  margin: 0;
  font-size: 1rem;
}

button {
  justify-self: center;
  min-width: 148px;
  border: 0;
  padding: 13px 18px;
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: var(--brick);
  box-shadow: 0 6px 0 #8b2f22;
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #8b2f22;
}

.hud {
  display: grid;
  gap: 16px;
  align-content: center;
}

.brand,
.stats-grid,
.preview-panel,
.controls,
.rules-panel {
  background: var(--panel);
  border: 4px solid #7b442c;
  box-shadow: 6px 6px 0 #3b2a2a;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.badge-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  background: #49d7ff;
  border: 5px solid #1f6fb0;
  box-shadow: inset -5px -5px 0 #2f68ff;
}

.brand h2,
.brand p,
.preview-panel h3,
.controls h3,
.rules-panel h3,
.rules-panel p {
  margin: 0;
}

.brand h2 {
  font-size: 1.12rem;
}

.brand p {
  color: #70533c;
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 10px;
}

.stats-grid div {
  min-height: 76px;
  display: grid;
  align-content: center;
  padding: 10px;
  background: #ffe58a;
  border: 3px solid #b5791d;
}

.stats-grid span {
  font-size: 0.85rem;
  color: #6e4c2d;
}

.stats-grid strong {
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.1;
}

.preview-panel,
.controls,
.rules-panel {
  padding: 16px;
}

.preview-panel {
  display: grid;
  gap: 12px;
}

#next {
  width: 120px;
  height: 120px;
  justify-self: center;
  background: #22305d;
  border: 4px solid #172039;
}

.controls {
  display: grid;
  gap: 10px;
}

.rules-panel {
  display: grid;
  gap: 8px;
}

.rules-panel p {
  color: #5f422d;
  font-size: 0.88rem;
  line-height: 1.45;
}

.controls div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  align-items: center;
}

.keys {
  display: flex;
  gap: 6px;
  align-items: center;
}

kbd {
  display: inline-grid;
  min-width: 30px;
  min-height: 28px;
  place-items: center;
  padding: 3px 6px;
  color: white;
  background: #28335d;
  border: 2px solid #101832;
  box-shadow: 0 3px 0 #101832;
  font: 700 0.8rem Arial, sans-serif;
}

@media (max-width: 760px) {
  body {
    place-items: start center;
  }

  .game-shell {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 18px 0 96px;
  }

  .hud {
    width: min(420px, 100%);
    margin-inline: auto;
  }

  .controls div {
    grid-template-columns: 92px 1fr;
  }
}
