* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060d;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  /* Keep the picture the right shape: never wider than the screen,
     never taller than the screen. */
  width: min(100%, calc(100vh * 384 / 272));
  width: min(100%, calc(100dvh * 384 / 272));
  height: auto;
  aspect-ratio: 384 / 272;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0d1a;
  touch-action: none;
}

/* ---------- touch controls ---------- */

#pad {
  position: fixed;
  inset: auto 0 0 0;
  height: 100%;
  pointer-events: none;
  display: none;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom)) 12px;
}

.pad-side {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  pointer-events: none;
}

.pad-left  { left: calc(14px + env(safe-area-inset-left)); }
.pad-right { right: calc(14px + env(safe-area-inset-right)); }

.btn {
  pointer-events: auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: rgba(20, 24, 44, 0.5);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  line-height: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  backdrop-filter: blur(2px);
  transition: transform 0.05s ease, background 0.05s ease;
}

.btn:active,
.btn.held {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0.92);
}

.btn-jump  { background: rgba(60, 170, 90, 0.5);  font-size: 16px; }
.btn-throw { background: rgba(200, 60, 60, 0.5);  font-size: 15px; }

/* ---------- small buttons ---------- */

#topbar {
  position: fixed;
  top: calc(6px + env(safe-area-inset-top));
  right: calc(6px + env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  z-index: 5;
}

.tiny {
  background: rgba(20, 24, 44, 0.55);
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 5px 8px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  line-height: 1.2;
  font-family: inherit;
}

a.tiny { color: #ffd93d; border-color: rgba(255, 217, 61, 0.55); }

.tiny:active { background: rgba(255, 255, 255, 0.25); }

/* Show the thumb pad on touch screens. */
@media (pointer: coarse), (hover: none) {
  #pad { display: block; }
}

body.touch #pad { display: block; }

/* On short wide screens (phone held sideways) keep the buttons clear of the art. */
@media (max-height: 420px) {
  .btn { width: 62px; height: 62px; font-size: 19px; }
  .btn-jump, .btn-throw { font-size: 13px; }
}

/* On narrow phones the four buttons must not touch each other. */
@media (max-width: 380px) {
  .btn { width: 60px; height: 60px; font-size: 18px; }
  .btn-jump, .btn-throw { font-size: 12px; }
  .pad-side { gap: 10px; }
  .pad-left  { left: calc(8px + env(safe-area-inset-left)); }
  .pad-right { right: calc(8px + env(safe-area-inset-right)); }
}
