.arrow {
  cursor:pointer;
}
.err {
  color:red;
}
.hide {
  display:none;
}

#extra {
  display:none;
}

#unitsDiv {
  display: none;
  overflow-y: auto;
  width: 100%;
  flex: 1;
  min-height: 0;
  container-type: inline-size;
  container-name: units-panel;
  padding-right: 10px;
}

body {
  background-image: url("/imgs/bg2.webp");
}

body.game-view {
  overflow: hidden;
}

#main-row {
  display: flex;
  height: 100vh;
  padding: 5px;
  gap: 10px;
  align-items: flex-start;
  overflow: hidden;
  box-sizing: border-box;
}

#units-column {
  position: relative;
  flex-grow: 10;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding-left: 10px;
}

.team {
  background-color: #afeff9; /* Light background */
  border: 2px solid #3498db; /* Blue border */
  border-radius: 15px; /* Rounded corners */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
  padding: 20px; /* Padding inside the div */
  display: flex;
  flex-direction:column;
  margin-bottom:10px;
}

.team h1 {
  font-size:25px;
  color:white;
}

.units {
  display: flex;
  flex-wrap: wrap;
}

.unit {
  background-color: #2d2b2b; /* Light background */
  border: 2px solid #0b0b0b;
  display: flex;
  flex-direction:column;
  color:white;
  position:relative;
  cursor: pointer;
}

.unit.sel {
  border: 2px solid yellow;
}

/* Enemy the selected unit could attack (in range) — click to target it. */
.unit.targetable {
  border: 2px solid #ffaa00;
  box-shadow: 0 0 8px rgba(255,170,0,0.7);
}
/* Enemy the selected unit is currently attacking. */
.unit.current-target {
  border: 2px solid #ff2222;
  box-shadow: 0 0 10px rgba(255,34,34,0.85);
}
.target-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  font-size: 16px;
  line-height: 1;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 0 3px #000;
}

.unit-delete-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 16px;
  font-size: 14px;
  background: rgba(180,0,0,0.75);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unit-delete-btn:hover {
  background: rgba(220,0,0,1);
}

.unit.unplaced {
  cursor: default;
  filter: grayscale(100%);
  opacity: 0.3;
  pointer-events: none;
}

.redOverlay {
  position:absolute;
  width:150px;
  height:130px;
  background-color:red;
  opacity:0.5;
}

.unit img {
  width:150px;
}

/* Marker overlay ("1" toggle): ArUco code pinned to the bottom-right corner of a unit's image. */
.unit-img {
  position:relative;
  line-height:0;   /* shrink-wrap the wrapper to the image so the overlay anchors to the image */
}
.unit-marker-code {
  position:absolute;
  bottom:3px;
  right:3px;
  width:40px;
  height:40px;
  background:#fff;
  border-radius:2px;
  padding:1px;
  box-sizing:border-box;
  z-index:10;
  pointer-events:none;
}
.unit-marker-code svg { width:100%; height:100%; display:block; }

.unit .stats {
  padding: 4px 6px;
}

.unit-dests {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px 4px;
  min-height: 22px;
}

.unit-dest-btn {
  width: 14px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-dest-btn svg {
  width: 14px;
  height: 20px;
  transition: transform 0.1s;
}

.unit-dest-btn:hover svg {
  transform: scale(1.2);
}

.unit-dest-btn-last {
  cursor: default;
  pointer-events: none;
}

.stat-bar-wrap {
  align-items: center;
  display: flex;
  gap: 5px;
  margin-bottom: 3px;
}

.stat-bar-label {
  color: #ccc;
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 10px;
  min-width: 16px;
  text-align: right;
}

.stat-bar-track {
  background: #333;
  border-radius: 3px;
  flex: 1;
  height: 14px;
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  border-radius: 3px;
  height: 100%;
  transition: width 0.2s, background 0.2s;
}

.stat-bar-text {
  color: white;
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 10px;
  left: 0;
  line-height: 14px;
  pointer-events: none;
  position: absolute;
  text-align: center;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  top: 0;
  width: 100%;
}

#videoSrc {
  -moz-transform: scale(-1, 1);
  -webkit-transform: scale(-1, 1); -o-transform: scale(-1, 1);
  transform: scale(-1, 1); filter: FlipH;
}

@font-face {font-family: "starjedi";
  src: url("/fonts/StarJedi-DGRW.woff") format("truetype")
}

.starwars {
  font-family:'starjedi';
  font-size:25px;
  color:white;
  text-align: center;
  display: block;
  margin-top:10px;
  margin-bottom:10px;
}

#gameId {
  color: rgba(180, 180, 180, 0.6);
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 11px;
  text-align: center;
  padding: 4px 0 2px;
  margin-top: auto;
}

#output {
  border: solid 1px black;
}

/* Horizontal display mirror, toggled from the menu (RenderInfo.mirrorHorz, default on). Flipping
   the composited element mirrors the camera feed and the rendered scene together. */
#output.mirror-h {
  transform: scale(-1, 1);
}

#hamburger-menu {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 1000;
}

#hamburger-btn {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 10px;
}

#hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

#hamburger-dropdown {
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  margin-top: 4px;
  min-width: 180px;
  overflow: hidden;
  position: absolute;
  right: 0;
}

#hamburger-dropdown.hidden {
  display: none;
}

.menu-item {
  color: white;
  cursor: pointer;
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 14px;
  padding: 10px 16px;
  user-select: none;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu-item.checked::before {
  content: '✓ ';
}

.menu-separator {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 4px 0;
}

.menu-item-danger {
  color: rgba(255, 100, 100, 0.9);
}

.menu-item-danger:hover {
  background: rgba(200, 50, 50, 0.2);
}

#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,10,0.92);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px;
  z-index: 8000;
}
#loading-overlay.hidden { display: none; }
#loading-text {
  font-family: 'Exo 2', sans-serif;
  color: rgba(0,200,255,0.85);
  font-size: 0.95rem;
  letter-spacing: 3px;
  text-transform: uppercase;
}

#quit-overlay,
#invalid-game-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

#quit-overlay.open { display: flex; }
#invalid-game-overlay.open { display: flex; }

#quit-modal {
  background: rgba(15, 10, 10, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  padding: 30px 36px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.6);
  text-align: center;
}

#quit-title {
  color: rgba(200, 240, 255, 0.95);
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 12px;
}

#quit-body {
  color: rgba(180, 180, 180, 0.85);
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

#quit-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.gbtn-danger {
  background: rgba(180, 40, 40, 0.75);
  border-color: rgba(220, 80, 80, 0.6);
}

.gbtn-danger:hover {
  background: rgba(210, 50, 50, 0.85);
}

.gmodal {
  position: absolute;
  top: 35px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 0 24px rgba(0, 200, 255, 0.18);
}

.gmodal-text {
  color: rgba(200, 240, 255, 0.95);
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(0, 180, 255, 0.7);
}

.hidden {
  display: none;
}

#msg-modal {
  flex-direction: column;
  gap: 12px;
}

#gameover-modal {
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.gameover-subtitle {
  font-size: 15px;
  opacity: 0.8;
}

.gameover-time {
  font-size: 13px;
  opacity: 0.6;
}

#game-warning-toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: rgba(0, 0, 0, 0.82);
  border: 2px solid rgba(255, 200, 0, 0.7);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  padding: 12px 28px;
  color: rgba(255, 220, 100, 0.95);
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 20px;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(255, 180, 0, 0.8);
  white-space: nowrap;
  pointer-events: none;
}

.gmodal-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(0, 180, 255, 0.2);
  border-top-color: rgba(0, 200, 255, 0.9);
  animation: gmodal-spin 0.8s linear infinite;
}

@keyframes gmodal-spin {
  to { transform: rotate(360deg); }
}

.gbtn {
  background: rgba(0, 100, 180, 0.5);
  border: 1px solid rgba(0, 200, 255, 0.3);
  border-radius: 7px;
  color: rgba(200, 240, 255, 0.9);
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  font-size: 16px;
  padding: 12px 20px;
  transition: background 0.15s, border-color 0.15s;
}

.gbtn:hover {
  background: rgba(0, 160, 220, 0.7);
  border-color: rgba(0, 200, 255, 0.65);
}

/* 50% scale: container too narrow for two 150px cards side by side */
@container units-panel (max-width: 359px) {
  .unit img       { width: 75px; }
  .redOverlay     { width: 75px; height: 65px; }
  .unit-marker-code { width: 24px; height: 24px; }
  .stat-bar-track { height: 11px; }
  .stat-bar-text  { font-size: 8px; line-height: 11px; }
  .stat-bar-label { font-size: 8px; min-width: 12px; }
}

/* 25% scale: container too narrow even for two 75px cards */
@container units-panel (max-width: 202px) {
  .unit img       { width: 37px; }
  .redOverlay     { width: 37px; height: 32px; }
  .unit-marker-code { width: 15px; height: 15px; bottom: 1px; right: 1px; padding: 0; }
  .stat-bar-track { height: 9px; }
  .stat-bar-text  { font-size: 7px; line-height: 9px; }
  .stat-bar-label { display: none; }
}