* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

#viewport {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

#amp-frame {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

#amp-face {
  width: 100%;
  height: auto;
  display: block;
}

#amp-frame canvas {
  position: absolute;
  pointer-events: none;
}

/* --- UI bar --- */
#ui-bar {
  position: fixed;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.72);
  color: #9fdcff;
  z-index: 9999;
  user-select: none;
}

#ui-bar button,
#ui-bar select {
  background: #111;
  color: #9fdcff;
  border: 1px solid #444;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

#ui-bar label { opacity: 0.9; }
#status { min-width: 44px; opacity: 0.9; }

/* --- Floating Settings Panel --- */
#popover {
  position: fixed;
  top: 60px;
  right: 12px;

  width: 850px;
  max-width: 92vw;    /* responsive but not crushing */
  min-width: 720px;   /* prevents slider collapse */

  max-height: calc(100vh - 80px);
  background: rgba(15,15,15,0.96);
  color: #d7f0ff;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.6);
  z-index: 10000;
  display: none;
  overflow-y: auto;

  resize: horizontal;
  pointer-events: auto;
}

#popover[aria-hidden="false"] { display: block; }

.popover-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #2a2a2a;
  background: rgba(0,0,0,0.35);
}

.drag-handle {
  cursor: move;
  font-weight: 650;
  opacity: 0.95;
  padding: 6px 8px;
  border-radius: 10px;
  user-select: none;
}

.drag-handle:hover {
  background: rgba(255,255,255,0.06);
}

.dock-btns {
  display: flex;
  gap: 6px;
}

.popover-head button {
  background: #111;
  color: #9fdcff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.popover-body {
  padding: 12px;
  overflow: auto;
}

/* --- grid/cards --- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (max-width: 1100px) {
  #popover { max-width: min(520px, 58vw); }
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  #popover {
    width: min(520px, 92vw);
    max-width: 92vw;
    left: 10px;
    right: auto;
  }
}

.card {
  border: 1px solid #2a2a2a;
  background: rgba(10,10,10,0.7);
  border-radius: 12px;
  padding: 12px;
}

.card-title {
  font-weight: 650;
  margin-bottom: 10px;
  opacity: 0.95;
}

.row {
  display: grid;
  grid-template-columns: 160px minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}

.row label { opacity: 0.9; }

.row input[type="color"] {
  width: 52px;
  height: 30px;
  border: 1px solid #444;
  background: transparent;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
}

.row input[type="range"] {
  width: 100%;
  cursor: pointer;
}

.row input[type="text"],
.row select {
  width: 100%;
  background: #111;
  color: #d7f0ff;
  border: 1px solid #444;
  padding: 6px 8px;
  border-radius: 8px;
}

.val {
  min-width: 70px;
  text-align: right;
  opacity: 0.85;
}

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

.btnrow button {
  background: #111;
  color: #9fdcff;
  border: 1px solid #444;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.hint {
  margin: 10px 0 0;
  font-size: 13px;
  opacity: 0.8;
  line-height: 1.35;
}

#power.is-on {
  box-shadow: 0 0 10px rgba(120, 220, 255, 0.55), 0 0 22px rgba(120, 220, 255, 0.25);
  border-color: rgba(120, 220, 255, 0.55);
}