:root {
  color-scheme: light;
  background: #d9f4ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  background: #d9f4ff;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #8ed9f7;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.win-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  background: rgba(20, 48, 70, 0.42);
}

.win-screen[hidden] { display: none; }

.win-screen h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(42px, 9vw, 88px);
  letter-spacing: 4px;
  text-shadow: 5px 5px 0 #2d4770;
}

.win-screen button {
  border: 4px solid #fff;
  padding: 12px 22px;
  color: #fff;
  background: #e45b4b;
  box-shadow: 4px 4px 0 #8e3040;
  font: bold 18px system-ui, sans-serif;
  cursor: pointer;
}

.win-screen button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #8e3040;
}

.touch-controls {
  display: none;
  position: absolute;
  z-index: 2;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.movement-controls,
.action-controls {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-control {
  width: clamp(58px, 16vw, 78px);
  height: clamp(58px, 16vw, 78px);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  color: #fff;
  background: rgba(34, 37, 61, 0.72);
  box-shadow: 0 4px 0 rgba(15, 17, 31, 0.52);
  font: 800 clamp(21px, 6vw, 30px)/1 system-ui, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-control--jump,
.touch-control--cast {
  font-size: clamp(12px, 3.4vw, 16px);
}

.touch-control--jump { background: rgba(56, 123, 189, 0.82); }
.touch-control--cast { background: rgba(157, 83, 177, 0.82); }

.touch-control:active,
.touch-control.is-pressed {
  transform: translateY(4px);
  box-shadow: none;
  filter: brightness(1.2);
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: flex; }
}

@media (max-height: 500px) and (hover: none) and (pointer: coarse) {
  .touch-controls {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
  }

  .movement-controls,
  .action-controls { gap: 8px; }
  .touch-control { width: 52px; height: 52px; }
}
