:root {
    --night: #050a24;
    --navy: #0a1440;
    --panel: #101d5c;
    --panel-line: #33479f;
    --blue: #1c3aa9;
    --gold: #f2c14e;
    --gold-light: #ffe39a;
    --orange: #f08a1d;
    --green-light: #4ade80;
    --ink: #f5f7ff;
    --muted: #b9c5ea;
    --dark-ink: #1a1200;
    --danger: #ffb3b3;
    --cut: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font: 17px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(ellipse 90% 60% at 50% 0, rgba(70, 110, 255, .38), transparent 70%),
        repeating-conic-gradient(from 0deg at 50% -10%, rgba(255, 255, 255, .025) 0 6deg, transparent 6deg 14deg),
        linear-gradient(180deg, var(--navy), var(--night));
    background-attachment: fixed;
}

a { color: var(--gold-light); }
h1, h2 { line-height: 1.2; }
h2 { margin: 0 0 12px; font-size: 1.05rem; color: var(--gold-light); }
code { color: var(--gold-light); }

.center { max-width: 760px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.page { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.logo {
    margin: 0 0 12px;
    font-size: clamp(2.4rem, 9vw, 4rem);
    font-weight: 800;
    letter-spacing: .01em;
    color: var(--gold);
    text-shadow: 0 2px 24px rgba(242, 193, 78, .35);
}
.logo span { color: var(--ink); }
.lead { margin: 0 auto 28px; max-width: 520px; color: var(--muted); }

.card {
    padding: 18px;
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    background: rgba(16, 29, 92, .82);
}

.code-form { max-width: 420px; margin: 0 auto 20px; text-align: left; }
.code-form .btn { width: 100%; }

.field { display: block; margin-bottom: 14px; color: var(--muted); font-size: .92rem; }
.field input, .field textarea {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 11px 12px;
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    background: var(--night);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.code-input { text-align: center; font-size: 1.35rem !important; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.btn {
    display: inline-block;
    min-height: 46px;
    padding: 10px 20px;
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: var(--gold);
    color: var(--dark-ink);
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--gold-light); }
.btn-secondary { background: transparent; color: var(--gold-light); }
.btn-secondary:hover { background: rgba(242, 193, 78, .14); }
.btn:focus-visible, .btn-small:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.btn-small {
    min-height: 36px;
    padding: 5px 10px;
    border: 1px solid var(--panel-line);
    border-radius: 6px;
    background: var(--navy);
    color: var(--ink);
    font: inherit;
    font-size: .88rem;
    cursor: pointer;
}
.btn-small:hover:not(:disabled) { border-color: var(--gold); }
.btn-small:disabled { opacity: .45; cursor: not-allowed; }

.error { margin: 0 0 14px; color: var(--danger); font-weight: 600; }
.notice {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-left: 3px solid var(--orange);
    background: rgba(240, 138, 29, .12);
    font-size: .9rem;
    text-align: left;
}

.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 1.5rem; color: var(--gold); overflow-wrap: anywhere; }

.code-display { margin: 6px 0; color: var(--gold); font-size: 1.7rem; font-weight: 800; letter-spacing: .08em; overflow-wrap: anywhere; }
.host-code-banner { margin-bottom: 18px; border-color: var(--gold); }
.host-code-banner p:last-child { margin-bottom: 0; }

/* Sechseckige Felder: Der äußere Rahmen zeigt die Goldkante, der innere die Fläche. */
.hex {
    --shape: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% 50%, calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 50%);
    display: block;
    width: 100%;
    padding: 2px;
    border: 0;
    background: var(--gold);
    color: var(--ink);
    font: inherit;
    text-align: left;
    clip-path: var(--shape);
}
.hex-inner {
    display: block;
    height: 100%;
    padding: 14px calc(var(--cut) + 12px);
    background: linear-gradient(180deg, var(--blue), var(--navy) 55%, var(--panel));
    clip-path: var(--shape);
}

.question-box { margin-bottom: 16px; }
.question-box .hex-inner { padding-block: 22px; font-size: clamp(1.1rem, 2.6vw, 1.4rem); font-weight: 600; text-align: center; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 16px; }
.answer .hex-inner { display: flex; gap: 8px; align-items: center; min-height: 58px; }
.answer b { color: var(--gold); }
.answers.letters-only { grid-template-columns: 1fr 1fr; }
.letters-only .answer .hex-inner { justify-content: center; min-height: 88px; font-size: 2rem; }
.letters-only .answer span span { display: none; }
button.answer { cursor: pointer; }
button.answer:hover .hex-inner { background: var(--blue); }
button.answer:focus-visible { background: #fff; }
button.answer:focus-visible .hex-inner { background: var(--blue); }

.answer.is-locked { background: var(--gold-light); }
.answer.is-locked .hex-inner { background: linear-gradient(180deg, #ffa94a, var(--orange)); color: var(--dark-ink); }
.answer.is-locked b { color: var(--dark-ink); }

.host-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.sidebar { display: grid; gap: 14px; }
.stage { min-width: 0; }

.status-pill {
    display: inline-block;
    margin: 0 0 14px;
    padding: 4px 12px;
    border: 1px solid var(--panel-line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 600;
}
.status-pill[data-status="open"] { border-color: var(--orange); color: var(--gold-light); }
.status-pill[data-status="revealed"] { border-color: var(--green-light); color: var(--green-light); }

.stage-hint { color: var(--muted); }
.controls { margin-top: 16px; }

/* Publikumsjoker-Diagramm: fester Maßstab bis 100 %, damit Balken vergleichbar bleiben. */
.chart {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    height: 300px;
    padding: 14px 10px 10px;
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    background: rgba(5, 10, 36, .7);
}
.chart-column { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-width: 0; text-align: center; }
.chart-track {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    min-height: 0;
    border-bottom: 1px solid var(--panel-line);
}
.chart-value { margin-bottom: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-bar {
    width: min(64%, 72px);
    height: calc((100% - 30px) * var(--share, 0));
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background: var(--gold);
    transition: height .45s ease;
}
.chart-letter { margin-top: 6px; color: var(--gold-light); font-weight: 800; }
.chart-count { color: var(--muted); font-size: .8rem; }
.vote-total { margin: 10px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }

.share { text-align: center; }
.share canvas { display: block; width: 100%; max-width: 240px; height: auto; margin: 8px auto; border-radius: 6px; }
.share .btn { width: 100%; }
.join-url { margin: 6px 0 12px; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }

.host-code-menu { position: relative; }
.host-code-menu summary { list-style: none; }
.host-code-menu summary::-webkit-details-marker { display: none; }
.host-code-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; width: 360px; background: var(--panel); }
.host-code-panel .code-display { margin: 0 0 12px; white-space: nowrap; }
.host-code-panel .btn { width: 100%; }
.host-code-panel .form-hint { margin: 10px 0 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--panel-line); }
.tabs a { padding: 10px 16px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { border-bottom-color: var(--gold); color: var(--gold-light); }

.narrow { max-width: 820px; }
.form-hint { margin: 0 0 14px; color: var(--muted); font-size: .92rem; }

.stopwatch { margin: 0 0 12px; color: var(--gold); font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.lobby { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.lobby li { padding: 4px 12px; border: 1px solid var(--panel-line); border-radius: 999px; overflow-wrap: anywhere; }
.lobby li.is-done { border-color: var(--green-light); color: var(--green-light); }

.pick-badge {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--dark-ink);
    color: var(--gold-light);
    font-style: normal;
    font-weight: 800;
}
.picked { margin: 0 0 12px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.order-actions { justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.play-player { margin: 0 0 16px; color: var(--muted); overflow-wrap: anywhere; }
.play #ranking, .play .chart { text-align: left; }
.play .vote-total { text-align: center; }

.solution { margin: 0 0 18px; padding-left: 24px; }
.ranking { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: place; }
.ranking li {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    align-items: baseline;
    justify-content: space-between;
    padding: 9px 12px;
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    background: rgba(5, 10, 36, .6);
    counter-increment: place;
}
.ranking li.is-winner { border-color: var(--gold); background: rgba(242, 193, 78, .16); font-size: 1.15rem; font-weight: 700; }
.ranking li.is-out { color: var(--muted); }
.ranking li.is-me { outline: 2px solid var(--orange); outline-offset: 1px; }
.ranking-name { min-width: 0; overflow-wrap: anywhere; }
.ranking-name::before { content: counter(place) ". "; color: var(--gold-light); font-weight: 700; }
.ranking-result { font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-actions { justify-content: flex-end; }

.play { max-width: 900px; }
.play-title { margin: 0 0 16px; font-size: 1.3rem; color: var(--gold); overflow-wrap: anywhere; }
.play-message { margin: 18px 0 0; font-size: 1.15rem; font-weight: 600; }

@media (max-width: 960px) {
    .host-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
    :root { --cut: 16px; }
    .center { padding-top: 28px; }
    .answers { grid-template-columns: minmax(0, 1fr); }
    .host-code-panel { position: static; width: auto; margin-top: 8px; }
    .host-code-panel .code-display { font-size: 1.35rem; white-space: normal; }
    .chart { height: 240px; padding-inline: 4px; }
    .chart-count { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
    .chart-bar { transition: none; }
}
