:root {
  color-scheme: light;
  --ink: #15171f;
  --muted: #606a78;
  --line: #dcd3c1;
  --accent: #e3562f;
  --shadow: 0 24px 70px rgb(21 23 31 / 14%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgb(83 177 239 / 26%), transparent 23rem),
    radial-gradient(circle at 86% 16%, rgb(210 166 59 / 22%), transparent 26rem),
    linear-gradient(135deg, #f8f6f0 0%, #eef6f0 52%, #fbf5e8 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 18px;
}

.topbar,
.brand,
.nav,
.hero,
.instructions,
.game-footer {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.brand {
  gap: 12px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 7px;
}

.nav {
  flex: 0 0 auto;
  gap: 6px;
}

.nav a {
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  border-radius: 7px;
}

.nav a:hover {
  color: var(--ink);
  background: rgb(255 255 255 / 70%);
}

.hero {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 10px;
  color: #b7351c;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2.55rem, 6vw, 5.1rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.instructions {
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.instructions span {
  padding: 7px 9px;
  color: var(--muted);
  background: rgb(255 255 255 / 74%);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 800;
}

.cabinet {
  overflow: hidden;
  padding: 10px;
  background: #15171f;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: min(calc(100vh - 150px), 66vw);
  max-height: 690px;
  background: #0f1726;
  image-rendering: pixelated;
  border-radius: 4px;
}

.touch-controls {
  display: none;
}

.game-footer {
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgb(255 255 255 / 78%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-footer p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

button {
  min-height: 38px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: #b7351c;
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .page {
    display: flex;
    width: 100%;
    min-height: 100dvh;
    flex-direction: column;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .brand {
    min-width: 0;
    gap: 8px;
    font-size: 0.92rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 6px;
  }

  .instructions {
    display: none;
  }

  .nav {
    margin-left: auto;
  }

  .nav a {
    padding: 7px 6px;
    font-size: 0.82rem;
  }

  .cabinet {
    flex: 1 1 auto;
    min-height: 0;
    padding: 6px;
  }

  canvas {
    height: min(calc(100dvh - 188px), 72vw);
    min-height: 260px;
    touch-action: none;
  }

  .game-footer {
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
  }

  .game-footer p {
    font-size: 0.84rem;
    line-height: 1.25;
  }

  .game-footer button {
    display: none;
  }

  .touch-controls {
    display: grid;
    grid-template-columns: 1.35fr 1fr 0.92fr;
    gap: 8px;
    margin-top: 8px;
  }

  .touch-move {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .touch-button {
    min-height: 54px;
    padding: 0 12px;
    font-size: 1.05rem;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .touch-action {
    background: #2563eb;
  }

  .touch-action:hover {
    background: #1d4ed8;
  }

  .touch-restart {
    color: var(--ink);
    background: rgb(255 255 255 / 82%);
    border: 1px solid var(--line);
  }

  .touch-restart:hover {
    background: #fff;
  }
}

@media (max-width: 420px) {
  .brand span:last-child {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav a {
    font-size: 0.78rem;
  }

  canvas {
    height: min(calc(100dvh - 184px), 78vw);
    min-height: 236px;
  }

  .touch-button {
    min-height: 50px;
  }
}

@media (max-width: 900px) and (max-height: 520px) {
  .page {
    padding: max(6px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom));
  }

  .topbar {
    display: none;
  }

  .cabinet {
    padding: 5px;
  }

  canvas {
    height: calc(100dvh - 112px);
    min-height: 180px;
  }

  .game-footer {
    margin-top: 6px;
    padding: 6px 8px;
  }

  .game-footer p {
    font-size: 0.76rem;
  }

  .touch-controls {
    gap: 6px;
    margin-top: 6px;
  }

  .touch-move {
    gap: 6px;
  }

  .touch-button {
    min-height: 44px;
  }
}
