/* Playforia Minigolf - browser port. Visual goal: pixel-faithful match to the
   original Java AWT client (light-green background #99FF99, pastel buttons,
   serif titles, AWT-style 3D-bevel widgets).

   Mobile/touch support is appended at the bottom: a portrait-mode "rotate
   your phone" prompt and a transform-scale fit on the fixed 735×525 #app for
   landscape touch devices. The game.ts mount handler hooks touch events on
   the canvas and floats a magnifier loupe above the finger during drag-to-shoot. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #2a2d33;
  color: #000;
  font-family: "Verdana", Tahoma, Geneva, sans-serif;
  font-size: 12px;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  /* `100dvh` follows the dynamic viewport so the layout shrinks when the
     mobile address bar appears and grows when it collapses. `100vh` falls
     back for browsers that don't support dvh - they get the static large
     viewport which can be partially covered by the bar. */
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  width: 735px;
  height: 525px;
  background: #99ff99; /* GolfGameFrame.colourGameBackground */
  border: 1px solid #000;
  position: relative;
  overflow: hidden;
}

/* ---------- AWT-style controls ---------- */

input[type="text"],
input[type="password"],
select {
  background: #fff;
  color: #000;
  border: 1px solid #000;
  border-top-color: #7a7a7a;
  border-left-color: #7a7a7a;
  padding: 2px 4px;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  font-size: 12px;
  border-radius: 0;
  outline: none;
}

input[type="text"]:focus,
select:focus {
  outline: 1px dotted #000;
  outline-offset: -3px;
}

button {
  background: #d9d9d9; /* Dialog grey - matches AWT default */
  color: #000;
  border: 2px outset #d9d9d9;
  padding: 3px 12px;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  font-size: 12px;
  cursor: pointer;
  border-radius: 0;
  min-height: 22px;
}

button:active:not(:disabled) {
  border-style: inset;
}

button:disabled {
  color: #888;
  cursor: not-allowed;
}

/* Coloured AWT buttons: green / yellow / red / blue */
button.btn-green  { background: #90e090; border-color: #90e090; }
button.btn-yellow { background: #e0e090; border-color: #e0e090; }
button.btn-red    { background: #e09090; border-color: #e09090; }
button.btn-blue   { background: #9090e0; border-color: #9090e0; }

/* AWT-style checkbox */
.awt-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  user-select: none;
}
.awt-check input[type="checkbox"] {
  margin: 0;
}

/* ---------- Loading ---------- */

.panel-loading {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #99ff99;
  color: #000;
}

.panel-loading h1 {
  font-family: "Times New Roman", "Liberation Serif", serif;
  font-size: 26px;
  font-weight: bold;
  margin: 0 0 16px 0;
}

.progress {
  width: 320px;
  height: 14px;
  background: #fff;
  border: 1px solid #000;
  border-top-color: #7a7a7a;
  border-left-color: #7a7a7a;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: #408040;
  transition: width 200ms linear;
}

/* ---------- Login ---------- */

.panel-login {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #99ff99;
  gap: 12px;
}

.panel-login h1 {
  font-family: "Times New Roman", "Liberation Serif", serif;
  font-size: 26px;
  font-weight: bold;
  margin: 0 0 8px 0;
  color: #000;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row label {
  width: 90px;
  text-align: right;
  color: #000;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
}

/* ---------- Lobby select ---------- */

.panel-lobbyselect {
  width: 100%;
  height: 100%;
  background: #99ff99 url("/picture/agolf/bg-lobbyselect.gif") no-repeat top left;
  position: relative;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  color: #000;
}

.panel-lobbyselect .lobby-titles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 130px;
  pointer-events: none;
}

.panel-lobbyselect .lobby-title {
  position: absolute;
  font-family: "Times New Roman", "Liberation Serif", serif;
  font-weight: bold;
  font-size: 26px;
  text-align: center;
  transform: translateX(-50%);
  top: 50px;
  white-space: nowrap;
}

.panel-lobbyselect .lobby-count {
  position: absolute;
  font-family: "Dialog", "Verdana", sans-serif;
  font-size: 12px;
  text-align: center;
  transform: translateX(-50%);
  top: 100px;
}

/* Three columns of buttons at the bottom of the bg image. Anchored in pixels
   to the bg image's 735px-wide thirds (0, 245, 490). #app has a 1px border
   with box-sizing: border-box, so a percent-based layout would resolve
   against 733px of content and slip the right two columns ~1px left of the
   image's divider lines. Pixel anchors match the image grid exactly. */
.panel-lobbyselect .col {
  position: absolute;
  bottom: 0;
  width: 245px;
  height: 165px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 14px;
}

.panel-lobbyselect .col.col-1 { left: 0; }
.panel-lobbyselect .col.col-2 { left: 245px; }
.panel-lobbyselect .col.col-3 { left: 490px; }

.panel-lobbyselect .col button {
  width: 150px;
  font-weight: bold;
}

.panel-lobbyselect .col .btn-quick {
  width: 100px;
  font-weight: normal;
}

.panel-lobbyselect .footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 12px;
}

.panel-lobbyselect .footer select {
  min-width: 180px;
}

/* ---------- Single-player lobby ---------- */

.panel-lobby {
  width: 100%;
  height: 100%;
  background: #99ff99 url("/picture/agolf/bg-lobby-single.gif") no-repeat top left;
  position: relative;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  color: #000;
}

.panel-lobby .nameplate {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Times New Roman", "Liberation Serif", serif;
  font-size: 16px;
  font-weight: bold;
  color: #000;
}

.panel-lobby .controls {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 0 18px;
}

.panel-lobby .control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.55);
  padding: 4px 8px;
  border: 1px solid #000;
}

/* ---------- Game ---------- */

.panel-game {
  width: 100%;
  height: 100%;
  background: #99ff99;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  color: #000;
}

/* Scoreboard above the canvas. Auto-sizes to its rows so 2-player rooms don't
   waste 40+px above the canvas; capped at 75px so a crowded room can't push the
   canvas off-screen. */
.panel-game .scoreboard {
  flex: 0 0 auto;
  max-height: 75px;
  width: 100%;
  padding: 2px 8px;
  font-size: 12px;
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  color: #000;
  overflow: hidden;
}

.panel-game .scoreboard .row {
  display: grid;
  /* tracks-col is `auto` (was `1fr`): the per-hole cells are now fixed-width,
     so the column hugs its content and the leftover width flows into the note
     column instead. Note column is `1fr` so long status badges
     ("(Voted to skip)", "(Connection problem…)") aren't clipped. */
  grid-template-columns: 16px 140px auto 64px 1fr;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  font-weight: bold;
}

/* Track-cell row: each per-hole stroke count gets a fixed-width slot so
   2-digit scores (10+) don't bump the next column out of alignment. */
.panel-game .scoreboard .tracks-cells {
  display: inline-flex;
  gap: 0;
}
.panel-game .scoreboard .track-cell {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.panel-game .scoreboard .row.you {
  color: #000080;
}
.panel-game .scoreboard .row.them {
  color: #406040;
}

.panel-game .canvas-frame {
  margin: 0 auto;
  /* Light-green tinted border around the playfield, mirroring the original. */
  padding: 3px;
  background: #c4f0c4;
  border: 1px solid #000;
}

.panel-game canvas {
  display: block;
  background: #99ff99;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* Bottom band - flex row that holds the chat strip (left, multiplayer only)
   and the trackinfo block. Trackinfo shrinks/expands depending on whether
   chat is visible. */
.panel-game .bottom-band {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 4px 8px;
  min-height: 0;
}

.panel-game .trackinfo {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 11px;
  color: #000;
  gap: 8px;
  min-width: 0;
}

.panel-game .trackinfo .left,
.panel-game .trackinfo .right {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.panel-game .trackinfo .right {
  text-align: right;
  align-items: flex-end;
}

.panel-game .trackinfo .center {
  text-align: center;
  font-weight: bold;
}

.panel-game .trackinfo .button-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 4px;
}

.panel-game .trackinfo .stats {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.panel-game .trackinfo .actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 2px;
  position: relative;
}

.panel-game .hud-status {
  font-size: 11px;
  color: #406040;
  font-style: italic;
  text-align: center;
}

/* ---------- Multiplayer bottom-band layout ----------
   Mirrors the original Playforia layout: chat on the left, then
   [Rata X/Y + name + author] | [stats] | [skip + menu] on the right.
   Stroke counter, "Click to shoot" hint, and Forfeit button are hidden -
   the original had no such elements, and the scoreboard already shows
   per-hole stroke counts. */
.panel-game.is-multi .chat-strip {
  flex: 1;
  min-width: 0;
}
.panel-game.is-multi .trackinfo {
  flex: 0 0 auto;
  grid-template-columns: auto auto auto;
}
.panel-game.is-multi .trackinfo .center {
  display: none;
}
.panel-game.is-multi .trackinfo .right {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.panel-game.is-multi .trackinfo .stats {
  text-align: left;
  align-items: flex-start;
}
.panel-game.is-multi .trackinfo .actions {
  flex: 0 0 auto;
  width: 130px;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  margin-top: 0;
}
.panel-game.is-multi .trackinfo .actions .skip-btn,
.panel-game.is-multi .trackinfo .actions .menu-btn {
  width: 100%;
  text-align: center;
  white-space: nowrap;
}
/* Stats column has a fixed width too, so the bottom band's columns don't
   reflow when text length changes (e.g. "Paras: 2 lyöntiä by Verylongname"). */
.panel-game.is-multi .trackinfo .stats {
  flex: 0 0 auto;
  width: 220px;
}
.panel-game.is-multi .trackinfo .left {
  flex: 0 0 auto;
  min-width: 80px;
}

/* Single-player default: hide chat strip (Java had no chat in 1-player). */
.panel-game .chat-strip {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #000;
  padding: 3px;
  min-height: 0;
}
.panel-game:not(.is-multi) .chat-strip {
  display: none;
}

/* ---------- Game-over overlay ---------- */

.game-end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: "Times New Roman", "Liberation Serif", serif;
  font-size: 22px;
  font-weight: bold;
  z-index: 20;
}

.game-end-overlay button {
  font-family: "Dialog", "Verdana", Tahoma, sans-serif;
  font-size: 12px;
  font-weight: normal;
}

/* ---------- Error banner ---------- */

.error-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #c04040;
  color: #fff;
  padding: 4px 10px;
  font-size: 12px;
  text-align: center;
  z-index: 100;
}

/* Non-fatal "we're trying to recover" banner - distinct from .error-banner so
   it can sit alongside other UI without screaming red and is removed cleanly
   on `reconnected`. */
.reconnect-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #c08040;
  color: #fff;
  padding: 4px 10px;
  font-size: 12px;
  text-align: center;
  z-index: 100;
}

/* ---------- Daily replay viewer ---------- */

.replay-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  gap: 6px;
  height: 100%;
  background: #99ff99;
}

.replay-header {
  text-align: center;
  font-family: "Times New Roman", Times, serif;
}

.replay-title {
  font-size: 16px;
  font-weight: bold;
}

.replay-meta {
  font-size: 12px;
  color: #333;
}

.replay-canvas {
  border: 1px solid #000;
  background: #000;
  image-rendering: pixelated;
}

.replay-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: "Verdana", sans-serif;
}

.replay-stroke {
  font-size: 12px;
  margin-left: 8px;
}

.replay-status {
  font-size: 11px;
  color: #444;
  text-align: center;
}

/* Valikko button - visual pressed state mirrors a sunken Win98 toolbar
 * toggle. `is-active` is added while the popover is open so the button
 * shows it's the source of the current menu. */
.panel-game .btn-yellow.is-active {
  background: #c8a020;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.4);
  transform: translateY(1px);
}

/* -----------------------------------------------------------------------
 * Win98/XP-style range input. Used by the in-game Valikko's volume slider.
 * The track is a thin sunken groove; the thumb is a tall narrow gray
 * rectangle with a 3D raised border and three horizontal grip lines on its
 * face. Cross-browser styling needs separate -webkit and -moz pseudo-element
 * blocks because each engine ships its own slider primitives.
 * --------------------------------------------------------------------- */
input[type="range"].win98-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 18px;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

input[type="range"].win98-slider:focus {
  outline: none;
}

/* WebKit / Blink */
input[type="range"].win98-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: #c0c0c0;
  /* Inset 3D groove: dark on top/left, light on bottom/right. */
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
  box-shadow: inset 1px 1px 0 #404040;
}

input[type="range"].win98-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 18px;
  margin-top: -8px; /* center thumb on the 4px track */
  background-color: #c0c0c0;
  /* Three horizontal grip lines (#808080) at y=6/8/10 within the 18px-tall
   * thumb, rendered with stacked linear-gradients so we don't need a sprite. */
  background-image:
    linear-gradient(#808080, #808080),
    linear-gradient(#808080, #808080),
    linear-gradient(#808080, #808080);
  background-size: 6px 1px, 6px 1px, 6px 1px;
  background-position: 2px 6px, 2px 9px, 2px 12px;
  background-repeat: no-repeat;
  /* Raised 3D bevel: white top/left, dark gray bottom/right. */
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #404040;
  border-bottom: 1px solid #404040;
  box-shadow: inset -1px -1px 0 #808080;
  border-radius: 0;
}

input[type="range"].win98-slider::-webkit-slider-thumb:active {
  background-color: #b0b0b0;
}

/* Firefox */
input[type="range"].win98-slider::-moz-range-track {
  height: 4px;
  background: #c0c0c0;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
  box-shadow: inset 1px 1px 0 #404040;
}

input[type="range"].win98-slider::-moz-range-thumb {
  width: 10px;
  height: 18px;
  background-color: #c0c0c0;
  background-image:
    linear-gradient(#808080, #808080),
    linear-gradient(#808080, #808080),
    linear-gradient(#808080, #808080);
  background-size: 6px 1px, 6px 1px, 6px 1px;
  background-position: 2px 6px, 2px 9px, 2px 12px;
  background-repeat: no-repeat;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #404040;
  border-bottom: 1px solid #404040;
  box-shadow: inset -1px -1px 0 #808080;
  border-radius: 0;
}

/* ---------- Mobile / touch support ---------- */

/* Rotate-phone prompt: hidden by default; only shown for coarse-pointer
   devices in portrait orientation. Lives in HTML so it appears before the
   TS bundle even runs. */
#rotate-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  /* Match the in-game playfield green so the prompt feels like part of the
     world rather than an OS-style modal. */
  background: #99ff99;
  color: #000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
  font-family: "Times New Roman", "Liberation Serif", serif;
}

#rotate-prompt .rotate-prompt__art {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The phone is a small AWT-bezel rectangle drawn entirely with CSS - a
   3D-bevel border, dark grey body, a screen window in pastel green with a
   white golf ball inside, and a home indicator pill. The whole assembly
   rotates from upright to landscape on a loop, mimicking the gesture the
   user needs to perform. */
#rotate-prompt .rotate-prompt__phone {
  position: relative;
  width: 60px;
  height: 100px;
  background: #c0c0c0;
  border: 2px solid #2a2d33;
  border-top-color: #ffffff;
  border-left-color: #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px #808080,
    0 4px 0 #2a2d33,
    0 4px 8px rgba(0, 0, 0, 0.25);
  animation: rotate-prompt-phone 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transform-origin: 50% 50%;
}

#rotate-prompt .rotate-prompt__notch {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  background: #2a2d33;
  border-radius: 2px;
}

#rotate-prompt .rotate-prompt__screen {
  position: absolute;
  inset: 12px 4px 12px 4px;
  background: #99ff99;
  border: 1px solid #2a2d33;
  border-top-color: #4a8040;
  border-left-color: #4a8040;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Golf ball - white circle with a faint shading dot in the corner so it
   reads as a ball rather than a flat disc. Rolls left↔right inside the
   "screen" so there's a hint of motion even mid-rotation. */
#rotate-prompt .rotate-prompt__ball {
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 35% 35%, #ffffff 0 60%, #c8e0c8 75%, #88a888 100%);
  border-radius: 50%;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  animation: rotate-prompt-ball 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

#rotate-prompt .rotate-prompt__home {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 3px;
  background: #2a2d33;
  border-radius: 2px;
}

#rotate-prompt .rotate-prompt__text {
  font-size: 22px;
  font-weight: bold;
  max-width: 320px;
  /* Subtle 1-px white drop so the text stays legible against the bright
     green background, matching the original Playforia title styling. */
  text-shadow: 0 1px 0 #ffffff;
}

/* Phone tilts from portrait to landscape and holds, then snaps back. */
@keyframes rotate-prompt-phone {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(-90deg); }
  75%  { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

/* Ball nudges sideways on the rotation peak - implies the ball is "ready
   to roll" once the phone is in the right orientation. */
@keyframes rotate-prompt-ball {
  0%   { transform: translateX(0); }
  35%  { transform: translateX(0); }
  55%  { transform: translateX(8px); }
  75%  { transform: translateX(0); }
  100% { transform: translateX(0); }
}

/* Magnifier loupe - a fixed-position circular canvas painted from the main
   game canvas every frame while a touch drag is active. Floats above the
   finger so the user sees what's hidden under their fingertip. */
.aim-loupe {
  display: none;
  position: fixed;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  background: #99ff99;
  pointer-events: none;
  z-index: 1500;
  /* Pixel art look - keep the zoomed-in pixels crisp instead of blurry. */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.aim-loupe.is-visible {
  display: block;
}

/* Mobile shoot-mode cycle button - desktop right-click parity. The button
   itself is created in TS and lives inside `.canvas-frame` so it scales with
   the canvas under the landscape `transform: scale()`. The default rule
   below hides it on every device; the touch-primary @media block re-enables
   it. Uses absolute positioning anchored to the canvas-frame's lower-right
   corner so it doesn't cover the playfield. */
.panel-game .canvas-frame {
  position: relative;
}
.panel-game .shoot-mode-btn {
  display: none;
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 24px;
  font-weight: bold;
  line-height: 1;
  font-family: "Verdana", Tahoma, sans-serif;
  background: rgba(255, 255, 255, 0.85);
  color: #000;
  border: 2px outset #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10;
  /* Each shootingMode picks a tint so the player can recognise the active
     mode at a glance without reading the glyph. */
  transition: background 0.15s ease;
}
.panel-game .shoot-mode-btn[data-mode="0"] { background: rgba(255, 255, 255, 0.85); }
.panel-game .shoot-mode-btn[data-mode="1"] { background: rgba(255, 220, 160, 0.95); }
.panel-game .shoot-mode-btn[data-mode="2"] { background: rgba(180, 220, 255, 0.95); }
.panel-game .shoot-mode-btn[data-mode="3"] { background: rgba(220, 180, 255, 0.95); }
.panel-game .shoot-mode-btn:active {
  border-style: inset;
}

/* Fullscreen gate - covers the play area on touch-primary devices in
   landscape until the user taps "Play fullscreen". Tapping triggers
   `requestFullscreen()` (which only works inside a user-gesture handler),
   and the body picks up `.is-fullscreen` from a fullscreenchange listener
   in main.ts so the gate hides for the rest of the session. The button
   uses the same green/pastel theme as the rotate prompt for visual
   continuity between the two preflight screens. */
#fullscreen-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #99ff99;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#fullscreen-prompt__button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 32px;
  background: #d9d9d9;
  border: 2px outset #d9d9d9;
  font-family: "Times New Roman", "Liberation Serif", serif;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a2d33;
  border-radius: 6px;
  /* Big tap target - comfortably hittable with a thumb. */
  min-width: 240px;
}

#fullscreen-prompt__button:active {
  border-style: inset;
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2a2d33;
}

.fullscreen-prompt__icon {
  font-size: 56px;
  line-height: 1;
}

.fullscreen-prompt__text {
  font-size: 22px;
  font-weight: bold;
  color: #000;
}

.fullscreen-prompt__sub {
  font-size: 13px;
  color: #404040;
  font-family: "Verdana", Tahoma, sans-serif;
}

/* Touch device adjustments. Gated on `body.is-touch-mode`, applied by
   `setupTouchMode()` in main.ts. We previously used
   `@media (hover: none) and (pointer: coarse)` here but that query proved
   unreliable on real phones - Chrome on Galaxy S23 reports `(hover: hover)`
   despite being a touch-only device, so the rotate prompt + fullscreen gate
   + mobile settings all stayed hidden. The JS detector combines client
   hints, the media query, and a touch-capability + viewport-size fallback,
   then writes the body class so all CSS rules below pick up the same
   verdict as the in-game `isTouchPrimary` flag. */
body.is-touch-mode .panel-game .shoot-mode-btn { display: block; }

/* Block default scroll/zoom gestures on the play canvas - touch input is
   consumed by drag-to-shoot. Buttons and chat scrolling outside the
   canvas remain unaffected. */
body.is-touch-mode .panel-game canvas {
  touch-action: none;
  cursor: default;
}

/* Portrait - show rotate prompt, hide everything else. */
@media (orientation: portrait) {
  body.is-touch-mode #app { display: none !important; }
  body.is-touch-mode #rotate-prompt { display: flex; }
}

/* Landscape - fit the fixed-size #app inside the viewport via a uniform
   transform, preserving the 735×525 internal layout. We can't use
   `width: 100vw` etc. because every child has hardcoded pixel sizes keyed
   to that 735×525 design; CSS-scaling the whole thing keeps the pixel art
   lined up exactly while filling the screen. The scale factor is computed
   in JS (see `setupMobileScale` in main.ts) and written to `--mobile-scale`
   because `scale()` requires a unitless number - `min(100vw/735, 100vh/525)`
   resolves to a length and fails to parse. */
@media (orientation: landscape) {
  body.is-touch-mode {
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.is-touch-mode #app {
    transform: scale(var(--mobile-scale, 1));
    transform-origin: center center;
    flex: 0 0 auto;
  }
  /* Show the fullscreen gate until `.is-fullscreen` is set by the
     fullscreenchange listener. The body class is the source of truth so
     the gate can re-appear if the user exits fullscreen (Esc / system
     back gesture) without us having to track state in JS. */
  body.is-touch-mode:not(.is-fullscreen) #fullscreen-prompt { display: flex; }
}
