html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: #121212;
  color: #f0f0f0;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;           /* phone: excludes the browser's toolbars */
  overflow: hidden;
}

/* Two rows of buttons at the top; the joystick gets the rest */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));   /* equal, whatever is inside */
  grid-auto-rows: clamp(72px, 12vh, 120px);
  gap: 12px;
  padding: 16px 16px 8px;
  box-sizing: border-box;
}

/* Action buttons */
.icon-btn {
  position: relative;
  background: #1e1e1e;
  border: 1px solid #2c2c2c;
  border-radius: 16px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
  color: #f0f0f0;
  font: inherit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: #2a2a2a;
}

.icon-svg {
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
}

.icon-label {
  font-size: 14px;
  font-weight: 600;
}

/* Slot picker: shows the slot number; the native list covers the whole
   button so a tap opens the phone's picker */
.slot-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 28px;
  margin-bottom: 6px;
  color: #ff7a63;
}

.slot-btn select {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;          /* stops iOS zooming in on focus */
}

/* One line of feedback (connected, uploaded, errors) */
#statusLine {
  min-height: 18px;
  padding: 0 16px;
  font-size: 13px;
  color: #888;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Joystick fills the lower part of the screen */
.joy-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 16px 16px;
  box-sizing: border-box;
}

/* Walk joystick, same look as the pan-tilt tripod page
   (ptz_firmware/webpage.h): shaded grey pad, dotted red ball stick.
   Sizes are that page's 300px design as percentages. */
#joyArea {
  position: relative;
  width: min(88vw, 48vh, 420px);
  width: min(88vw, 48dvh, 420px);   /* browsers without dvh keep the line above */
  flex: 0 0 auto;
  aspect-ratio: 1;
  box-sizing: border-box;
  background: radial-gradient(circle at 38% 32%, #5a5a5a 0%, #3a3a3a 55%, #2a2a2a 100%);
  border: 1px solid #1a1a1a;
  border-radius: 50%;
  box-shadow:
    inset 0 6px 14px rgba(0, 0, 0, 0.55),
    inset 0 -2px 6px rgba(255, 255, 255, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stick {
  position: absolute;
  width: 30.67%;            /* 92 / 300 */
  height: 30.67%;
  left: 34.67%;             /* centred: (150 - 46) / 300 */
  top: 34.67%;
  box-sizing: border-box;
  border-radius: 50%;
  pointer-events: none;

  background-image:
    radial-gradient(circle, #0a0a0a 2.15px, transparent 2.35px),
    radial-gradient(circle, #0a0a0a 2.15px, transparent 2.35px),
    radial-gradient(circle at 34% 28%, #ff7a63 0%, #e5291b 45%, #a3140b 80%, #7a0f08 100%);
  background-size: 11px 11px, 11px 11px, 100% 100%;
  background-position: 0 0, 5.5px 5.5px, 0 0;

  border: 2px solid #5c0c06;
  box-shadow:
    0 5px 10px rgba(0, 0, 0, 0.6),
    inset 0 2px 3px rgba(255, 255, 255, 0.25),
    inset 0 -6px 10px rgba(0, 0, 0, 0.45);
  opacity: 0.97;
}

/* Bottom bar at bottom */
.bottom-bar {
  display: flex;
  justify-content: space-around;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: #1a1a1a;
  border-top: 1px solid #2c2c2c;
}

.footer-btn {
  background: none;
  border: none;
  color: #f0f0f0;
  font-size: 16px;
}

/* Status dot */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 6px;
}

.dot.gray { background: #888; }
.dot.green { background: #0f0; }

/* Full log: kept for desktop debugging, hidden on the phone layout */
#log {
  display: none;
}
