/* Quiz Vote PWA — "casino night" theme.
   Deep felt green, cream & gold, art-deco display type (Yeseva One). */

:root {
    --felt: #0c1f16;
    --felt-deep: #071510;
    --cream: #f2e8d5;
    --cream-dim: #c9bda3;
    --gold: #d4a944;
    --gold-bright: #edc76a;
    --rouge: #c8373e;
    --noir: #171717;
    --vert: #1e8a4c;
    --line: rgba(212, 169, 68, 0.35);
    --font-display: "Yeseva One", "Georgia", serif;
    --font-body: "Mulish", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* display:flex on panels would otherwise defeat the hidden attribute */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    font-family: var(--font-body);
    color: var(--cream);
    background: radial-gradient(ellipse 120% 90% at 50% -10%, #14352384 0%, transparent 60%),
                radial-gradient(ellipse 140% 100% at 50% 110%, var(--felt-deep) 0%, transparent 55%),
                var(--felt);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Subtle felt grain, pure CSS so it works offline */
.felt-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-radial-gradient(circle at 30% 20%, transparent 0 3px, rgba(0,0,0,.05) 3px 4px),
        repeating-radial-gradient(circle at 70% 80%, transparent 0 4px, rgba(255,255,255,.015) 4px 5px);
}

/* ── Screens ─────────────────────────────────────────────── */

#app {
    flex: 1;
    display: grid;
    position: relative;
    z-index: 1;
    width: min(100%, 34rem);
    margin: 0 auto;
    padding: max(env(safe-area-inset-top), 1rem) 1.5rem calc(4.5rem + env(safe-area-inset-bottom));
}

.screen {
    grid-area: 1 / 1;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
    animation: screen-in 380ms cubic-bezier(.22,.9,.35,1) both;
}

.screen[data-active="true"] { display: flex; }

@keyframes screen-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* ── Typography ──────────────────────────────────────────── */

.marquee { display: flex; flex-direction: column; align-items: center; gap: .9rem; }

.marquee h1 {
    font-family: var(--font-display);
    font-size: clamp(3.4rem, 17vw, 5.2rem);
    line-height: .95;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gold-bright);
    text-shadow: 0 1px 0 #7c5c1a, 0 3px 12px rgba(0,0,0,.55);
}

.marquee-line {
    width: 9rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    position: relative;
}

.marquee-line::after {
    content: "◆";
    position: absolute;
    left: 50%; top: 50%;
    translate: -50% -50%;
    font-size: .55rem;
    color: var(--gold);
}

.tagline {
    font-style: italic;
    color: var(--cream-dim);
    letter-spacing: .02em;
}

.screen-title, .roulette-title {
    font-family: var(--font-display);
    font-size: 1.9rem;
    color: var(--cream);
    letter-spacing: .02em;
}

.kicker {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .32em;
    color: var(--gold);
}

.question-text {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 6.5vw, 2.3rem);
    line-height: 1.25;
    max-width: 26rem;
    overflow-wrap: break-word;
}

.muted { color: var(--cream-dim); font-size: .9rem; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .9rem 1.9rem;
    color: var(--cream);
    background: rgba(255,255,255,.04);
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-gold {
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, #a87f2b);
    border-color: #8a6a24;
    color: #241a05;
    box-shadow: 0 4px 0 #6d5420, 0 10px 24px rgba(0,0,0,.45);
}

.btn-gold:active { box-shadow: 0 1px 0 #6d5420; translate: 0 3px; }

.btn-big { font-size: 1.1rem; padding: 1.1rem 2.6rem; }

.vote-row, .bet-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.btn-pour { background: linear-gradient(180deg, #27a05c, var(--vert)); border-color: #0f5a30; }
.btn-contre { background: linear-gradient(180deg, #d9494f, var(--rouge)); border-color: #7c2025; }

.btn-pour, .btn-contre {
    flex: 1 1 9rem;
    max-width: 12rem;
    box-shadow: 0 4px 0 rgba(0,0,0,.4), 0 10px 24px rgba(0,0,0,.4);
}

.count {
    display: inline-block;
    min-width: 1.7em;
    margin-left: .35em;
    padding: .1em .4em;
    border-radius: 999px;
    background: rgba(0,0,0,.28);
    font-variant-numeric: tabular-nums;
}

/* Casino chips for roulette bets */
.chip {
    flex: 0 1 auto;
    border-width: 4px;
    border-style: dashed;
    box-shadow: 0 5px 0 rgba(0,0,0,.45), 0 12px 22px rgba(0,0,0,.4);
}

.chip-rouge { background: var(--rouge); border-color: #f4b9bc; }
.chip-noir  { background: var(--noir);  border-color: #9a9a9a; }
.chip-vert  { background: var(--vert);  border-color: #b6e6c9; }

/* ── Home actions / join by code ─────────────────────────── */

.home-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: min(100%, 20rem);
}

.home-actions .btn-big { width: 100%; }

.btn-plain { font-size: .85rem; padding: .7rem 1.4rem; }

.join-row {
    display: flex;
    gap: .6rem;
    width: 100%;
}

.join-row input {
    flex: 1;
    min-width: 0;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: .35em;
    text-align: center;
    text-transform: uppercase;
    color: var(--gold-bright);
    background: rgba(0,0,0,.3);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .8rem 1rem;
    outline: none;
}

.join-row input:focus { border-color: var(--gold); }
.join-row input::placeholder { color: rgba(242,232,213,.25); letter-spacing: .35em; }

/* ── Share code display ──────────────────────────────────── */

.share-code {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 14vw, 4rem);
    letter-spacing: .18em;
    color: var(--gold-bright);
    border: 2px dashed var(--gold);
    border-radius: .8rem;
    padding: .6rem 1.4rem .6rem 1.6rem;
    background: rgba(0,0,0,.28);
    text-shadow: 0 2px 10px rgba(0,0,0,.5);
    user-select: all;
}

/* ── History tags ────────────────────────────────────────── */

.h-tag {
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--cream-dim);
    border: 1px solid var(--line);
    border-radius: .3rem;
    padding: .15rem .4rem;
    white-space: nowrap;
}

.h-tag-online { color: var(--gold-bright); border-color: var(--gold); }

/* ── Online poll screen ──────────────────────────────────── */

#poll-status { width: min(100%, 22rem); }
#poll-status .progress-track { width: 100%; }

/* ── Setup form ──────────────────────────────────────────── */

#setup-form {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    width: 100%;
    max-width: 22rem;
}

.field { display: flex; flex-direction: column; gap: .45rem; text-align: left; }

.field span {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .22em;
    color: var(--gold);
}

.field input {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--cream);
    background: rgba(0,0,0,.3);
    border: 1px solid var(--line);
    border-radius: .6rem;
    padding: .85rem 1rem;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,169,68,.18);
}

.field input::placeholder { color: rgba(242,232,213,.3); font-style: italic; }

/* ── Question progress ───────────────────────────────────── */

#vote-panel, #result-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
}

.progress-track {
    width: min(100%, 22rem);
    height: .55rem;
    border-radius: 999px;
    background: rgba(0,0,0,.35);
    border: 1px solid var(--line);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--gold), var(--gold-bright));
    transition: width 300ms ease;
}

.finished-stamp {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--gold-bright);
    rotate: -2deg;
    border: 2px solid var(--gold);
    border-radius: .4rem;
    padding: .4rem 1.1rem;
    animation: stamp 420ms cubic-bezier(.2,1.6,.4,1) both;
}

@keyframes stamp {
    from { opacity: 0; scale: 1.6; }
    to   { opacity: 1; scale: 1; }
}

.server-results {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: .8rem;
    background: rgba(0,0,0,.25);
    padding: 1.2rem 2rem;
    min-width: 16rem;
}

.server-votes { display: flex; gap: 1.6rem; }

.server-votes .stat { display: flex; flex-direction: column; gap: .15rem; }

.server-votes .stat b {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 400;
}

.server-votes .stat span {
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--cream-dim);
}

.stat-pour b { color: #4ecb82; }
.stat-contre b { color: #ef7d82; }
.stat-total b { color: var(--gold-bright); }

/* ── Roulette wheel ──────────────────────────────────────── */

.wheel-stage {
    position: relative;
    width: min(56vw, 13.5rem);
    aspect-ratio: 1;
}

.wheel {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 6px solid #8a6a24;
    box-shadow: inset 0 0 0 4px #3b2d0e, 0 14px 34px rgba(0,0,0,.55);
    overflow: hidden;
    /* JS sets --spin-turns then adds .spinning */
    transform: rotate(0turn);
}

.wheel.spinning {
    transition: transform 2s cubic-bezier(.15,.75,.25,1);
    transform: rotate(var(--spin-turns));
}

.wheel .slice {
    position: absolute;
    left: 50%; top: 0;
    width: 12%;
    height: 50%;
    transform-origin: 50% 100%;
    translate: -50%;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.slice-num {
    position: absolute;
    left: 50%;
    top: 7%;
    translate: -50%;
    font-size: .52rem;
    font-weight: 800;
    color: var(--cream);
    /* Slices are wedge-clipped; the label sits inside the outer band */
}

.wheel-hub {
    position: absolute;
    left: 50%; top: 50%;
    translate: -50% -50%;
    width: 34%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--gold-bright), #a87f2b 70%);
    border: 3px solid #3b2d0e;
    display: grid;
    place-items: center;
    color: #241a05;
    font-size: 1.3rem;
    box-shadow: 0 4px 10px rgba(0,0,0,.5);
}

.wheel-pin {
    position: absolute;
    left: 50%; top: -4px;
    translate: -50%;
    width: 0; height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 16px solid var(--cream);
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.5));
}

#roulette-betting, #roulette-spinning, #roulette-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.grid-kicker { letter-spacing: .22em; }

#number-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: .3rem;
    width: min(100%, 24rem);
}

.num-cell {
    font-family: var(--font-body);
    font-size: .82rem;
    font-weight: 800;
    color: var(--cream);
    aspect-ratio: 1;
    border-radius: .35rem;
    border: 1px solid rgba(255,255,255,.18);
    cursor: pointer;
    transition: transform 100ms ease, filter 100ms ease;
    -webkit-tap-highlight-color: transparent;
}

.num-cell:active { transform: scale(.9); }
.num-cell:hover { filter: brightness(1.25); }

/* 0 spans the first row start, like the green pocket it is */
.num-cell:first-child { grid-column: span 2; aspect-ratio: auto; }

.num-rouge { background: var(--rouge); }
.num-noir  { background: var(--noir); }
.num-vert  { background: var(--vert); }

#spin-result { text-transform: uppercase; }

.bet-outcome { font-size: 1.05rem; font-weight: 800; }
.bet-outcome.win  { color: #4ecb82; }
.bet-outcome.lose { color: #ef7d82; }

/* ── Historique ──────────────────────────────────────────── */

.history-list {
    list-style: none;
    width: 100%;
    max-width: 24rem;
    display: flex;
    flex-direction: column;
    gap: .7rem;
}

.history-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: .7rem;
    background: rgba(0,0,0,.25);
    padding: .8rem 1rem;
}

.history-list .h-question { font-weight: 600; overflow-wrap: anywhere; }

.history-list .h-score {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 800;
    color: var(--gold-bright);
}

/* ── Bottom nav ──────────────────────────────────────────── */

#bottom-nav {
    position: fixed;
    left: 50%;
    bottom: max(env(safe-area-inset-bottom), .9rem);
    translate: -50%;
    z-index: 2;
    display: flex;
    gap: .3rem;
    padding: .3rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(7, 21, 16, .88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

#bottom-nav[hidden] { display: none; }

.nav-item {
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--cream-dim);
    background: none;
    border: none;
    border-radius: 999px;
    padding: .55rem 1.3rem;
    display: flex;
    align-items: center;
    gap: .45rem;
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease;
}

.nav-item[data-selected="true"] {
    color: #241a05;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}

.nav-ico { font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
    .screen { animation: none; }
    .wheel.spinning { transition-duration: .3s; }
}
