:root {
  color-scheme: light;
  --ink: #2b2118;
  --muted: #7b6454;
  --paper: #fff8ea;
  --panel: rgba(255, 252, 243, 0.88);
  --accent: #e85d3f;
  --accent-2: #229a8a;
  --line: rgba(66, 47, 30, 0.18);
  --shadow: 0 18px 42px rgba(73, 49, 25, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 246, 220, 0.72)),
    radial-gradient(circle at 20% 10%, #ffd98d 0 14%, transparent 38%),
    linear-gradient(135deg, #fdf3d6, #d7f1e7 52%, #ffe0c8);
  color: var(--ink);
  font-family:
    "Inter", "BIZ UDPGothic", "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  letter-spacing: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-shell {
  width: min(100vw, 1180px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4.8vw, 2.4rem);
  line-height: 1.05;
}

.icon-button,
.primary-button,
.control-button,
.jump-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  font-weight: 900;
}

.stage-wrap {
  position: relative;
  align-self: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #8bd4ff;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 249, 233, 0.2), rgba(255, 249, 233, 0.66));
  backdrop-filter: blur(2px);
}

.overlay-panel[hidden] {
  display: none;
}

.panel-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.overlay-panel h2 {
  margin: 0;
  max-width: 12em;
  font-size: clamp(1.6rem, 7vw, 4rem);
  line-height: 1.04;
}

.primary-button {
  justify-self: center;
  min-width: 180px;
  min-height: 54px;
  padding: 0 24px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  touch-action: none;
}

.dpad {
  display: flex;
  gap: 10px;
}

.control-button,
.jump-button {
  min-width: 72px;
  height: 64px;
  border-radius: 8px;
  font-size: 1.35rem;
  font-weight: 950;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.jump-button {
  width: min(33vw, 150px);
  background: #ffe078;
}

.control-button:active,
.jump-button:active,
.icon-button:active,
.primary-button:active {
  transform: translateY(1px);
}

@media (orientation: landscape) and (max-height: 560px) {
  .game-shell {
    grid-template-columns: 1fr 150px;
    grid-template-rows: auto 1fr;
  }

  .topbar {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .touch-controls {
    grid-template-columns: 1fr;
    align-content: end;
    min-height: 0;
  }

  .dpad {
    justify-content: center;
  }
}
