:root {
    --page: #83dfe9;
    --panel: rgba(255, 255, 255, 0.75);
    --panel-border: rgba(255, 255, 255, 0.8);

    --gold: #fff066;
    --gold-deep: #ffd556;

    --mint: #98fbcb;
    --mint-deep: #718a56;

    /* Dark text colours */
    --ink:er #1F4D4D;
    --ink-strong: #123333;
    --muted: #386666;

    --coral: #F6B3A6;
    --cream: #FFFFFF;

    --radius: 20px;
}

/* ---------- Global ---------- */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background-image: url(background-img.png);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;

    color: var(--ink-strong);
    font-family: "Quicksand", sans-serif;
    font-weight: 600;

    min-height: 100vh;
    padding: 32px 16px 64px;
}

.wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 45px;
}

/* ---------- Header ---------- */

header {
    text-align: center;
    margin-bottom: 28px;
}

.eyebrow {
    font-size: 12px;
    letter-spacing: 0.22em;
    color: var(--mint-deep);
    text-transform: uppercase;
    margin: 0 0 6px;
}

h1 {
    font-family: "Bungee", cursive;
    font-weight: 400;
    font-size: clamp(38px, 7.5vw, 64px);
    line-height: 1;
    margin: 0;

    color: #fff;
    text-shadow: 0 0 10px #8dff83, 0 0 20px #bcffac;
}

h1 span {
    color: #168A63;
    text-shadow: 3px 3px 0 rgba(183, 185, 219, 0.8);
}

.sub {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

.sub b {
    color: var(--ink-strong);
}

.toptitle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.toptitle img {
    display: block;
    width: 500px;
    max-width: 100%;
    height: auto;
}

/* ---------- Panels ---------- */

.panel {
    margin-bottom: 20px;
    padding: 22px;

    background: var(--panel);
    border: none;
    border-radius: 24px;
    box-shadow: 0 0 15px 5px var(--panel-border);
}

/* ---------- Camera Stage ---------- */

.stage {
    position: relative;

    max-width: 520px;
    margin: auto;
    aspect-ratio: 4 / 3;

    overflow: hidden;
    border: 4px solid #ffeb56;
    border-radius: var(--radius);
    background: #fffdcd;
}

.stage video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.stage .idle-msg {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;

    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

.idle-msg i {
    font-size: 34px;
    color: var(--gold-deep);
}

/* ---------- Flash ---------- */

.flash {
    position: absolute;
    inset: 0;

    background: var(--cream);
    opacity: 0;
    pointer-events: none;
}

.flash.on {
    opacity: 0.9;
    transition: opacity 60ms ease-out;
}

.flash.off {
    opacity: 0;
    transition: opacity 420ms ease-in;
}

/* ---------- Countdown ---------- */

.count-overlay {
    position: absolute;
    inset: 0;

    display: flex;
    justify-content: center;
    align-items: center;

    pointer-events: none;
}

.count-num {
    font-family: "Unkempt", cursive;
    font-weight: 700;
    font-style: normal;
    font-size: clamp(140px, 22vw, 240px);
    line-height: 1;

    color: var(--cream);
    -webkit-text-stroke: 2px var(--gold-deep);
    text-shadow: 4px 4px 0 rgba(107, 90, 46, 0.35);

    opacity: 0;
    transform: scale(0.6);
}

.count-num.show {
    animation: pop 0.68s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

@keyframes pop {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }

    20% {
        opacity: 1;
        transform: scale(1.1);
    }

    35% {
        transform: scale(1);
    }

    80% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.85);
    }
}

/* ---------- Recording Badge ---------- */

.rec-badge {
    position: absolute;
    top: 10px;
    left: 10px;

    display: none;
    align-items: center;
    gap: 6px;

    padding: 4px 9px;
    border-radius: 20px;

    background: var(--coral);
    color: #5C1F14;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.rec-badge.show {
    display: inline-flex;
}

.rec-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;

    background: #5C1F14;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.25;
    }
}

/* ---------- Progress Dots ---------- */

.dots {
    display: flex;
    justify-content: center;
    gap: 10px;

    margin: 16px 0 6px;
}

.dots span {
    width: 13px;
    height: 13px;

    border: 2px solid var(--gold-deep);
    border-radius: 50%;
    background: transparent;

    transition: background 200ms ease, transform 200ms ease;
}

.dots span.filled {
    background: var(--gold-deep);
    transform: scale(1.15);
}

/* ---------- Controls ---------- */

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;

    margin-top: 18px;
}

button {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    margin: 0;
    padding: 0;

    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;

    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;

    transition: transform 120ms ease;
}

button:hover {
    transform: translateY(-5px);
}

button:active {
    transform: scale(0.95);
}

button:focus {
    outline: none;
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

button img {
    display: block;
    width: 80px;
    height: auto;
    pointer-events: none;
}

button.primary,
button.ghost {
    background: transparent;
    border: none;
    box-shadow: none;
}

button.primary:hover,
button.ghost:hover {
    background: transparent;
}

/* ---------- Hint ---------- */

.hint {
    margin-top: 12px;
    text-align: center;

    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.hint b {
    color: var(--ink-strong);
}

/* ---------- Results ---------- */

.result-section {
    display: none;
}

.result-section.show {
    display: block;
}

.result-wrap {
    max-width: 900px;
    max-height: 60%;

    padding: 16px 8px 20px;

    justify-content: center;
}

#resultCanvas {
    max-width: 100%;
    border-radius: 20px;
    box-shadow: 0 10px 0 rgba(209, 252, 190, 0.8);
}

/* ---------- Toggle Switch ---------- */

.slider {
    position: absolute;
    inset: 0;

    cursor: pointer;

    background: var(--panel-border);
    border-radius: 20px;

    transition: background 150ms ease;
}

.slider::before {
    content: "";

    position: absolute;
    top: 3px;
    left: 3px;

    width: 18px;
    height: 18px;

    background: var(--cream);
    border-radius: 50%;

    transition: transform 150ms ease;
}

.switch input:checked + .slider {
    background: var(--mint-deep);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

/* ---------- Footer ---------- */

footer {
    margin-top: 26px;
    text-align: center;

    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}