/* ==========================================================================
   BNI Prize Draw
   ========================================================================== */

:root {
    color-scheme: dark;

    --bg: #08080b;
    --panel: #111117;
    --panel-2: #16161d;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.15);
    --text: #f6f6f8;
    --muted: #a0a0ad;
    --muted-dim: #6f6f7d;
    --red: #da291c;
    --red-bright: #ff4434;
    --red-glow: rgba(218, 41, 28, 0.32);
    --green: #45d99a;
    --amber: #ffb020;
    --radius-lg: 22px;
    --radius-md: 14px;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --page-width: 1320px;
    --gutter: 24px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 45% at 78% 8%, rgba(218, 41, 28, 0.17), transparent 70%),
        radial-gradient(ellipse 45% 40% at 8% 0%, rgba(218, 41, 28, 0.09), transparent 72%),
        radial-gradient(ellipse 70% 60% at 50% 105%, rgba(90, 90, 120, 0.1), transparent 70%),
        var(--bg);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.22;
    background-image: linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 80% 65% at 50% 30%, #000 20%, transparent 80%);
}

h1,
h2,
h3,
p {
    margin: 0;
}

button,
textarea,
input {
    font: inherit;
    color: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

img,
svg,
canvas {
    display: block;
    max-width: 100%;
}

::selection {
    background: rgba(218, 41, 28, 0.4);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--red-bright);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--red);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 16px;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 26px var(--gutter) 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 15px;
    background: linear-gradient(145deg, #ff5546 0%, var(--red) 62%, #a81c12 100%);
    box-shadow: 0 12px 26px rgba(218, 41, 28, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.brand-copy {
    min-width: 0;
}

.brand-copy h1 {
    font-size: clamp(20px, 2.6vw, 27px);
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.brand-copy p {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.status-dot {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-dim);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.status[data-state="saved"] {
    color: #c9f3e2;
    border-color: rgba(69, 217, 154, 0.25);
    background: rgba(69, 217, 154, 0.08);
}

.status[data-state="saved"] .status-dot {
    background: var(--green);
    box-shadow: 0 0 10px rgba(69, 217, 154, 0.7);
}

.status[data-state="dirty"] {
    color: #ffe1ad;
    border-color: rgba(255, 176, 32, 0.28);
    background: rgba(255, 176, 32, 0.08);
}

.status[data-state="dirty"] .status-dot {
    background: var(--amber);
    box-shadow: 0 0 10px rgba(255, 176, 32, 0.65);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.layout {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(320px, 392px) minmax(0, 1fr);
    gap: 30px;
    width: 100%;
    max-width: var(--page-width);
    min-height: 0;
    margin: 0 auto;
    padding: 6px var(--gutter) 26px;
}

/* --------------------------------------------------------------------------
   Control panel
   -------------------------------------------------------------------------- */

.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 160px),
        var(--panel);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-head h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #d7d7de;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 24px;
    padding: 0 9px;
    border-radius: 8px;
    background: var(--red-glow);
    color: #ffb4ad;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.names-input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 140px;
    padding: 13px 15px;
    resize: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #0b0b10;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.7;
    box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.45);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.names-input::placeholder {
    color: #5d5d6a;
}

.names-input:hover {
    border-color: var(--line-strong);
}

.names-input:focus {
    outline: none;
    border-color: rgba(218, 41, 28, 0.75);
    box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(218, 41, 28, 0.16);
}

.names-input:read-only {
    opacity: 0.65;
    cursor: progress;
}

.field-note {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted-dim);
}

.field-note.is-warning {
    color: #ffb4ad;
}

.actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(180deg, #f63c2c, var(--red));
    color: #fff;
    box-shadow: 0 10px 24px rgba(218, 41, 28, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #ff5344, #e02d1f);
    box-shadow: 0 14px 30px rgba(218, 41, 28, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-ghost {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    border-color: rgba(218, 41, 28, 0.5);
    background: rgba(218, 41, 28, 0.16);
    color: #ffb4ad;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(218, 41, 28, 0.26);
    border-color: rgba(218, 41, 28, 0.75);
}

.btn.is-busy {
    opacity: 0.75;
    pointer-events: none;
}

.panel-divider {
    height: 1px;
    background: var(--line);
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.toggle-track {
    position: relative;
    flex: none;
    width: 36px;
    height: 20px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #24242d;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #8d8d9b;
    transition: transform 0.18s ease, background 0.18s ease;
}

.toggle input:checked + .toggle-track {
    border-color: transparent;
    background: var(--red);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(16px);
    background: #fff;
}

.toggle input:focus-visible + .toggle-track {
    outline: 2px solid var(--red-bright);
    outline-offset: 3px;
}

.toggle input:disabled + .toggle-track {
    opacity: 0.45;
}

.toggle:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 0;
    padding-top: 6px;
}

.wheel-shell {
    position: relative;
    width: 100%;
    max-width: min(680px, calc(100vh - 250px));
    max-width: min(680px, calc(100dvh - 300px));
    aspect-ratio: 1 / 1;
    margin-inline: auto;
    border-radius: 50%;
    box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6);
    touch-action: manipulation;
    user-select: none;
}

.wheel-shell::before {
    content: "";
    position: absolute;
    inset: -12%;
    z-index: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 52%, rgba(218, 41, 28, 0.22), transparent 64%);
    filter: blur(14px);
    pointer-events: none;
}

.wheel-shell.is-spinning::before {
    background: radial-gradient(circle at 50% 52%, rgba(218, 41, 28, 0.34), transparent 66%);
}

#wheel-canvas {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    cursor: pointer;
}

.wheel-shell.is-spinning #wheel-canvas {
    cursor: default;
}

.wheel-pointer {
    position: absolute;
    top: 50%;
    right: -6px;
    z-index: 4;
    width: clamp(28px, 5.6%, 44px);
    aspect-ratio: 52 / 38;
    transform: translateY(-50%);
    background: linear-gradient(270deg, #ff6152 0%, var(--red) 55%, #9d1a11 100%);
    clip-path: polygon(0 50%, 100% 0, 100% 100%);
    filter: drop-shadow(-5px 6px 12px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

.hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    display: grid;
    place-content: center;
    gap: 1px;
    width: 22.5%;
    aspect-ratio: 1 / 1;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: radial-gradient(circle at 36% 28%, #30303c 0%, #15151c 48%, #0a0a0f 100%);
    box-shadow:
        0 0 0 9px rgba(8, 8, 11, 0.55),
        0 0 0 10px rgba(255, 255, 255, 0.05),
        0 18px 42px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hub:hover:not(:disabled) {
    transform: translate(-50%, -50%) scale(1.045);
    box-shadow:
        0 0 0 9px rgba(8, 8, 11, 0.55),
        0 0 0 10px rgba(218, 41, 28, 0.35),
        0 20px 50px rgba(218, 41, 28, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hub:active:not(:disabled) {
    transform: translate(-50%, -50%) scale(0.985);
}

.hub:disabled {
    cursor: not-allowed;
    opacity: 0.82;
}

.hub-label {
    font-size: clamp(9px, 1.6vw, 17px);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-indent: 0.12em;
    line-height: 1.15;
    white-space: nowrap;
}

.hub-sub {
    color: var(--muted-dim);
    font-size: clamp(7px, 0.95vw, 10px);
    font-weight: 600;
    letter-spacing: 0.18em;
    text-indent: 0.18em;
    text-transform: uppercase;
}

.stage-hint {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: #d3d3db;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
}

.last-winner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 7px 14px;
    border: 1px solid rgba(69, 217, 154, 0.22);
    border-radius: 999px;
    background: rgba(69, 217, 154, 0.07);
    color: #b9e8d6;
    font-size: 12.5px;
}

.last-winner[hidden] {
    display: none;
}

.last-winner strong {
    overflow: hidden;
    max-width: 46ch;
    color: #fff;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px 24px;
    flex-wrap: wrap;
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 18px var(--gutter) 30px;
    border-top: 1px solid var(--line);
    color: var(--muted-dim);
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */

.dialog {
    display: none;
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    overflow: visible;
}

.dialog[open] {
    display: grid;
    place-items: center;
}

.dialog::backdrop {
    background: rgba(4, 4, 7, 0.74);
    backdrop-filter: blur(9px);
    animation: fade-in 0.22s ease both;
}

.dialog-card {
    position: relative;
    z-index: 2;
    width: min(92vw, 530px);
    padding: 40px 34px 30px;
    border: 1px solid var(--line-strong);
    border-radius: 26px;
    background: linear-gradient(180deg, #1b1b23 0%, #111117 55%, #0d0d12 100%);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    text-align: center;
    overflow: hidden;
    animation: pop-in 0.3s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.dialog-card::before {
    content: "";
    position: absolute;
    inset: -140px -20% auto;
    height: 280px;
    background: radial-gradient(ellipse at center, rgba(218, 41, 28, 0.4), transparent 68%);
    pointer-events: none;
}

.dialog-card--compact {
    width: min(92vw, 440px);
    padding: 32px 30px 26px;
}

.eyebrow {
    position: relative;
    color: #ff9a91;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    text-transform: uppercase;
}

.winner-name {
    position: relative;
    margin: 14px 0 0;
    font-size: clamp(30px, 6.6vw, 56px);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.04;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.remove-note {
    position: relative;
    margin-top: 14px;
    padding: 9px 12px;
    border: 1px solid rgba(255, 176, 32, 0.24);
    border-radius: 10px;
    background: rgba(255, 176, 32, 0.07);
    color: #ffe1ad;
    font-size: 12px;
    line-height: 1.45;
}

.remove-note[hidden] {
    display: none;
}

.dialog-actions {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

.dialog-actions .btn {
    min-width: 128px;
}

.confirm-title {
    position: relative;
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.confirm-body {
    position: relative;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.6;
}

.confetti {
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 90;
    max-width: min(92vw, 480px);
    padding: 12px 18px;
    transform: translate(-50%, 14px);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--red);
    border-radius: 12px;
    background: #17171f;
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.toast[data-type="error"] {
    border-left-color: #ff5c4d;
    background: #221316;
    color: #ffd9d5;
}

.toast[data-type="success"] {
    border-left-color: var(--green);
    background: #10201a;
    color: #d3f6e8;
}

.noscript {
    position: fixed;
    inset: auto 16px 16px;
    z-index: 100;
    padding: 14px 18px;
    border-radius: 12px;
    background: #221316;
    color: #ffd9d5;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes pop-in {
    from {
        transform: translateY(12px) scale(0.96);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Desktop: keep the whole app inside the visible viewport. The panel and its
   textarea absorb the leftover height instead of the page growing. */
@media (min-width: 1025px) {
    body {
        height: 100vh;
        height: 100dvh;
    }

    .panel {
        overflow-y: auto;
    }
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        align-content: start;
        gap: 26px;
        max-width: 760px;
    }

    .stage {
        order: -1;
        padding-top: 0;
    }

    .wheel-shell {
        max-width: min(560px, calc(100vh - 210px), 88vw);
        max-width: min(560px, calc(100dvh - 210px), 88vw);
    }
}

@media (max-width: 620px) {
    :root {
        --gutter: 16px;
    }

    .topbar {
        padding-top: 20px;
    }

    .brand-mark {
        width: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 15px;
    }

    .brand-copy p {
        display: none;
    }

    .status {
        padding: 7px 12px;
        font-size: 11.5px;
    }

    .panel {
        padding: 18px;
        border-radius: 18px;
    }

    .names-input {
        min-height: 150px;
    }

    .actions {
        grid-template-columns: 1fr 1fr;
    }

    .wheel-shell {
        max-width: min(96vw, calc(100vh - 190px));
        max-width: min(96vw, calc(100dvh - 190px));
    }

    .dialog-card {
        padding: 32px 22px 24px;
        border-radius: 22px;
    }

    .dialog-actions {
        flex-direction: column-reverse;
    }

    .dialog-actions .btn {
        width: 100%;
    }

    .site-footer {
        flex-direction: column;
    }
}

@media (max-width: 380px) {
    .status {
        display: none;
    }
}
