* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 18px;
    line-height: 1.45;
    min-height: 100vh;
}
.container { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.3rem; margin: 0 0 16px; }
.muted { color: #94a3b8; }
a { color: #60a5fa; }

.card {
    background: #1e293b;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0 16px; border-bottom: 1px solid #334155; margin-bottom: 16px;
}
.who { font-weight: 600; }
.inline { display: inline; margin: 0; padding: 0; }
.link {
    background: none; border: none; color: #60a5fa; cursor: pointer;
    font-size: 1rem; padding: 0;
}

label {
    display: block; margin-bottom: 12px; font-weight: 500;
}
input[type=text], input[type=password] {
    display: block; width: 100%; margin-top: 4px;
    padding: 12px 14px; font-size: 1rem;
    background: #0f172a; color: #e2e8f0;
    border: 1px solid #334155; border-radius: 8px;
}

button {
    cursor: pointer;
    font-size: 1rem; font-weight: 600;
    padding: 12px 18px; border-radius: 8px; border: none;
    transition: background .15s, transform .05s;
}
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: #2563eb; color: #fff; }
button.primary:hover:not(:disabled) { background: #1d4ed8; }
button.warn    { background: #f59e0b; color: #1f2937; }
button.warn:hover:not(:disabled) { background: #d97706; color: #fff; }
button.danger  { background: #dc2626; color: #fff; }
button.danger:hover:not(:disabled) { background: #b91c1c; }
button.ghost   { background: transparent; color: #cbd5e1; border: 1px solid #475569; }
button.big     { width: 100%; padding: 16px; font-size: 1.1rem; margin-top: 8px; }

.error {
    background: #7f1d1d; color: #fee2e2;
    padding: 10px 14px; border-radius: 8px;
    margin-bottom: 12px; font-size: .95rem;
}
.status { margin-top: 12px; min-height: 24px; font-size: .95rem; }
.status.ok { color: #4ade80; }
.status.err { color: #fca5a5; }

.screen { animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.spinner {
    width: 32px; height: 32px; margin: 24px auto;
    border: 3px solid #334155; border-top-color: #60a5fa;
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.rules { padding-left: 20px; }
.rules li { margin-bottom: 8px; }

.qhead {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.badge {
    background: #334155; color: #cbd5e1;
    padding: 4px 10px; border-radius: 6px; font-size: .85rem;
}
.timer {
    background: #0f172a; border: 1px solid #334155;
    padding: 8px 14px; border-radius: 8px;
    font-variant-numeric: tabular-nums;
    font-size: 1.4rem; font-weight: 700;
}
.timer.danger { background: #7f1d1d; border-color: #b91c1c; color: #fee2e2; }
.t-unit { font-size: .85rem; color: #94a3b8; font-weight: 500; }

.options { display: grid; gap: 10px; margin: 16px 0; }
.opt-btn {
    text-align: left; padding: 14px; border-radius: 10px;
    background: #334155; color: #f1f5f9; border: 2px solid transparent;
    font-weight: 500;
}
.opt-btn:hover:not(:disabled) { background: #475569; }
.opt-btn.selected {
    background: #1e3a8a; border-color: #60a5fa; color: #fff;
}
.opt-letter {
    display: inline-block; width: 24px; height: 24px;
    background: #475569; color: #fff;
    border-radius: 4px; text-align: center; line-height: 24px;
    margin-right: 10px; font-weight: 700; font-size: .85rem;
}
.opt-btn.selected .opt-letter { background: #60a5fa; color: #0f172a; }

.row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 4px 0; flex-wrap: wrap;
}
.cur-question { margin-top: 8px; font-style: italic; }

.btn-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.btn-row button { flex: 1 1 auto; min-width: 120px; }

.leaderboard {
    width: 100%; border-collapse: collapse;
}
.leaderboard th, .leaderboard td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid #334155;
}
.leaderboard th { color: #94a3b8; font-weight: 600; font-size: .9rem; }
.leaderboard tr:first-child td { font-weight: 700; color: #fde047; }

@media (max-width: 480px) {
    body { font-size: 17px; }
    .container { padding: 12px; }
    .card { padding: 16px; }
    h1 { font-size: 1.4rem; }
    .timer { font-size: 1.2rem; }
}
