body {
  font-family: sans-serif;
  background: #f2f2f2;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top-nav {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  gap: 4px;
  background: #333;
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 20px;
}

.nav-link {
  color: #ccc;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.95rem;
}

.nav-link:hover {
  background: #444;
  color: #fff;
}

.nav-link.active {
  background: #2c9aff;
  color: #fff;
}

/* the EN / NL button (i18n.js): at the right end of the top bar */
button.nav-link.lang-btn {
  flex: none;
  min-width: 0;
  min-height: 0;
  margin-left: auto;
  background: none;
  border: 1px solid #555;
  cursor: pointer;
  font-family: inherit;
}
button.nav-link.lang-btn:hover {
  background: #444;
}

/* --- Cam page: fullscreen webcam viewer (overrides the dashboard body's
   centered/padded layout, since this page is just the stream - no nav bar,
   an overlay button substitutes for it so the stream can use the full
   viewport) --- */

body.cam-body {
  padding: 0;
  /* 100vh sizes to the viewport as if the browser's address bar were
     never there, so on mobile Chrome (before the bar auto-hides on
     scroll) the page is taller than what's actually visible and the
     bottom - the webcam frame and map overlay - gets clipped. 100dvh
     tracks the REAL visible viewport as the address bar shows/hides.
     The plain 100vh above stays as a fallback for browsers that don't
     recognize dvh (an unsupported value is simply ignored, leaving the
     first declaration in effect). */
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  align-items: stretch;
}

.cam-fullscreen {
  position: relative;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* a long press (holding a button, the shield) is not "select this text":
     no selection, no Copy / Select all / Share menu */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.cam-fullscreen input,
.cam-fullscreen textarea,
.cam-fullscreen select {
  -webkit-user-select: auto;
  user-select: auto;
}
/* the game's touch buttons: no browser gestures (scroll, zoom) on them */
.game-touch-ui .cam-overlay-btn {
  touch-action: none;
}

.cam-overlay-btn {
  display: block;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-weight: bold;
  font-size: 0.95rem;
  text-align: left;
  /* Reset the app-wide `button { ... }` sizing (min 90x60px touch targets)
     for this small overlay control - only matters for the fullscreen
     button, which is a <button>; the "Main" link is an <a> and was never
     affected, but resetting both keeps them visually identical. */
  min-width: auto;
  min-height: auto;
  cursor: pointer;
}

.cam-overlay-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Menu panel: every clickable button on this page (Main, Fullscreen, Cam
   settings, and whatever gets added later) lives inside this one
   collapsible <details> in the top-left corner, rather than each getting
   its own permanently-visible overlay button scattered around the frame -
   keeps the live camera view uncluttered as more get added over time. */
.cam-menu-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
}

.cam-menu-panel > summary {
  display: inline-flex;
  align-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
}

.cam-menu-panel > summary:hover {
  background: rgba(0, 0, 0, 0.55);
}

.cam-menu-panel > summary::-webkit-details-marker {
  display: none;
}

.cam-menu-panel > summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.cam-menu-panel[open] > summary::before {
  transform: rotate(90deg);
}

.cam-menu-panel-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 6px;
}

/* The Menu panel in two columns: a phone held sideways isn't tall enough for
   all its buttons in one. The game/app choice and the gamepad line span
   both; still too tall, it scrolls rather than run off the screen. */
#camMenuPanel .cam-menu-panel-body {
  display: grid;
  grid-template-columns: repeat(2, auto);
  max-height: calc(100vh - 70px);
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
}

#camMenuPanel .cam-mode-label,
#camMenuPanel .cam-gamepad-status {
  grid-column: 1 / -1;
}

/* Second instance of the same collapsible-panel pattern, anchored to the
   opposite corner so it doesn't stack on top of the Menu panel -- e.g. the
   "Overlays" panel. */
.cam-menu-panel-right {
  left: auto;
  right: 10px;
}

/* Toggle switch: a standard checkbox visually restyled as a sliding switch
   (the checkbox itself stays in the DOM/tab order for accessibility, just
   visually hidden) -- used for on/off overlay settings instead of the
   plain checkboxes the Main page uses, to fit this page's touch-oriented,
   large-target overlay-button look. */
.cam-toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
}

.cam-toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cam-toggle-slider {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 11px;
  transition: background 0.15s ease;
}

.cam-toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.cam-toggle-switch input:checked + .cam-toggle-slider {
  background: #2c9aff;
}

.cam-toggle-switch input:checked + .cam-toggle-slider::before {
  transform: translateX(16px);
}

/* The Overlays panel's switches, compact: there are more of them than a phone
   held sideways has room for at full size (Free drive adds four). Still too
   tall, the panel scrolls. */
#camOverlaysPanel .cam-menu-panel-body {
  gap: 0;
  max-height: calc(100vh - 70px);
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
}

#camOverlaysPanel .cam-toggle-switch {
  padding: 3px 8px;
  gap: 6px;
  font-size: 0.85rem;
}

#camOverlaysPanel .cam-toggle-slider {
  width: 28px;
  height: 16px;
  border-radius: 8px;
}

#camOverlaysPanel .cam-toggle-slider::before {
  width: 12px;
  height: 12px;
}

#camOverlaysPanel .cam-toggle-switch input:checked + .cam-toggle-slider::before {
  transform: translateX(12px);
}

/* a slider in the Overlays panel (the floors' and walls' opacity) */
.cam-range {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-weight: bold;
  font-size: 0.85rem;
  padding: 3px 8px;
}

.cam-range input {
  width: 80px;
  accent-color: #2c9aff;
}

.cam-range span:last-child {
  min-width: 3em;
  text-align: right;
}

#camOverlaysPanel .cam-overlay-btn {
  margin-top: 4px;
}

.cam-toggle-switch input:focus-visible + .cam-toggle-slider {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Force-landscape: overlays a rotate prompt on touchscreens held in
   portrait (the camera view keeps rendering underneath, dimmed, rather
   than being hidden entirely) and disables the floating touch joysticks
   (see setupCamTouchControls()'s own check) -- a tall/narrow layout was
   never designed for driving via those joysticks, but there's no reason to
   hide the stream itself while the user rotates. Scoped to touch devices
   specifically (hover:none + pointer:coarse) so a desktop browser window
   that happens to be taller than it is wide never triggers this - only
   phones/tablets do. */
.cam-rotate-prompt {
  display: none;
}

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .cam-rotate-prompt {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    align-items: center;
    justify-content: center;
    text-align: center;
    font: 1.1rem sans-serif;
    padding: 40px;
    box-sizing: border-box;
  }
}

.cam-map-overlay {
  /* No background/border-radius/border here anymore -- the round map
     background and its border are now drawn on the canvas itself (see
     cam.js's initMapOverlay), specifically so an out-of-range waypoint's
     arrow can be positioned a few px past the drawn circle's edge without
     being discarded: a canvas can only ever render within its own pixel
     buffer bounds regardless of CSS, so the element is sized bigger than
     the visible circle to leave it room to do that. */
  position: absolute;
  bottom: 10px;
  left: 10px;
}

.cam-floor-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cam-fullscreen img {
  /* width/height 100% (not max-width/max-height) so a low-resolution
     stream - run deliberately low-res to minimize latency - is scaled UP
     to fill the viewport rather than displayed at its native pixel size;
     object-fit keeps the aspect ratio intact instead of stretching it. */
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cam-status {
  position: absolute;
  bottom: 10px;
  left: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Standalone action button (not tucked in a collapsible panel like Main/
   Fullscreen/Cam settings) -- it's the one thing on this page meant to be
   pressed often and immediately, so it stays permanently visible rather
   than costing an extra tap to reveal each time. */
.cam-fireball-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 10;
}

/* Floating touch joysticks (see setupCamTouchControls() in cam.js) --
   invisible until the user actually touches down, then appear centered on
   the touch point, same "floating stick" convention as mobile FPS games
   (PUBG Mobile, COD Mobile etc.) rather than a fixed on-screen control:
   comfortable to reach with a thumb from anywhere in its half of the
   screen, with no permanent visual clutter over the camera view.
   pointer-events:none -- the actual touch handling is on the fullscreen
   container itself (so a drag can range further than the visual base
   without losing the touch), these are purely visual feedback. */
.cam-floating-joystick-base {
  position: absolute;
  width: 140px;
  height: 140px;
  margin-left: -70px;
  margin-top: -70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 20;
}

/* Left (drive/strafe) stays neutral white; right (look) tinted teal to
   match the camera-control joystick's color on the Main page. */
.cam-floating-joystick-base-right {
  border-color: rgba(22, 160, 133, 0.6);
}

.cam-floating-joystick-knob {
  position: absolute;
  width: 64px;
  height: 64px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}

.cam-floating-joystick-base-right .cam-floating-joystick-knob {
  background: rgba(22, 160, 133, 0.75);
}

/* Only added by JS on detected touch devices (setupCamTouchControls() in
   cam.js) -- disables the browser's own scroll/pinch-zoom gestures within
   the camera view so a drag is captured as joystick input instead. */
.cam-touch-controls-active {
  touch-action: none;
}

.container {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

.panel-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  min-height: 60px;
}

/* Narrow viewports (phone in landscape, small windows): the 320px columns
   themselves are left alone (shrinking them would cramp panel contents),
   but the 40px body padding + inter-column gap is generous desktop
   spacing that alone is often the difference between 1 and 2 columns
   fitting. Two 320px columns + this tighter spacing fit down to about
   664px of viewport width, covering essentially all phones in landscape. */
@media (max-width: 900px) {
  body {
    padding: 8px;
  }

  .top-nav {
    margin-bottom: 8px;
    flex-wrap: wrap; /* (six links and the language button: on a phone, two rows) */
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .container {
    gap: 8px;
  }
}

.reboot-notice {
  box-sizing: border-box;
  background: #fff3cd;
  border: 1px solid #e0a800;
  color: #664d03;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 20px;
  cursor: pointer;
}

.reboot-notice:hover {
  background: #ffe8a1;
}

.reboot-notice-dismiss {
  font-size: 0.8rem;
  text-decoration: underline;
  white-space: nowrap;
}

.reboot-reason-display {
  font-size: 0.85rem;
  color: #444;
  margin-bottom: 8px;
}

.form-group {
  margin-top: 10px;
}

.form-group h4 {
  margin: 15px 0 8px 0;
}

.panel {
  border: 2px solid #333;
  border-radius: 6px;
  background-color: #f9f9f9;
}

.panel > summary {
  display: flex;
  align-items: center;
  font-weight: bold;
  font-size: 1.1em;
  cursor: pointer;
  padding: 10px;
  list-style: none;
}

.panel-drag-handle {
  width: 16px;
  height: 18px;
  margin-left: auto;
  padding-left: 12px;
  flex-shrink: 0;
  cursor: grab;
  position: relative;
}

.panel-drag-handle::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #888;
  box-shadow:
    0 6px 0 #888,
    0 12px 0 #888,
    8px 0 0 #888,
    8px 6px 0 #888,
    8px 12px 0 #888;
}

.panel.panel-dragging {
  opacity: 0.5;
}

body.panel-drag-active {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

body.panel-drag-active .panel-drag-handle {
  cursor: grabbing;
}

body.layout-locked .panel-drag-handle {
  cursor: not-allowed;
  opacity: 0.35;
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.panel[open] > summary::before {
  transform: rotate(90deg);
}

.panel-body {
  padding: 0 10px 10px 10px;
}

.panel-body h4 {
  margin: 10px 0 8px 0;
}

.checkbox-group label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
}

.checkbox-group label input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 3px;
}

.inline-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-group label {
  min-width: 90px;
}

.inline-group input {
  width: 90px;
}

input[type="number"] {
  width: 90px;
  padding: 4px;
}

select {
  width: 100%;
  box-sizing: border-box;
  padding: 5px;
  font-size: 1rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.slider-group input[type="range"] {
  width: 100%;
}

.joystick-container {
  width: 220px;
  height: 220px;
  background-color: #eee;
  /* Horizontal/vertical/diagonal guide lines through the center, as a
     driving aid (e.g. keeping the knob on the vertical line drives
     straight, on the horizontal line turns on the spot). Background-image
     rather than an SVG/canvas overlay so it's a single declarative layer
     that #joystickContainer2 doesn't need to redraw, just recolor. */
  background-image:
    linear-gradient(to right, transparent calc(50% - 1px), rgba(0, 0, 0, 0.18) calc(50% - 1px), rgba(0, 0, 0, 0.18) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0, 0, 0, 0.18) calc(50% - 1px), rgba(0, 0, 0, 0.18) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(45deg, transparent calc(50% - 1px), rgba(0, 0, 0, 0.14) calc(50% - 1px), rgba(0, 0, 0, 0.14) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(-45deg, transparent calc(50% - 1px), rgba(0, 0, 0, 0.14) calc(50% - 1px), rgba(0, 0, 0, 0.14) calc(50% + 1px), transparent calc(50% + 1px));
  border: 2px solid #aaa;
  border-radius: 50%;
  position: relative;
  margin: 20px auto;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.joystick-container.active {
  border-color: #2c9aff;
  box-shadow: 0 0 10px rgba(44, 154, 255, 0.8);
}

.joystick-knob {
  width: 60px;
  height: 60px;
  background: #444;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Control-frame joystick: tinted purple to match its purple reference arrow
   on the map, and to be visually distinct at a glance from the motor
   joystick above -- same size/shape, different behavior (field-oriented
   relative to a rotatable frame rather than direct per-wheel drive), so the
   two are easy to mix up otherwise. */
#joystickContainer2 {
  background-color: #f2e9f7;
  border-color: #9b59b6;
}

#joystickContainer2.active {
  border-color: #8e44ad;
  box-shadow: 0 0 10px rgba(142, 68, 173, 0.8);
}

#joystickKnob2 {
  background: #8e44ad;
}

/* Camera control joystick: X axis rotates the control frame (same
   proportional control the old horizontal drag strip had -- center is
   stopped, edges are the robot's full physical spin speed), Y axis sets the
   tilt angle directly and holds it on release. Teal-tinted, distinct from
   the motor joystick (default gray) and the control-frame joystick (purple)
   above, since it combines a rate control and a position control in one
   widget -- worth flagging visually as its own thing. */
.camera-control-joystick {
  background-color: #e0f5f2;
  border-color: #16a085;
}

.camera-control-joystick.active {
  border-color: #117a65;
  box-shadow: 0 0 10px rgba(17, 122, 101, 0.8);
}

#cameraControlKnob {
  background: #117a65;
}

.camera-control-caption {
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  margin: -10px auto 10px;
  max-width: 220px;
}

.lab1-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.lab2-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.lab1-buttons.active,
.lab2-buttons.active {
  border: 2px solid #2c9aff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 10px rgba(44, 154, 255, 0.4);
}

button {
  flex: 1;
  min-width: 90px;
  min-height: 60px;
  padding: 10px;
  font-size: 1rem;
}

.map-group {
  margin-top: 10px;
  text-align: center;
}

.map-group.active #map {
  border-color: #2c9aff;
  box-shadow: 0 0 10px rgba(44, 154, 255, 0.4);
}

#map {
  background: #fff;
  border: 2px solid #aaa;
  border-radius: 6px;
  cursor: pointer;
  box-sizing: border-box;
  max-width: 100%;
  height: auto;
}

#ws-status,
#ws-clients {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #666;
}

.link-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.diag-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  font-size: 0.85rem;
}

.diag-grid span:nth-child(odd) {
  color: #666;
}

.diag-grid .diag-warn {
  color: #c00;
  font-weight: bold;
}

/* No STAT line heard from the cam in a while -- values below are frozen,
   not live, so grey the whole block rather than let stale numbers look
   current. */
.diag-grid.diag-stale {
  opacity: 0.5;
}

#rttGraph {
  background: #fff;
  border: 2px solid #aaa;
  border-radius: 6px;
  display: block;
  margin-top: 8px;
}

.speedometer-group {
  margin-top: 10px;
  text-align: center;
}

#speedometerGauge {
  background: #fff;
  border: 2px solid #aaa;
  border-radius: 6px;
  display: block;
  margin: 0 auto;
}

#rtt-stats {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

#gotoWheelVelStats {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

#servoPulseUsDisplay {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

.sys-stats {
  margin-top: 6px;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sys-stats th, .sys-stats td {
  text-align: left;
  padding: 3px 8px 3px 0;
  border-bottom: 1px solid #ddd;
  white-space: normal;
  word-wrap: break-word;
}

.sys-stats th {
  color: #444;
}

.sys-stats td {
  color: #666;
}

.sys-stats caption {
  text-align: left;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 4px;
  caption-side: top;
}

.goto-graph-block {
  margin-top: 10px;
}

.goto-graph-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 4px;
}

.goto-graph-block canvas {
  background: #fff;
  border: 2px solid #aaa;
  border-radius: 6px;
  display: block;
}

.waypoints-table {
  margin-top: 6px;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.waypoints-table th, .waypoints-table td {
  text-align: left;
  padding: 4px 6px 4px 0;
  border-bottom: 1px solid #ddd;
}

.waypoints-table th {
  color: #444;
}

.waypoints-table td {
  color: #666;
}

.waypoints-table tbody tr {
  cursor: pointer;
}

.waypoints-table tbody tr.selected {
  background: #d6ebff;
}

.waypoints-table tbody tr.home-row td {
  font-style: italic;
}

.waypoints-table input[type="text"],
.waypoints-table input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  padding: 2px;
}

.waypoints-actions,
.waypoints-edit-actions {
  margin-top: 8px;
}

.waypoint-auto-advance-status {
  margin-top: -4px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #666;
  min-height: 1.1em;
}

/* --- Wi-Fi networks manager (wifi.js): Main page panel + /wifi setup page --- */

.wifi-page .wifi-card {
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.wifi-page .wifi-card h3 {
  margin: 12px 0 6px 0;
}

.wifi-mgr {
  font-size: 0.9rem;
}

.wifi-mgr [hidden] {
  display: none;
}

.wifi-status {
  margin-top: 4px;
}

.wifi-cam {
  color: #555;
}

.wifi-success {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #e3f5e3;
  border: 1px solid #7bbf7b;
}

.wifi-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wifi-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid #e2e2e2;
}

.wifi-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  flex: 1;
  min-width: 0;
}

.wifi-ssid {
  font-weight: bold;
  overflow-wrap: anywhere;
}

.wifi-tag {
  font-size: 0.8rem;
  color: #555;
  white-space: nowrap;
}

.wifi-tag-warn,
.wifi-tag-dim {
  white-space: normal;
}

.wifi-tag-ok {
  color: #1a7f1a;
  font-weight: bold;
}

.wifi-tag-warn {
  color: #b35900;
}

.wifi-tag-dim,
.wifi-dim {
  color: #888;
}

.wifi-pickable {
  cursor: pointer;
}

/* A saved network's access points, folded under its row in "Nearby networks". */
.wifi-list li:has(> .wifi-aps) {
  flex-wrap: wrap;
}

.wifi-aps {
  flex-basis: 100%;
  margin: 2px 0 0 14px;
  font-size: 0.9rem;
  cursor: default;
}

.wifi-aps summary {
  cursor: pointer;
  color: #555;
}

.wifi-aps li:last-child {
  border-bottom: none;
}

.wifi-bssid {
  font-family: monospace;
}

.wifi-pickable:hover {
  background: #eef3fb;
}

.wifi-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.wifi-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* The page-wide button style is sized for joystick-adjacent touch targets;
   list actions here need to sit inline. */
.wifi-btn {
  flex: none;
  min-width: 0;
  min-height: 0;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.wifi-btn-primary {
  padding: 8px 16px;
  font-size: 1rem;
}

.wifi-btn-danger {
  color: #a00;
}

.wifi-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.wifi-form input[type="text"],
.wifi-form input[type="password"] {
  padding: 8px;
  font-size: 1rem;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
}

.wifi-form .wifi-btn-primary {
  align-self: flex-start;
}

.wifi-show-pw {
  font-size: 0.85rem;
}

.wifi-msg {
  min-height: 1.2em;
  margin: 6px 0 0 0;
}

.wifi-error {
  color: #c00;
}

.wifi-country {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
  font-size: 0.85rem;
}

.wifi-country select {
  width: auto;
  padding: 3px;
}

/* --- First-person view: games/apps additions (cam.html, ar.js) --- */

.cam-mode-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
  font-size: 0.8rem;
  padding: 4px 6px 0 6px;
}

.cam-mode-select {
  font-size: 0.9rem;
  padding: 4px;
}

.game-canvas {
  z-index: 5;
}

.game-touch-ui {
  position: absolute;
  right: 10px;
  bottom: 60px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  /* too many for the height: a second column to the left, not up over the panels */
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  max-height: calc(100% - 140px);
  gap: 6px;
}

/* a small screen (a phone): the buttons as their icons, smaller */
@media (max-width: 760px), (max-height: 480px) {
  .game-touch-ui {
    right: 6px;
    bottom: 52px;
    gap: 4px;
    max-height: calc(100% - 110px);
  }
  .game-touch-ui .cam-overlay-btn {
    min-width: 40px;
    padding: 5px 6px;
    font-size: 1.05rem;
    line-height: 1.1;
  }
  .game-touch-ui .touch-lbl {
    display: none;
  }
}

.game-touch-ui:empty {
  display: none;
}

/* --- Games & apps page (games.html) --- */

.games-main {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.games-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.games-hero h2 {
  margin: 8px 0 4px 0;
}

.games-hero-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.games-player {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 2px;
}

.games-player input {
  padding: 6px;
  font-size: 1rem;
  width: 150px;
}

.games-play-btn {
  display: inline-block;
  padding: 10px 20px;
  background: #1a7f1a;
  color: #fff;
  font-weight: bold;
  border-radius: 6px;
  text-decoration: none;
}

.games-play-btn:hover {
  background: #146414;
}

.games-dim {
  color: #666;
}

.games-small {
  font-size: 0.8rem;
}

.games-section-title {
  margin: 14px 0 8px;
  font-size: 1.05rem;
}

.games-picks {
  margin-bottom: 6px;
}

.games-picks .games-card:not(.games-card-active) {
  border-color: #e0b84a;
  background: #fffaf0;
}

.games-tag.games-tag-pick {
  background: #f5d36b;
  color: #4a3500;
}

.games-card-date {
  font-size: 0.75rem;
  color: #777;
  margin-bottom: 2px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.games-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.games-card:hover {
  border-color: #888;
}

.games-card-editing {
  border-color: #3a6fd8;
}

.games-card-active {
  border-color: #1a7f1a;
  background: #f1fbf1;
}

.games-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.games-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.games-card-title {
  font-weight: bold;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.games-card-blurb {
  font-size: 0.85rem;
  color: #444;
}

.games-card-actions {
  margin-top: auto;
}

.games-tag {
  font-size: 0.7rem;
  font-weight: normal;
  padding: 1px 6px;
  border-radius: 8px;
  background: #e6e6e6;
  color: #444;
}

.games-tag-ai {
  background: #e2ecff;
  color: #2a4fa0;
}

/* The page-wide button style is sized for touch driving; these sit inline. */
.games-btn {
  flex: none;
  min-width: 0;
  min-height: 0;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.games-btn-on {
  background: #1a7f1a;
  color: #fff;
  border: 1px solid #146414;
}

.games-btn-quiet {
  font-size: 0.8rem;
  padding: 3px 8px;
}

.games-card-wide {
  width: 100%;
  box-sizing: border-box;
}

.games-settings-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.games-settings-head h3 {
  margin: 12px 0 0 0;
}

.games-saved {
  font-size: 0.85rem;
  color: #1a7f1a;
}

.games-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 16px;
  align-items: end;
}

.games-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.9rem;
}

.games-field input[type="number"],
.games-field select {
  width: 100%;
  box-sizing: border-box;
  padding: 5px;
}

.games-field-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.games-field-wide {
  grid-column: 1 / -1;
}

.games-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.games-chip {
  flex: none;
  min-width: 0;
  min-height: 0;
  padding: 3px 8px;
  font-size: 0.8rem;
  border-radius: 12px;
  border: 1px solid #bbb;
  background: #f4f4f4;
}

.games-chip-on {
  background: #d6f5d6;
  border-color: #1a7f1a;
}

.games-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 8px 0;
}

.games-file {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 3px;
}

.games-model-status {
  font-weight: bold;
  overflow-wrap: anywhere;
}

.games-model-url {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 3px;
  margin: 8px 0;
}

.games-model-url input {
  width: 100%;
  box-sizing: border-box;
}

.games-ok {
  color: #1a7f1a;
}

.games-warn {
  color: #b35900;
}

.games-boards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.games-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.games-score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.games-score-table td {
  padding: 2px 4px;
  border-bottom: 1px solid #eee;
}

.games-score {
  font-weight: bold;
  text-align: right;
}

.games-keys {
  border-collapse: collapse;
  font-size: 0.85rem;
}

.games-keys td {
  padding: 3px 10px 3px 0;
}

.games-keys td:nth-child(odd) {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: bold;
  white-space: nowrap;
}

.games-page progress {
  width: 100%;
}

/* Gamepad status line in the camera page's Menu panel. */
.cam-gamepad-status {
  max-width: 190px;
  color: #ddd;
  font-size: 0.75rem;
  line-height: 1.3;
}

/* Short-lived notice over the camera view (e.g. gamepad connected). */
.cam-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 6px 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.cam-toast.visible {
  opacity: 1;
}

/* A camera-page button waiting for its confirming second tap. */
.cam-overlay-btn.cam-btn-armed {
  background: #b3261e;
  color: #fff;
}

/* A game's introduction (intro.js): over everything on the camera page */
.intro-layer {
  position: absolute;
  inset: 0;
  z-index: 60;
  touch-action: none;
  transition: opacity 0.5s;
  font-family: system-ui, sans-serif;
}
.intro-layer.intro-gone {
  opacity: 0;
  pointer-events: none;
}
.intro-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 16%;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
  transition: opacity 0.3s;
  pointer-events: none;
}
.intro-icon {
  font-size: clamp(36px, 9vmin, 84px);
  line-height: 1.1;
}
.intro-name {
  font: normal clamp(30px, 8vmin, 72px) / 1.1 Impact, "Arial Black", sans-serif;
  letter-spacing: 0.04em;
}
.intro-kicker {
  margin-top: 4px;
  font-size: clamp(13px, 2.4vmin, 18px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #ffe9a8;
}
.intro-sub {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  width: min(92%, 860px);
  text-align: center;
  pointer-events: none;
}
.intro-sub span {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: clamp(15px, 2.9vmin, 24px);
  line-height: 1.35;
}
.intro-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.intro-bar div {
  height: 100%;
  width: 0;
  background: #ffcf5a;
}
.intro-ctrl {
  position: absolute;
  right: 12px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.intro-btn,
.intro-check {
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.intro-skip {
  background: rgba(255, 190, 60, 0.9);
  color: #1a1206;
  font-weight: 600;
}
.intro-check input {
  vertical-align: middle;
}
.intro-hint {
  position: absolute;
  left: 12px;
  bottom: 18px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  pointer-events: none;
}
.intro-fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 0.45s;
  pointer-events: none;
}
@media (max-width: 760px), (max-height: 480px) {
  .intro-hint {
    display: none;
  }
  .intro-sub {
    bottom: 64px;
  }
  .intro-ctrl {
    bottom: 10px;
    right: 8px;
  }
  .intro-btn,
  .intro-check {
    padding: 6px 10px;
    font-size: 13px;
  }
}
/* (the page's own buttons are hidden while an introduction plays) */
body.intro-playing .cam-menu-panel,
body.intro-playing .game-touch-ui,
body.intro-playing .cam-fireball-btn {
  visibility: hidden;
}
