* { box-sizing: border-box; }

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    background: #061f2d;
    color: #f4a300;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
    overflow: hidden;
}

.remote {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* dvh avoids iOS address-bar height issue */
    padding: 6px 10px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    background: #061f2d;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* ── Title ── */
.title {
    flex-shrink: 0;
    height: 22px;
    color: #9ec8df;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Top button row ── */
.top-buttons {
    flex-shrink: 0;
    width: 100%;
    max-width: 420px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 2fr;
    gap: 5px;
}

.top-buttons button {
    height: 40px;
    border-radius: 9px;
    border: 2px solid #f4f4f4;
    background: transparent;
    color: #f4a300;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.top-buttons button:active {
    background: rgba(244, 163, 0, .22);
    transform: scale(.96);
}

/* ── Shoot toggle ── */
.shoot-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
}

.shoot-label {
    font-size: 11px;
    font-weight: 900;
    min-width: 22px;
    transition: color .25s;
}
.shoot-label.shoot-on  { color: #00aa33; }
.shoot-label.shoot-off { color: #cc2222; }

.shoot-toggle {
    width: 54px;
    height: 28px;
    border-radius: 14px;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    transition: background .25s;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.shoot-toggle.shoot-on  { background: #00aa33; }
.shoot-toggle.shoot-off { background: #cc2222; }

.toggle-knob {
    position: absolute;
    top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
    transition: left .25s;
}
.shoot-toggle.shoot-on  .toggle-knob { left: 30px; }
.shoot-toggle.shoot-off .toggle-knob { left: 4px; }

/* ── Settings rows (BRIGHT / OFFSET) ── */
.bright-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    max-width: 420px;
    height: 30px;
}

.bright-label {
    font-size: 10px;
    font-weight: 900;
    color: #9ec8df;
    min-width: 38px;
}

.bright-row button {
    height: 30px;
    min-width: 32px;
    border-radius: 7px;
    border: 2px solid #f4f4f4;
    background: transparent;
    color: #f4a300;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    padding: 0 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.bright-row button:active {
    background: rgba(244, 163, 0, .22);
    transform: scale(.96);
}

#bright-val {
    font-size: 13px;
    font-weight: 900;
    color: #f4a300;
    min-width: 26px;
    text-align: center;
}

/* ── Camera / panoramic preview ─────────────────────────────── */
/* Width = full available, height respects camera 1920×1200 (1.6:1)
   but caps at 36% of viewport so the d-pad always has room.      */
.preview-box {
    flex-shrink: 0;
    width: calc(100vw - 20px);
    height: min(
        calc((100vw - 20px) * 0.625),
        clamp(140px, calc(100dvh * 0.36), 280px)
    );
    background: #000;
    object-fit: cover;
    border: 2px solid #f4f4f4;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 170, 255, .25);
}

/* ── D-pad area ────────────────────────────────────────────── */
.controller-area {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
}

/* D-pad container scales with screen.
   clamp: min 180px → grows with viewport height → max 280px */
.dpad {
    --s: clamp(180px, calc(100dvh - 390px), 280px);
    width: var(--s);
    height: var(--s);
    position: relative;
}

/* All buttons use % positions so they auto-scale with .dpad */
.pad-btn {
    position: absolute;
    border: 2px solid #f4f4f4;
    background: transparent;
    color: #f4a300;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pad-btn:active,
.pad-btn[aria-pressed="true"] {
    background: rgba(244, 163, 0, .22);
    transform: scale(.97);
}

.pad-up    { left:34%; top:0;    width:32%; height:29%; border-radius:40% 40% 10px 10px; font-size: clamp(20px, 6vw, 36px); }
.pad-down  { left:34%; bottom:0; width:32%; height:29%; border-radius:10px 10px 40% 40%; font-size: clamp(20px, 6vw, 36px); }
.pad-left  { left:0;   top:34%;  width:29%; height:32%; border-radius:40% 10px 10px 40%; font-size: clamp(20px, 6vw, 38px); }
.pad-right { right:0;  top:34%;  width:29%; height:32%; border-radius:10px 40% 40% 10px; font-size: clamp(20px, 6vw, 38px); }

.shoot-center {
    position: absolute;
    left: 36%; top: 36%;
    width: 28%; height: 28%;
    border-radius: 50%;
    border: 3px solid #f4f4f4;
    background: transparent;
    color: #f4a300;
    font-size: clamp(20px, 6vw, 36px);
    font-weight: 1000;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(244, 163, 0, .25);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}
.shoot-center:active {
    background: rgba(244, 163, 0, .25);
    transform: scale(.95);
}

/* ── Panoramic map ─────────────────────────────────────────── */
.pano-view {
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    background: #000;
}
.pano-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.pano-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.pano-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ec8df;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    pointer-events: none;
}
.scan-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    height: 34px;
    padding: 0 14px;
    border-radius: 7px;
    border: 2px solid #f4f4f4;
    background: rgba(6, 31, 45, .85);
    color: #f4a300;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    letter-spacing: 1px;
    touch-action: manipulation;
}
.scan-btn:active { background: rgba(244, 163, 0, .22); transform: scale(.96); }

#map-btn.map-active { background: rgba(244, 163, 0, .25); border-color: #f4a300; }

/* ── Status bar ── */
.status {
    flex-shrink: 0;
    height: 14px;
    color: #9ec8df;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
