:root {
  color-scheme: light;
  --ink: #14263a;
  --paper: #fff1bd;
  --coral: #f26a5d;
  --lake: #1c8799;
  --mint: #8fdb9a;
  --sky: #b5e7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

main {
  display: grid;
  gap: 1rem;
  width: min(74rem, calc(100% - 2rem));
  min-height: 100vh;
  align-content: center;
  margin: 0 auto;
  padding: 2rem 0;
}

h1,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  font-size: 4.2rem;
  line-height: 1;
}

p,
li {
  font-size: 1.05rem;
  line-height: 1.5;
}

ul {
  margin: 0;
  padding-left: 1.2rem;
}

.back-link {
  justify-self: start;
  color: var(--ink);
  font-weight: 850;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 0.22rem;
  text-underline-offset: 0.22rem;
}

.game-lab {
  display: grid;
  grid-template-columns: minmax(16rem, 24rem) minmax(18rem, 1fr);
  gap: 1rem;
  align-items: center;
}

.copy {
  display: grid;
  gap: 1rem;
}

.board {
  display: grid;
  gap: 0.65rem;
  padding: 0.5rem;
  border-radius: 12px;
  outline: 4px solid transparent;
  outline-offset: 3px;
}

.board:focus-visible {
  outline-color: var(--coral);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
}

.hud p,
.hud button {
  min-height: 2.6rem;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0.25rem 0.25rem 0 var(--lake);
}

.hud p {
  display: grid;
  align-items: center;
  min-width: 7rem;
  padding: 0 0.7rem;
  background: var(--mint);
  font-weight: 850;
}

.hud button {
  padding: 0 0.8rem;
  color: var(--ink);
  background: var(--coral);
  font: inherit;
  font-weight: 850;
}

canvas {
  display: block;
  width: 100%;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--sky);
  box-shadow: 0.45rem 0.45rem 0 var(--lake);
  aspect-ratio: 12 / 7;
}

.control-help {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.direction-pad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left down right";
  grid-template-columns: repeat(3, minmax(3.25rem, 4.5rem));
  gap: 0.45rem;
  justify-content: center;
  touch-action: none;
}

.move-button {
  min-width: 3.25rem;
  min-height: 3.25rem;
  border: 3px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  background: var(--mint);
  box-shadow: 0.18rem 0.18rem 0 var(--lake);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.move-button:focus-visible {
  outline: 4px solid var(--coral);
  outline-offset: 2px;
}

.move-button:active {
  box-shadow: none;
  transform: translate(0.18rem, 0.18rem);
}

.move-up { grid-area: up; }
.move-left { grid-area: left; }
.move-down { grid-area: down; }
.move-right { grid-area: right; }

@media (max-width: 48rem) {
  h1 {
    font-size: 2.7rem;
  }

  .game-lab {
    grid-template-columns: 1fr;
  }

  main {
    width: min(100% - 1rem, 36rem);
    padding: 1rem 0;
  }

  .board {
    min-width: 0;
  }
}
