:root {
  color-scheme: dark;
  --bg: #121114;
  --panel: #1d1b22;
  --ink: #f4eee5;
  --muted: #b9afa5;
  --red: #e42126;
  --blue: #315c6f;
  --gold: #d8b45f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(228, 33, 38, .13), transparent 28rem),
    radial-gradient(circle at 80% 20%, rgba(49, 92, 111, .2), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  user-select: none;
  -webkit-user-select: none;
}

.wrap {
  width: min(100vw - 12px, 1080px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 0 calc(12px + var(--safe-bottom));
  display: grid;
  align-content: center;
  gap: 10px;
}

.hero {
  display: grid;
  gap: 4px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: clamp(10px, 2.8vw, 12px);
}

h1 {
  margin: 0;
  font-size: clamp(28px, 9vw, 64px);
  line-height: .92;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #000, 6px 6px 0 rgba(228,33,38,.5);
}

.tagline {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: clamp(12px, 3.4vw, 16px);
}

.game-card {
  border: 3px solid #000;
  background: var(--panel);
  box-shadow: 0 10px 0 #000, 0 18px 32px rgba(0,0,0,.45);
  padding: 6px;
}

.game-shell {
  position: relative;
  overflow: hidden;
  border: 2px solid #000;
  background: #9fb3b3;
  touch-action: none;
  margin: 0 auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(62svh, 520px);
  image-rendering: pixelated;
  background: #9fb3b3;
  cursor: pointer;
  touch-action: none;
}


.tap-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 7px;
  border: 2px solid #000;
  background: rgba(18, 17, 20, .72);
  color: var(--gold);
  font-size: 10px;
  letter-spacing: .08em;
  pointer-events: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.desktop-only { display: none; }
.mobile-only { display: inline; }

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 6px;
  border: 2px solid #000;
  border-bottom-width: 4px;
  border-radius: 4px;
  background: #f4eee5;
  color: #151515;
  font: inherit;
  text-align: center;
}

@media (orientation: landscape) and (max-height: 520px) {
  .wrap {
    width: min(100vw - 18px, 1080px);
    grid-template-columns: minmax(170px, 24vw) 1fr;
    align-items: center;
    gap: 10px;
  }

  .hero { text-align: left; }
  h1 { font-size: clamp(24px, 5vw, 44px); }
  .tagline { font-size: 12px; }
  canvas { max-height: calc(100svh - 46px - var(--safe-top) - var(--safe-bottom)); }
  .controls { grid-column: 2; padding-top: 6px; }
}

@media (orientation: landscape) and (max-width: 900px) and (max-height: 560px) {
  body.mobile-landscape {
    overflow: hidden;
  }

  body.mobile-landscape .wrap {
    width: 100vw;
    min-height: 100dvh;
    padding: var(--safe-top) max(8px, var(--safe-bottom)) var(--safe-bottom);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.mobile-landscape .hero,
  body.mobile-landscape .controls {
    display: none;
  }

  body.mobile-landscape .game-card {
    width: 100%;
    max-width: none;
    border-width: 2px;
    padding: 4px;
    box-shadow: 0 8px 0 #000, 0 14px 24px rgba(0,0,0,.38);
  }

  body.mobile-landscape .game-shell {
    width: min(
      calc(100vw - 12px - var(--safe-top) - var(--safe-bottom)),
      calc((100dvh - 12px - var(--safe-top) - var(--safe-bottom)) * 2.6667)
    );
  }

  body.mobile-landscape canvas {
    width: 100%;
    max-height: none;
  }

  body.mobile-landscape .tap-hint {
    bottom: 6px;
    right: 6px;
  }
}

@media (min-width: 760px) {
  .wrap {
    width: min(1080px, calc(100vw - 24px));
    padding-top: calc(28px + var(--safe-top));
    gap: 18px;
  }

  .hero {
    text-align: left;
    gap: 6px;
  }

  .game-card {
    padding: 10px;
    box-shadow: 0 16px 0 #000, 0 22px 40px rgba(0,0,0,.45);
  }

  .controls {
    justify-content: space-between;
    font-size: 13px;
  }

  .desktop-only { display: inline; }
  .mobile-only { display: none; }
  .tap-hint { display: none; }
}
