/* ============================================================
   Vinlotteriet – toppskaret.no
   Felles stil (forside + påmelding)
   ============================================================ */

:root {
    --bg1: #150826;
    --bg2: #2e0e3f;
    --wine: #a4133c;
    --gold: #f6c453;
    --gold2: #ffdf8e;
    --cream: #fff3dd;
    --muted: #cbb8d9;
    --green: #3ddc84;
    --silver: #d7dae0;
    --bronze: #e0a473;
    --line: rgba(246, 196, 83, 0.3);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--cream);
    background:
        radial-gradient(1200px 800px at 50% -10%, #4a1657 0%, var(--bg1) 55%) fixed,
        var(--bg1);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

a { color: var(--gold2); }

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.4rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: clamp(1.2rem, 2.5vw, 1.9rem);
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand span { color: var(--gold); }

.head-right { display: flex; align-items: center; gap: 0.9rem; }

.icon-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--cream);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 1.1rem;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
}

footer {
    padding: 0.7rem 1.4rem;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ---------- Scenen ---------- */

#stage {
    position: relative;
    flex: 1;
    overflow: hidden;
    min-height: 62vh;
}

/* Vertikalt hjul: navnene ruller nedover gjennom et horisontalt bånd.
   Perspektiv (større i midten) settes per rad i draw.js. */

#reel-wrap {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    width: min(92vw, 720px);
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

#reel {
    position: relative;
    height: 100%;
    border-left: 2px solid rgba(246, 196, 83, 0.65);
    border-right: 2px solid rgba(246, 196, 83, 0.65);
    border-top: none;
    border-bottom: none;
    border-radius: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 60px rgba(246, 196, 83, 0.2), inset 0 0 40px rgba(0, 0, 0, 0.75);
    perspective: 850px;
    transform-style: preserve-3d;
}

#reel::before,
#reel::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 28%;
    z-index: 5;
    pointer-events: none;
}

#reel::before {
    top: 0;
    background: linear-gradient(rgba(10, 3, 22, 0.98) 15%, rgba(10, 3, 22, 0.75) 60%, transparent);
}

#reel::after {
    bottom: 0;
    background: linear-gradient(transparent, rgba(10, 3, 22, 0.75) 40%, rgba(10, 3, 22, 0.98) 85%);
}

#strip {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    transform-style: preserve-3d;
    will-change: transform;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 82px; /* MÅ matche CELL_H i draw.js */
    font-size: clamp(1.15rem, 2.7vw, 1.85rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    color: var(--cream);
    transform-origin: center center;
    backface-visibility: hidden;
    will-change: transform, opacity, filter;
}

.cell .nm {
    display: inline-block;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(.2, 1.25, .4, 1), filter 0.3s ease;
}

.cell.pending {
    opacity: 0 !important;
}

.cell.pending .nm {
    opacity: 0 !important;
    transform: scale(0.65);
    filter: blur(3px);
}

.cell.win .nm {
    background: linear-gradient(180deg, var(--gold), #d9a428);
    color: #3a2408;
    border-radius: 999px;
    padding: 0.12em 0.85em;
    box-shadow: 0 0 26px rgba(246, 196, 83, 0.55);
    animation: winPulse 0.7s ease-in-out 3;
}

.cell.dock-flash .nm {
    animation: dockGlow 0.65s cubic-bezier(.17, .89, .32, 1.25);
}

@keyframes dockGlow {
    0% { transform: scale(1.22); color: var(--gold); text-shadow: 0 0 20px rgba(246, 196, 83, 0.9); }
    100% { transform: scale(1); color: var(--cream); text-shadow: none; }
}

#pointer {
    position: absolute;
    left: -42px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    font-size: 1.7rem;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
    line-height: 1;
}

#pointer.bump { animation: bump 0.1s ease-in-out; }

#pointer-line {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: linear-gradient(90deg, transparent,
        rgba(246, 196, 83, 0.7) 15%, rgba(246, 196, 83, 0.7) 85%, transparent);
    z-index: 6;
    pointer-events: none;
}

/* Svevende navn */

.chip {
    position: absolute;
    left: 0;
    top: 0;
    padding: 0.45em 0.95em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--line);
    backdrop-filter: blur(3px);
    font-weight: 600;
    font-size: clamp(0.85rem, 1.4vw, 1.1rem);
    white-space: nowrap;
    z-index: 6;
    will-change: transform, opacity;
}

.chip .num { color: var(--gold); margin-right: 0.35em; font-size: 0.85em; }

.chip.flying-in {
    z-index: 10;
    background: rgba(246, 196, 83, 0.25);
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(246, 196, 83, 0.45);
}

.chip.docked {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* Vinnernavn som glir fra hjulet og ned til vinnerkortet */

.ghost {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 12;
    font-weight: 900;
    font-size: clamp(1.3rem, 3.5vw, 2.2rem);
    color: #fff;
    text-shadow: 0 4px 24px rgba(246, 196, 83, 0.6);
    pointer-events: none;
    white-space: nowrap;
    opacity: 1;
    transition: transform 1.05s cubic-bezier(.45, -0.05, .3, 1), opacity 1.05s ease;
}

/* Nedtelling */

#countdown {
    position: absolute;
    left: 50%;
    top: 44%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
    background: rgba(21, 8, 38, 0.85);
    padding: 1.8rem 2.6rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    backdrop-filter: blur(6px);
    max-width: 92vw;
}

.cd-title {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--gold);
    font-weight: 700;
    font-size: 0.95rem;
}

#cd-when {
    margin: 0.4rem 0 1.2rem;
    font-size: clamp(1.2rem, 3vw, 2rem);
}

.cd-boxes { display: flex; gap: 0.9rem; justify-content: center; }

.cd-box {
    min-width: 5.1rem;
    padding: 0.7rem 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.cd-box b {
    display: block;
    font-size: clamp(1.9rem, 5vw, 3.4rem);
    font-variant-numeric: tabular-nums;
    color: var(--gold2);
    line-height: 1.1;
}

.cd-box span {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cd-seal {
    margin-top: 1.1rem;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(246, 196, 83, 0.25);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
}

.cd-seal span {
    color: var(--muted);
}

#cd-sub { margin: 1rem 0 0; font-size: 0.95rem; }

/* Overlays */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 10;
    background: rgba(15, 5, 28, 0.74);
    backdrop-filter: blur(3px);
    padding: 1rem;
}

#win-overlay .place {
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: var(--gold);
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 700;
}

#win-overlay .congrats {
    font-size: clamp(1.4rem, 3.5vw, 2.4rem);
    margin-top: 0.3rem;
    animation: pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1);
}

#win-overlay .name {
    font-size: clamp(2.2rem, 7vw, 5rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 30px rgba(246, 196, 83, 0.55);
    animation: pop 0.65s cubic-bezier(0.2, 1.4, 0.4, 1);
    overflow-wrap: anywhere;
}

#win-overlay .prize {
    font-size: clamp(1.3rem, 3.5vw, 2.3rem);
    margin-top: 0.6rem;
    color: var(--gold2);
}

.final-title {
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    margin: 0 0 1.2rem;
    color: var(--gold);
}

#final-rows .row {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 3vw, 1.9rem);
    margin: 0.45rem 0;
}

#final-rows .medal { font-size: 1.35em; }
#final-rows .row b { color: var(--gold2); }
#final-rows .row .who { color: #fff; font-weight: 700; }

#final-next { margin: 1.4rem 0 0.8rem; }

/* Vinnerkort nederst til venstre (3. premie tegnes først) */

#winner-cards {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    z-index: 9;
    max-width: min(46vw, 480px);
}

.wcard {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(0, 0, 0, 0.55);
    border-left: 5px solid var(--bronze);
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    font-size: clamp(0.8rem, 1.5vw, 1.02rem);
    animation: cardIn 0.5s ease-out;
    white-space: nowrap;
    overflow: hidden;
}

.wcard.p2 { border-color: var(--silver); }
.wcard.p1 { border-color: var(--gold); }
.wcard b { color: var(--gold2); flex-shrink: 0; }
.wcard .wname { font-weight: 700; }

/* Meldinger */

.msg {
    position: absolute;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    z-index: 7;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.8rem 1.3rem;
    font-size: clamp(0.95rem, 2vw, 1.2rem);
    max-width: 90vw;
    text-align: center;
}

#confetti {
    position: absolute;
    inset: 0;
    z-index: 30;
    pointer-events: none;
}

/* Knapper */

.btn {
    background: linear-gradient(180deg, var(--gold), #d9a428);
    color: #3a2408;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }

.btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--cream);
    border: 1px solid var(--line);
    font-weight: 600;
}

/* ---------- Påmeldingssiden ---------- */

.page {
    max-width: 1040px;
    margin: 1.6rem auto 3rem;
    padding: 0 1.2rem;
    width: 100%;
}

.page h1 { text-align: center; font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 0.3rem; }

.card {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.6rem;
}

.signup-layout {
    display: flex;
    flex-direction: row;
    gap: 1.8rem;
    align-items: flex-start;
    width: 100%;
}

.signup-left {
    flex: 1 1 320px;
    max-width: 440px;
    position: sticky;
    top: 1rem;
}

.signup-right {
    flex: 1.1 1 320px;
    min-width: 250px;
    display: flex;
    flex-direction: column;
}

.weeklist-scroll {
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    margin-top: 0.4rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(246, 196, 83, 0.45) rgba(255, 255, 255, 0.05);
}

.weeklist-scroll::-webkit-scrollbar {
    width: 6px;
}
.weeklist-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
}
.weeklist-scroll::-webkit-scrollbar-thumb {
    background: rgba(246, 196, 83, 0.45);
    border-radius: 999px;
}

@media (max-width: 560px) {
    .signup-layout {
        flex-direction: column;
        gap: 1.4rem;
    }
    .signup-left {
        position: static;
        max-width: 100%;
    }
    .weeklist-scroll {
        max-height: 380px;
    }
}

.card label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; }

.card input[type="text"],
.card input[type="email"],
.card input[type="password"],
.card select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.07);
    color: var(--cream);
    font-size: 1rem;
}

.card input:focus, .card select:focus { outline: 2px solid var(--gold); }

.form-msg { margin: 0.8rem 0 0; min-height: 1.2rem; }
.form-msg.err { color: #ff9d9d; }
.form-msg.ok { color: var(--green); }

.weekrow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0.45rem 0;
    border: 1px solid transparent;
}

.weekrow .when b { display: block; font-size: 1.02rem; }
.weekrow .when span { font-size: 0.82rem; color: var(--muted); }

.weekrow.on { border-color: rgba(61, 220, 132, 0.5); background: rgba(61, 220, 132, 0.10); }

.toggle-btn {
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.08);
    color: var(--cream);
    padding: 0.45rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-btn.on { background: rgba(61, 220, 132, 0.2); border-color: var(--green); color: var(--green); }
.toggle-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.link-btn {
    background: none;
    border: none;
    color: var(--gold2);
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: underline;
    padding: 0;
}

/* ---------- Animasjoner ---------- */

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

@keyframes cardIn {
    from { transform: translateY(18px); opacity:  0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes winPulse {
    from { filter: brightness(1); }
    to { filter: brightness(1.25); }
}

@keyframes bump {
    50% { transform: translateY(-50%) scale(1.4); }
}

@media (max-width: 640px) {
    .cd-boxes { gap: 0.5rem; }
    .cd-box { min-width: 3.9rem; }
    #winner-cards { max-width: 92vw; }
    #pointer { left: -34px; }
}

/* ---------- Påmelding: ukevalg med pris ---------- */

.weeklist { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.4rem; }

.weekcheck {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem; /* smalere og mer kompakt */
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    margin: 0;
    transition: all 0.15s ease;
}

.weekcheck:hover:not(.locked):not(.holiday):not(.already-enrolled) {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(246, 196, 83, 0.4);
}

.weekcheck.on { border-color: rgba(61, 220, 132, 0.5); background: rgba(61, 220, 132, 0.12); }

.weekcheck input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: #3ddc84;
    flex-shrink: 0;
    cursor: pointer;
}

.weekcheck .when { flex: 1; min-width: 0; }
.weekcheck .when b {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.94rem;
    line-height: 1.25;
}
.weekcheck .when span {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.weekcheck .price { color: var(--gold2); font-weight: 700; font-size: 0.88rem; flex-shrink: 0; }

.weekcheck.locked { opacity: 0.45; cursor: not-allowed; }
.weekcheck.holiday { opacity: 0.6; cursor: not-allowed; background: rgba(123, 223, 242, 0.06); border-color: rgba(123, 223, 242, 0.2); }

.weekcheck.already-enrolled {
    opacity: 0.95;
    cursor: not-allowed;
    background: rgba(61, 220, 132, 0.09);
    border-color: rgba(61, 220, 132, 0.4);
}
.weekcheck.already-enrolled input {
    accent-color: #3ddc84;
    cursor: not-allowed;
}

.badge.enrolled {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #3ddc84;
    background: rgba(61, 220, 132, 0.18);
    border: 1px solid rgba(61, 220, 132, 0.45);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.badge.holiday {
    display: inline-block;
    font-size: 0.76rem;
    font-weight: 700;
    color: #7bdff2;
    background: rgba(123, 223, 242, 0.16);
    border: 1px solid rgba(123, 223, 242, 0.35);
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    margin-left: 0.45rem;
    vertical-align: middle;
}

.quick-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.5rem 0 0.8rem;
}

.btn-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--cream);
    padding: 0.35rem 0.85rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-chip:hover { background: rgba(246, 196, 83, 0.18); border-color: var(--gold); }
.btn-chip.ghost { opacity: 0.7; }

/* VIPPS-kort */
.vipps-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: rgba(255, 91, 36, 0.12);
    border: 1px solid rgba(255, 91, 36, 0.38);
    margin-top: 1rem;
}

.vipps-badge {
    background: #ff5b24;
    color: #fff;
    font-weight: 900;
    font-size: 0.92rem;
    letter-spacing: 0.8px;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    flex-shrink: 0;
}

.vipps-info {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    line-height: 1.4;
}

.vipps-num {
    color: #ff9b7a;
    font-size: 1.05rem;
    letter-spacing: 0.4px;
}

.vipps-sub {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.costline {
    margin-top: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(246, 196, 83, 0.08);
    font-size: 1.05rem;
    text-align: center;
}

.costline b { color: var(--gold2); }
.costline .pay-hint { font-size: 0.88rem; color: var(--cream); margin-left: 0.4rem; }

.payinfo {
    margin-top: 0.8rem;
    font-size: 0.92rem;
    color: var(--muted);
    text-align: center;
}

.paidpill {
    display: inline-block;
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.paidpill.on { background: rgba(61, 220, 132, 0.2); color: var(--green); }
.paidpill.off { background: rgba(255, 255, 255, 0.1); color: var(--muted); }

h3.sub { margin-top: 1.8rem; }

.okbox {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(61, 220, 132, 0.5);
    background: rgba(61, 220, 132, 0.1);
    line-height: 1.55;
}

