/* Live Test Arena — mobile-first competition UI (Phase 6) */

:root {
    --bg: #150f2e;
    --card: #241b45;
    --card-2: #2d2258;
    --accent: #8b5cf6;
    --accent-2: #ec4899;
    --teal: #2dd4bf;
    --amber: #fbbf24;
    --danger: #f87171;
    --text: #f3f0ff;
    --muted: #a99ed4;
    --border: #3b2f6b;
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(160deg, #1e1b4b 0%, #3b1d6e 50%, #701a5b 100%);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(36, 27, 69, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 { font-size: 1.05rem; margin: 0; margin-right: auto; }

.topbar nav {
    order: 10;
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 0.25rem;
}

.topbar nav.open { display: flex; }

.topbar nav button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    margin: 0;
    font-size: 0.9rem;
}

.hamburger {
    display: block;
    width: auto;
    margin: 0;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
}

@media (min-width: 768px) {
    .hamburger { display: none; }
    .topbar h1 { margin-right: 0; }
    .topbar nav {
        order: 0;
        width: auto;
        display: flex;
        flex-direction: row;
        gap: 0.4rem;
    }
    .topbar nav button { width: auto; text-align: center; padding: 0.35rem 0.6rem; }
    .topbar .auth { margin-left: auto; }
}

.shell { max-width: 560px; margin: 0 auto; padding: 1rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.card h2 { margin-top: 0; font-size: 1.2rem; }
.card h3 { color: var(--accent); margin: 1rem 0 0.3rem; font-size: 1rem; }
.aboutlist { margin: 0.5rem 0; padding-left: 1.2rem; color: var(--text); }
.aboutlist li { margin: 0.4rem 0; }
.rolebadge {
    display: inline-block;
    background: rgba(45, 212, 191, 0.16);
    color: #5eead4;
    border: 1px solid rgba(45, 212, 191, 0.35);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
}

label { display: block; margin: 0.75rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); }

input, select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    font-size: 1rem;
}

button {
    display: block;
    width: 100%;
    margin-top: 0.9rem;
    padding: 0.8rem;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary { background: linear-gradient(135deg, #8b5cf6, #ec4899); color: #fff; }
button.secondary { background: linear-gradient(135deg, #14b8a6, #2dd4bf); color: #04211d; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
button.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }

hr { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }

.roomcode {
    font-size: 2.4rem;
    letter-spacing: 0.35em;
    text-align: center;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border-radius: 12px;
    padding: 0.6rem;
    margin: 0.3rem 0;
}

.players { list-style: none; padding: 0; margin: 0.5rem 0; }
.players li {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.hint { color: var(--muted); font-size: 0.9rem; }
.topbar .auth { display: flex; align-items: center; gap: 0.4rem; }
.topbar .auth .handle { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.error { color: #f87171; }
.attempts { list-style: none; padding: 0; margin: 0; }
.attempts li { border-bottom: 1px solid var(--border); padding: 0.6rem 0; }
.attempts .aline { display: flex; justify-content: space-between; align-items: baseline; }
.answers { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.ans { width: 1.45rem; height: 1.45rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.ans.ok { background: rgba(34,197,94,.18); color: #22c55e; }
.ans.no { background: rgba(248,113,113,.18); color: #f87171; }

.roundbadge {
    display: inline-block;
    background: rgba(139, 92, 246, 0.18);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: #c4b5fd;
    margin-bottom: 0.5rem;
}

.playhead { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.playhead .roundbadge { margin-bottom: 0; }
.timer { font-weight: 800; color: var(--amber); font-size: 1.05rem; white-space: nowrap; }
.elapsed { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.myscore { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.myscore strong { color: var(--teal); font-size: 1.15rem; }

.question {
    font-size: 2rem;
    text-align: center;
    font-weight: 700;
    padding: 1rem 0;
}

.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
.opt {
    margin: 0;
    padding: 1.3rem 0;
    font-size: 1.5rem;
    background: var(--card-2);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    transition: transform .12s ease, border-color .12s ease;
}
.opt:hover { border-color: var(--accent); transform: translateY(-2px); }
.opt:active { border-color: var(--accent-2); }

.feedback { text-align: center; margin-top: 0.8rem; font-size: 1.1rem; }
.feedback .waiting { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.scoreboard { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.scoreboard h3 { font-size: 0.95rem; color: var(--muted); }
.scoreline { display: flex; justify-content: space-between; padding: 0.3rem 0; }

.ranking { list-style: none; padding: 0; margin: 0.7rem 0; }
.ranking li {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
}
.ranking li:first-child { color: var(--amber); font-weight: 700; }

.toast {
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #334155;
    color: var(--text);
    padding: 0.6rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@media (min-width: 560px) {
    .options { grid-template-columns: repeat(4, 1fr); }
}

.banner { width: 100%; border-radius: 12px; margin: 0.4rem 0 0.6rem; }
.details { display: inline-block; color: var(--accent); text-decoration: none; margin-bottom: 0.5rem; }
#qrbox { text-align: center; margin: 0.6rem 0; }
#qrbox img { image-rendering: pixelated; border-radius: 8px; background: #fff; padding: 6px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.share-row button { margin-top: 0.5rem; }
button.wa { background: #25d366; color: #04120b; }
button.tg { background: #229ed9; color: #fff; }
button.fb { background: #1877f2; color: #fff; }
button.skip { background: transparent; border: 1px dashed var(--border); color: var(--muted); padding: 0.6rem; margin-top: 0.8rem; }
textarea { width: 100%; padding: 0.7rem 0.8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-size: 1rem; font-family: inherit; resize: vertical; }
label.check { display: flex; align-items: center; gap: 0.55rem; }
label.check input[type=checkbox] { width: auto; height: 1.2rem; accent-color: var(--accent-2); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0.9rem 0 0.3rem; }
.tab { margin: 0; padding: 0.7rem; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabpanel { margin-top: 0.4rem; }
.qtypes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.3rem; }
.qtype { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.qtype input, .qtype select { width: 100%; }
.devrole { width: auto; padding: 0.3rem 0.5rem; font-size: 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); }
.openrooms { list-style: none; padding: 0; margin: 0.5rem 0; }
.openrooms li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.roominfo { display: flex; flex-direction: column; min-width: 0; }
.rname { font-weight: 600; }
.rmeta { font-size: 0.8rem; color: var(--muted); }
.roomactions { display: flex; gap: 0.4rem; flex-shrink: 0; }
button.small { width: auto; margin: 0; padding: 0.45rem 0.8rem; font-size: 0.85rem; border-radius: 8px; }
.level { display: inline-block; background: rgba(236,72,153,.18); color: #f9a8d4; padding: 0.25rem 0.6rem; border-radius: 999px; font-weight: 700; margin-bottom: 0.5rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.badge { background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.3rem 0.6rem; font-size: 0.85rem; }
