:root {
    --bg-deep: #1B1030;
    --bg-deep-2: #2D1B4E;
    --coral: #FF6B6B;
    --teal: #4ECDC4;
    --yellow: #FFD93D;
    --lime: #B8FF3D;
    --purple: #C77DFF;
    --text-light: #F4F1FA;
    --text-muted: #B8AEDB;
    --card-bg: rgba(255,255,255,0.06);
    --card-border: rgba(255,255,255,0.12);
    --font-display: 'Baloo 2', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(ellipse at top left, var(--bg-deep-2), var(--bg-deep) 60%);
    color: var(--text-light);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; }

.logo, .logo-small {
    font-family: var(--font-display);
    font-weight: 800;
    background: linear-gradient(90deg, var(--coral), var(--yellow), var(--lime));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.logo { font-size: 4rem; text-align: center; }
.logo-small { font-size: 1.6rem; }
.logo-dot { color: var(--coral); -webkit-text-fill-color: var(--coral); }

/* ---------- Bakgrundslampor (används på alla sidor) ---------- */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    z-index: 0;
    pointer-events: none;
    animation: float 12s ease-in-out infinite;
}
.blob-1 { width: 480px; height: 480px; background: var(--coral); top: -120px; left: -120px; }
.blob-2 { width: 420px; height: 420px; background: var(--purple); bottom: -100px; right: -100px; animation-delay: 3s; }
.blob-3 { width: 320px; height: 320px; background: var(--teal); top: 40%; left: 60%; animation-delay: 6s; }
.blob-4 { width: 340px; height: 340px; background: var(--yellow); bottom: 10%; left: -80px; animation-delay: 9s; }
@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    50% { transform: translate(30px,-30px) scale(1.08); }
}

.landing-wrap {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
    text-align: center;
}
.tagline { color: var(--text-muted); font-size: 1.15rem; margin-top: 0.5rem; margin-bottom: 3rem; }

.card-row { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2rem;
    flex: 1 1 320px;
    max-width: 380px;
    text-align: left;
    backdrop-filter: blur(10px);
}
.panel h2 { font-size: 1.3rem; margin-bottom: 1.2rem; }
.panel form label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.panel input, .panel select {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.08);
    color: var(--text-light);
    font-size: 1rem;
    font-family: var(--font-body);
}
.panel input:focus, .panel select:focus { outline: 2px solid var(--lime); }
.panel select option {
    background: var(--bg-deep-2);
    color: var(--text-light);
}

.btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    border: none;
    border-radius: 14px;
    padding: 0.9rem 1.6rem;
    cursor: pointer;
    width: 100%;
    transition: transform 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(90deg, var(--coral), var(--yellow)); color: #1B1030; }
.btn-secondary { background: linear-gradient(90deg, var(--teal), var(--purple)); color: #1B1030; }
.btn-downvote { background: rgba(255,255,255,0.1); color: var(--text-light); border: 2px solid var(--coral); margin-top: 1.5rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.error { color: var(--coral); font-size: 0.9rem; margin-top: 0.7rem; min-height: 1.2em; }

/* ---------- Display (huvudskärm) ---------- */
body.display .screen { padding: 2.5rem 3rem; position: relative; z-index: 1; }
.code-hint { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 1.5rem; }
.qr-wrap { display: flex; justify-content: center; margin-top: 0.8rem; }
.qr-code {
    width: 300px;
    height: 300px;
    background: #fff;
    padding: 10px;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(184,255,61,0.25);
}
.game-code {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-align: center;
    color: var(--lime);
    margin: 0.7rem 0 1.3rem;
}
.players-heading { text-align: center; color: var(--text-muted); font-size: 1.1rem; margin-bottom: 0.7rem; }
.lobby-players { list-style: none; padding: 0; max-width: 500px; margin: 0 auto 1.3rem; }
.lobby-players li {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 0.6rem 1.3rem;
    margin-bottom: 0.4rem;
    font-size: 1.2rem;
    text-align: center;
}
#startBtn { max-width: 320px; margin: 0 auto; display: block; }
.hint { text-align: center; color: var(--text-muted); margin-top: 1rem; }
.hint a { color: var(--lime); }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.round-info { color: var(--text-muted); font-size: 1.2rem; }

.scoreboard { display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: center; margin-bottom: 1.5rem; }
.score-chip {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 0.6rem 1.3rem;
    display: flex;
    gap: 0.8rem;
    align-items: center;
    font-size: 1.1rem;
}
.score-chip.active { border-color: var(--lime); box-shadow: 0 0 20px rgba(184,255,61,0.4); }
.score-name { font-weight: 600; }
.score-val { font-family: var(--font-display); color: var(--yellow); font-weight: 700; }

.turn-banner {
    text-align: center;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--yellow);
    margin-bottom: 1.5rem;
}

.category-grid, .mobile-category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}
.category-card {
    background: linear-gradient(135deg, var(--purple), var(--coral));
    border-radius: 18px;
    padding: 1.8rem 1rem;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    color: #1B1030;
}
.category-card.disabled {
    opacity: 0.4;
    filter: grayscale(0.6);
}

.question-area { text-align: center; max-width: 900px; margin: 0 auto; }
.question-cat {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 0.4rem 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.question-text { font-size: 1.7rem; font-weight: 600; margin-bottom: 1.2rem; }
.options-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; max-width: 700px; margin: 0 auto; }
.option-card {
    border: 2px solid;
    border-radius: 12px;
    padding: 0.7rem 1rem;
    font-size: 1.05rem;
    background: rgba(255,255,255,0.04);
    transition: background 0.2s, box-shadow 0.2s;
}
.option-card.selected {
    background: rgba(255,255,255,0.18);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5) inset;
}
.option-card.correct {
    background: rgba(184,255,61,0.25);
    box-shadow: 0 0 0 3px var(--lime) inset;
}
.option-card.wrong {
    background: rgba(255,107,107,0.25);
    box-shadow: 0 0 0 3px var(--coral) inset;
}

.reveal-area { text-align: center; max-width: 700px; margin: 2rem auto 0; }
.reveal-result { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; margin-bottom: 1rem; }
.reveal-result.correct { color: var(--lime); }
.reveal-result.wrong { color: var(--coral); }
.reveal-answer { font-size: 1.3rem; color: var(--text-muted); margin-bottom: 1rem; }
.reveal-timer { color: var(--text-muted); margin-top: 0.8rem; }
#questionTimer { margin-top: 0.8rem; }

.streak-meter { display: flex; justify-content: center; gap: 0.7rem; margin-top: 2rem; }
.streak-dot {
    width: 46px; height: 46px;
    border-radius: 50%;
    border: 2px solid var(--card-border);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-muted);
}
.streak-dot.filled { background: var(--lime); color: #1B1030; border-color: var(--lime); }

.winner-card { text-align: center; margin: 2rem 0 3rem; }
.trophy { font-size: 5rem; }
.winner-name { font-family: var(--font-display); font-size: 3rem; font-weight: 800; color: var(--yellow); }
.winner-sub { color: var(--text-muted); font-size: 1.3rem; }

/* ---------- Mobile play view ---------- */
body.play .screen {
    min-height: 100vh;
    padding: 1.5rem 1.2rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}
.wait-message {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 3rem 0 2rem;
    color: var(--text-light);
}
.mini-scoreboard { width: 100%; max-width: 420px; }
.mini-score-row {
    display: flex;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.7rem 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}
.mini-score-row.you { border-color: var(--lime); }

.prompt { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; }
.mobile-category-list { grid-template-columns: 1fr; width: 100%; max-width: 420px; }
.category-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    padding: 1.3rem;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, var(--purple), var(--coral));
    color: #1B1030;
    margin-bottom: 0.9rem;
    width: 100%;
}
.category-btn:disabled { opacity: 0.5; }

.mobile-question-cat {
    text-align: center;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    margin-bottom: 1rem;
    display: inline-block;
    align-self: center;
}
.mobile-question-text { text-align: center; font-size: 1.4rem; font-weight: 600; margin-bottom: 1.5rem; }
.mobile-options { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 0.8rem; }
.option-btn {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.05rem;
    padding: 1.1rem;
    border-radius: 14px;
    border: none;
    color: #1B1030;
    width: 100%;
}
.option-btn:disabled { opacity: 0.55; }

.downvote-hint { color: var(--text-muted); margin-top: 0.7rem; text-align: center; }

@media (max-width: 640px) {
    .logo { font-size: 2.6rem; }
    .game-code { font-size: 1.4rem; }
    .options-grid { grid-template-columns: 1fr; }
    .question-text { font-size: 1.5rem; }
}

/* ---------- Historik ---------- */
body.history {
    padding: 2.5rem 1.5rem 4rem;
}
.history-wrap {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}
.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 1.2rem;
    font-size: 0.95rem;
}
.back-link:hover { color: var(--lime); }

.history-list { display: flex; flex-direction: column; gap: 1rem; }
.history-card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 1.2rem 1.4rem;
    text-decoration: none;
    color: var(--text-light);
    transition: border-color 0.15s ease;
}
.history-card:hover { border-color: var(--lime); }
.history-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.history-code {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.1em;
    color: var(--lime);
}
.status-pill {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-pill.lobby { background: rgba(184,255,61,0.15); color: var(--lime); }
.status-pill.playing { background: rgba(255,217,61,0.15); color: var(--yellow); }
.status-pill.finished { background: rgba(199,125,255,0.2); color: var(--purple); }
.history-date { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.4rem; }
.history-players { color: var(--text-light); font-size: 0.95rem; }
.winner-tag {
    margin-left: 0.6rem;
    color: var(--yellow);
    font-weight: 600;
}

.detail-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    margin-top: 1.2rem;
}
.detail-section h2 {
    font-size: 1.15rem;
    margin-bottom: 1rem;
}
.score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--card-border);
}
.score-row:last-child { border-bottom: none; }
.score-row .pts { font-family: var(--font-display); font-weight: 700; color: var(--yellow); }

.log-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.log-table th, .log-table td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--card-border);
    vertical-align: top;
}
.log-table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.log-table .q-text { max-width: 280px; }
.outcome-yes { color: var(--lime); font-weight: 700; }
.outcome-no { color: var(--coral); font-weight: 700; }

.disabled-question-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.9rem;
}
.disabled-question-card:last-child { margin-bottom: 0; }
.disabled-question-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.option-pill {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.option-pill.correct {
    border-color: var(--lime);
    color: var(--lime);
    font-weight: 600;
}
