:root {
    --red: #b3132a;
    --red-dark: #5a0712;
    --green: #1f6f43;
    --gold: #f2c14e;
    --cream: #fffaf0;
    --ink: #1d1d1f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body {
    font-family: "Noto Sans Lao", "Noto Sans Thai", system-ui, sans-serif;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}
.th { font-family: "Noto Sans Thai", "Noto Sans Lao", system-ui, sans-serif; }

.app { position: fixed; inset: 0; }
.live { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.live.mirror { transform: scaleX(-1); }
.hidden-video { visibility: hidden; }

.corner-hotspot { position: absolute; left: 0; top: 0; width: 80px; height: 80px; z-index: 50; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; }
.overlay.panel {
    background: radial-gradient(ellipse at top, #a3121f 0%, var(--red-dark) 70%);
    padding: 4vh 4vw;
}
.overlay.panel::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background-image:
        radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
        radial-gradient(3px 3px at 70% 20%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 40% 80%, #fff 50%, transparent 51%),
        radial-gradient(3px 3px at 85% 65%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 10% 70%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 55% 50%, #fff 50%, transparent 51%);
    background-size: 300px 300px;
    animation: snow 12s linear infinite;
}
@keyframes snow { from { background-position: 0 0; } to { background-position: 0 300px; } }
.overlay.panel > * { position: relative; }
h1 { font-size: 5vh; margin: 0; font-weight: 800; text-align: center; }
h2 { font-size: 3.2vh; margin: 0; font-weight: 600; text-align: center; }

/* idle */
.overlay.idle { background: linear-gradient(180deg, rgba(90,7,18,.15), rgba(90,7,18,.75)); cursor: pointer; justify-content: flex-end; padding-bottom: 8vh; }
.idle-card { display: flex; flex-direction: column; align-items: center; gap: 1.6vh; }
.idle-title { font-family: "Great Vibes", cursive; font-size: 14vh; line-height: 1; text-shadow: 0 4px 20px rgba(0,0,0,.5); }
.idle-sub { font-size: 3.2vh; color: var(--gold); font-weight: 600; letter-spacing: .1em; }
.hint { font-size: 2.2vh; opacity: .8; }
.hint.dark { color: #555; opacity: 1; }

/* buttons */
.btn { border: 0; border-radius: 999px; padding: 1.4vh 3vw; font: inherit; font-weight: 700; font-size: 2.4vh; cursor: pointer; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #2a9a5d, var(--green)); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; border: 2px solid rgba(255,255,255,.35); }
.btn-lg { font-size: 3vh; padding: 2vh 4vw; width: 100%; }
.btn-xl { font-size: 3.6vh; padding: 2.4vh 5vw; animation: pulse 1.8s ease-in-out infinite; }
.btn.small { font-size: 1.8vh; padding: 1vh 2vw; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.row { display: flex; gap: 1.5vw; width: 100%; justify-content: center; }
.row .btn-lg { width: auto; flex: 1; max-width: 40vw; }

/* shooting */
.shot-badge { position: absolute; top: 3vh; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.5); padding: 1vh 2.4vw; border-radius: 999px; font-size: 3vh; font-weight: 700; }
.countdown { font-size: 34vh; font-weight: 800; text-shadow: 0 8px 40px rgba(0,0,0,.6); animation: pop 1s ease-out; }
.countdown.smile { font-size: 20vh; animation: none; }
@keyframes pop { 0% { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { opacity: .85; } }
.thumbs { position: absolute; bottom: 3vh; right: 3vw; display: flex; gap: 1vw; }
.thumbs img { height: 12vh; border: 4px solid #fff; border-radius: 8px; }
.flash { position: absolute; inset: 0; background: #fff; z-index: 40; animation: flash .25s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* review */
.review-grid { display: flex; gap: 2vw; justify-content: center; }
.review-grid img { height: 40vh; max-width: 28vw; object-fit: cover;border: 8px solid var(--cream); border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* result / payment */
.overlay.result { flex-direction: row; gap: 5vw; }
.strip-preview { height: 88vh; border-radius: 6px; box-shadow: 0 16px 50px rgba(0,0,0,.5); }
.result-side { display: flex; flex-direction: column; gap: 2vh; width: min(34vw, 520px); align-items: stretch; }
.qr-card { background: var(--cream); color: var(--ink); border-radius: 24px; padding: 3vh 2vw; display: flex; flex-direction: column; align-items: center; gap: 1.2vh; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.qr-title { font-weight: 800; font-size: 2.6vh; text-align: center; }
.qr { width: 30vh; height: 30vh; image-rendering: pixelated; }
.qr-placeholder { width: 30vh; height: 30vh; display: flex; flex-direction: column; gap: 2vh; align-items: center; justify-content: center; text-align: center; color: #666; font-size: 2vh; }
.qr-placeholder.error { color: var(--red); font-weight: 700; }
.laoqr-badge { background: #d0021b; color: #fff; font-weight: 800; letter-spacing: .1em; padding: .4vh 1.4vw; border-radius: 6px; font-size: 2vh; }
.amount { font-size: 4.4vh; font-weight: 800; color: var(--red); }
.ref { font-family: ui-monospace, Menlo, monospace; color: #777; font-size: 1.6vh; }
.msg { border-radius: 14px; padding: 1.4vh 1.4vw; font-size: 2.2vh; font-weight: 600; text-align: center; }
.msg.warn { background: #fff3cd; color: #7a5200; }
.msg.error { background: #ffe0e3; color: #a00018; }
.big-emoji { font-size: 16vh; }

.spinner { width: 6vh; height: 6vh; border: 6px solid rgba(255,255,255,.3); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
.qr-placeholder .spinner { border-color: #ddd; border-top-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: rgba(255,255,255,.95); color: #a00018; padding: 1vh 2vw; border-radius: 12px; font-family: "Noto Sans Thai", sans-serif; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; color: var(--ink); border-radius: 20px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5); user-select: text; -webkit-user-select: text; }
.modal .btn-ghost { color: var(--ink); border-color: #ccc; background: #f3f3f3; }
.modal-title { font-weight: 700; margin-bottom: 16px; text-align: center; }
.pin { width: 340px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pin-dots { display: flex; gap: 14px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #999; }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.err span { border-color: #d0021b; background: #d0021b; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 80px); gap: 10px; }
.pin-grid button { height: 64px; border-radius: 14px; border: 1px solid #ddd; background: #fafafa; font-size: 24px; cursor: pointer; }
.pin-grid button:disabled { visibility: hidden; }

.settings { width: min(960px, 94vw); height: 88vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.settings-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid #eee; }
.tabs { display: flex; gap: 6px; }
.tabs button { border: 0; background: #f0f0f0; padding: 8px 16px; border-radius: 999px; font: inherit; cursor: pointer; }
.tabs button.on { background: var(--green); color: #fff; }
.settings-body { overflow: auto; padding: 16px 24px 24px; flex: 1; }
.settings-body h3 { margin: 20px 0 8px; color: var(--red); }
.field { display: grid; grid-template-columns: 260px 1fr; gap: 4px 14px; align-items: center; padding: 6px 0; }
.field input[type=text], .field input[type=number], .field select { padding: 8px 10px; border: 1px solid #ccc; border-radius: 8px; font: inherit; width: 100%; }
.field input[type=checkbox] { width: 22px; height: 22px; justify-self: start; }
.field small { grid-column: 2; color: #888; }
.settings .row { justify-content: flex-start; margin-top: 20px; flex-wrap: wrap; }
.settings .btn { font-size: 15px; padding: 10px 20px; }
.stats { display: flex; gap: 12px; margin-bottom: 16px; }
.stats > div { flex: 1; background: #f6f6f6; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; }
.stats b { font-size: 28px; }
.stats span { color: #666; font-size: 14px; }
table.orders { width: 100%; border-collapse: collapse; font-size: 14px; }
table.orders th, table.orders td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; }
table.orders .mono { font-family: ui-monospace, Menlo, monospace; }
table.orders .ok { color: var(--green); font-weight: 700; }
table.orders .warn { color: #b07a00; font-weight: 700; }
table.orders .actions button { border: 1px solid #ccc; background: #fafafa; border-radius: 8px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.muted { color: #888; }
.toast { position: fixed; bottom: 4vh; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); padding: 12px 24px; border-radius: 999px; z-index: 200; font-family: "Noto Sans Thai", sans-serif; }
