/* Full-screen, no scroll, no text selection — feels like an app, not a webpage. */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1e3a;
  /* Disable browser touch gestures (scroll/zoom) so they don't fight the game. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlay shown before play and after a round. */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(11, 30, 58, 0.85);
  color: #fff;
  text-align: center;
  padding: 24px;
  /* Respect iPad notch / safe areas. */
  padding-top: calc(24px + env(safe-area-inset-top));
}

.overlay.hidden { display: none; }

.overlay h1 { font-size: clamp(32px, 9vw, 72px); }
.overlay p  { font-size: clamp(18px, 4.5vw, 32px); opacity: 0.9; }

/* Big, finger-friendly button. ~44px is Apple's min touch target; we go bigger. */
.big-btn {
  font-size: clamp(24px, 6vw, 40px);
  padding: 20px 48px;
  min-width: 200px;
  min-height: 72px;
  border: none;
  border-radius: 999px;
  background: #ffd54f;
  color: #5d4037;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #f9a825;
  transition: transform 0.05s ease;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #f9a825; }

/* Floating controls (top-right), clear of the notch via safe-area inset. */
.controls {
  position: fixed;
  /* Right edge, vertically centered — clear of the top nav bar and bottom tray. */
  top: 50%;
  transform: translateY(-50%);
  right: calc(10px + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 5;
}
.ctrl-btn {
  width: 64px;
  height: 64px;
  font-size: 30px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.on { background: #ffe082; box-shadow: 0 0 0 3px #ffb300, 0 3px 8px rgba(0,0,0,0.2); }

/* In-game name dialog (a card centered on the dimmed overlay). */
.dialog {
  background: #fff;
  color: #37474f;
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 280px;
  max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.dialog h2 { font-size: clamp(20px, 5vw, 32px); text-align: center; }
#name-input {
  font-size: clamp(20px, 5vw, 30px);
  padding: 14px 18px;
  border: 3px solid #ffb300;
  border-radius: 14px;
  text-align: center;
  outline: none;
  /* Inputs must allow selection/typing despite the global no-select rules. */
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}
.dialog-buttons { display: flex; gap: 14px; justify-content: center; }
.dialog .big-btn {
  min-width: 120px;
  min-height: 56px;
  padding: 14px 24px;
  font-size: clamp(18px, 4.5vw, 26px);
}
.big-btn.secondary { background: #eceff1; color: #607d8b; box-shadow: 0 6px 0 #cfd8dc; }
.big-btn.secondary:active { box-shadow: 0 2px 0 #cfd8dc; }

/* On-screen D-pad (bottom-left), shown only in play scenes. */
.dpad {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  z-index: 6;
}
.dpad.hidden { display: none; }
.dpad .arrow {
  font-size: 24px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #455a64;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  touch-action: none;
}
.dpad .arrow:active { background: #ffe082; }
.dpad .up    { grid-area: 1 / 2; }
.dpad .left  { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down  { grid-area: 3 / 2; }
