html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.media-container {
    position: relative;
    width: min(100vw, calc(100vh * 9 / 16));
    height: min(100vh, calc(100vw * 16 / 9));
    width: min(100vw, calc(100dvh * 9 / 16));
    height: min(100dvh, calc(100vw * 16 / 9));
    background-color: #000;
    overflow: hidden;
    z-index: 1;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    cursor: default;
}

.slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease;
}

.slide.active {
    opacity: 1;
    visibility: visible;
}

.slide-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    user-select: none;
}

.zone-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
}

.hit-zone {
    position: absolute;
    padding: 0;
    margin: 0;
    border: 0 solid transparent;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    touch-action: none;
    transition: opacity 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hit-zone.editing {
    border: 1px solid #ff0000;
    background: rgba(255, 0, 0, 0.06);
}

.hit-zone.anywhere {
    z-index: 0;
    background: transparent;
    border: 0;
}

.hit-zone.dragging {
    background: rgba(255, 0, 0, 0.18);
    border-style: dashed;
}

.hit-zone.chosen {
    border-color: #ff7c00;
}

.hit-zone.chosen .option-art {
    transform: scale(1.012);
    filter:
        drop-shadow(0 0 3px #ff7c00)
        drop-shadow(0 0 10px rgba(255, 124, 0, 0.8))
        drop-shadow(0 0 24px rgba(255, 124, 0, 0.45))
        saturate(1.15)
        brightness(1.06);
    animation: optionPick 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes optionPick {
    0% { transform: scale(1); }
    38% { transform: scale(1.035); }
    100% { transform: scale(1.012); }
}

.hit-zone.blocked {
    background: rgba(255, 80, 80, 0.3);
    border-color: #ff5050;
}

.option-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
    filter:
        drop-shadow(0 0 3px rgba(255, 124, 0, 0))
        drop-shadow(0 0 10px rgba(255, 124, 0, 0))
        drop-shadow(0 0 24px rgba(255, 124, 0, 0))
        saturate(1)
        brightness(1);
    transform: scale(1);
    transition:
        filter 0.28s cubic-bezier(0.22, 0.61, 0.36, 1),
        transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.zone-layer.nudge {
    animation: nudgeShake 0.4s ease;
}

@keyframes nudgeShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
    .zone-layer.nudge { animation: none; }
    .hit-zone.blocked { background: rgba(255, 80, 80, 0.3); }
    .hit-zone.chosen .option-art { animation: none; }
    .option-art,
    .hit-zone { transition-duration: 0.01ms; }
    #calculatingOverlay .calc-phone,
    #calculatingOverlay .calc-screen::before,
    #calculatingOverlay .calc-bar { animation: none; }
}

.hit-zone:focus-visible {
    outline: 2px solid #ff7c00;
    outline-offset: -2px;
}

.qr-zone {
    position: absolute;
    padding: 0;
    margin: 0;
    border: 0 solid transparent;
    background: transparent;
    line-height: 0;
    pointer-events: none;
}

.qr-zone.editing {
    border: 1px solid #ff0000;
    background: rgba(255, 0, 0, 0.06);
    pointer-events: auto;
}

.qr-zone canvas,
.qr-zone img,
.qr-zone table {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-zone canvas {
    width: 100%;
    height: 100%;
}

.zone-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    z-index: 5;
    border: 2px solid #fff;
    background: #ff0000;
    border-radius: 2px;
    touch-action: none;
    cursor: pointer;
}

.zone-handle.h-nw { top: -9px; left: -9px; cursor: nwse-resize; }
.zone-handle.h-ne { top: -9px; right: -9px; cursor: nesw-resize; }
.zone-handle.h-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.zone-handle.h-se { bottom: -9px; right: -9px; cursor: nwse-resize; }

.zone-handle.resizing {
    background: #ffd24a;
    border-color: #ff0000;
}

.zone-label {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    padding: 1px 4px;
    background: var(--zone-label-bg, rgba(255, 0, 0, 0.85));
    color: var(--zone-label-fg, #fff);
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: var(--zone-label-size, 11px);
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    transform: translateY(-100%);
    text-shadow: none;
}

.collect-form {
    position: absolute;
    inset: 0;
    z-index: 12;
    touch-action: auto;
    --collect-text: #ffffff;
    --collect-align: center;
}

.collect-form .form-field {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: var(--collect-align);
    width: 100%;
    cursor: text;
}

.collect-form input[type="text"],
.collect-form input[type="email"] {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0 0.5vh;
    border: none;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: var(--collect-text);
    caret-color: var(--collect-text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2.1vh;
    font-weight: 500;
    line-height: 1.2;
    text-align: var(--collect-align);
    touch-action: auto;
    -webkit-user-select: text;
    user-select: text;
}

.collect-form input[type="text"]::placeholder,
.collect-form input[type="email"]::placeholder {
    color: transparent;
}

.collect-form .form-field.invalid,
.collect-form .form-agree.invalid {
    box-shadow: 0 0 0 0.3vh rgba(255, 77, 77, 0.85);
    border-radius: 0.6vh;
}

.collect-form .form-agree {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.collect-form .form-agree input[type="checkbox"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    touch-action: auto;
}

.collect-form .agree-check {
    width: 78%;
    height: 78%;
    fill: none;
    stroke: #ff7c00;
    stroke-width: 3.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.16s ease, transform 0.16s ease;
    pointer-events: none;
}

.collect-form .form-agree.checked .agree-check {
    opacity: 1;
    transform: scale(1);
}

.collect-form .collect-submit {
    box-sizing: border-box;
    padding: 0;
    border: none;
    background: transparent;
    color: transparent;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.collect-form .collect-error {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff4d4d;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.7vh;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 0.2vh 0.6vh rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.collect-form .collect-error.show {
    opacity: 1;
}

.collect-form .collect-submit.busy {
    opacity: 0.45;
}

.collect-form .collect-submit:disabled {
    cursor: wait;
}

.collect-form .collect-hp {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

#debugPanel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10000;
    max-width: min(96%, 460px);
    display: none;
    padding: 8px 10px;
    border: 1px solid #333;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 10px;
    line-height: 1.4;
    pointer-events: auto;
}

#debugPanel.visible {
    display: block;
}

#debugPanel .debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

#debugPanel .debug-title {
    font-weight: 700;
    color: #ffd24a;
}

.debug-actions {
    display: flex;
    gap: 4px;
}

.copy-btn {
    padding: 2px 10px;
    border: 1px solid #ffd24a;
    border-radius: 4px;
    background: #ffd24a;
    color: #000;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}

.copy-btn.alt {
    background: transparent;
    color: #ffd24a;
}

.copy-btn:hover {
    background: #fff;
    border-color: #fff;
    color: #000;
}

.copy-btn.ok {
    background: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

.debug-hint {
    margin-top: 4px;
    color: #9aa;
}

.copy-out {
    display: block;
    width: 100%;
    min-width: 260px;
    margin-top: 3px;
    padding: 4px;
    border: 1px solid #333;
    border-radius: 3px;
    background: #0b0b0b;
    color: #cfe8c8;
    font-family: inherit;
    font-size: 9px;
    line-height: 1.4;
    white-space: pre;
    resize: both;
}

#debugPanel table {
    border-collapse: collapse;
}

#debugPanel th,
#debugPanel td {
    padding: 1px 5px;
    border: 1px solid #333;
    text-align: right;
}

#debugPanel th {
    color: #9aa;
    font-weight: 600;
}

#loadingOverlay {
    position: absolute;
    inset: 0;
    z-index: 9999;
    background-color: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loadingOverlay.done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#loadingSpinner {
    width: 48px;
    height: 48px;
    border: 4px solid #2a2a3e;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#loadingText {
    margin-top: 16px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2vh;
    color: #ccc;
}

#kioskBtn {
    position: absolute;
    top: 0;
    left: 0;
    width: 10%;
    height: 10%;
    z-index: 999;
    cursor: pointer;
    background: transparent;
}

#musicBtn {
    position: absolute;
    top: 0;
    left: 10%;
    width: 10%;
    height: 10%;
    z-index: 1000;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

#musicBtn svg {
    width: 42%;
    height: 42%;
    fill: #ffffff;
    stroke: #ffffff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
    filter: drop-shadow(0 0 0.4vh rgba(0, 0, 0, 0.6));
}

#musicBtn .spk-body {
    stroke: none;
}

#musicBtn .spk-slash {
    display: none;
    stroke: #ff4d4d;
}

#musicBtn.muted .spk-wave {
    display: none;
}

#musicBtn.muted .spk-slash {
    display: block;
}

#calculatingOverlay {
    position: absolute;
    inset: 0;
    z-index: 9000;
    background-color: rgba(6, 6, 12, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#calculatingOverlay.on {
    opacity: 1;
    visibility: visible;
}

.calc-phone {
    position: relative;
    width: 18vh;
    height: 34vh;
    max-width: 30vw;
    border: 0.45vh solid #fff;
    border-radius: 4vh;
    background: #0d0d18;
    box-shadow: 0 0 0 0.6vh rgba(255, 124, 0, 0.25), 0 0 6vh rgba(255, 124, 0, 0.4);
    animation: calcSpin 2.6s cubic-bezier(0.45, 0, 0.45, 1) infinite;
}

.calc-phone::after {
    content: "";
    position: absolute;
    top: 1.6vh;
    left: 50%;
    transform: translateX(-50%);
    width: 30%;
    height: 0.65vh;
    border-radius: 999px;
    background: #333;
}

.calc-screen {
    position: absolute;
    inset: 3.4vh 1.2vh auto auto;
    left: 1.2vh;
    height: 26vh;
    border-radius: 1.6vh;
    background: radial-gradient(120% 120% at 30% 20%, #241a10, #0d0d18 70%);
    overflow: hidden;
}

.calc-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 124, 0, 0.35) 50%, transparent 58%);
    background-size: 300% 100%;
    animation: calcScan 2.6s ease-in-out infinite;
}

.calc-site {
    position: absolute;
    left: 1.2vh;
    right: 1.2vh;
    bottom: 1.2vh;
    height: 2vh;
    border-radius: 1vh;
    background: #1c1c2a;
}

.calc-bar {
    position: absolute;
    left: 2.4vh;
    right: 2.4vh;
    bottom: 0.9vh;
    height: 0.6vh;
    border-radius: 999px;
    background: #ff7c00;
    animation: calcBarGrow 2.6s ease-in-out infinite;
}

@keyframes calcSpin {
    0%, 55% { transform: rotateY(0deg); }
    65% { transform: rotateY(180deg); }
    75% { transform: rotateY(360deg); }
    100% { transform: rotateY(360deg); }
}

@keyframes calcScan {
    0%, 100% { background-position: 180% 0; }
    50% { background-position: -80% 0; }
}

@keyframes calcBarGrow {
    0%, 100% { transform: scaleX(0.15); }
    50% { transform: scaleX(1); }
}

#calculatingText {
    margin-top: 6vh;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2.6vh;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #fff;
}

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

@media (prefers-reduced-motion: reduce) {
    .slide {
        transition: none;
    }
}
