/* Look & feel modelled on politie.nl: dark navy header, light grey page,
   white cards, strong blue for links and actions. */
:root {
    --navy: #0c2a52;        /* header / footer band */
    --navy-dark: #081d3a;
    --primary: #1561ad;     /* links, buttons, focus */
    --primary-dark: #0f4c8a;
    --bg: #f2f4f7;
    --panel: #ffffff;
    --surface: #eef1f5;     /* inputs, option tiles */
    --border: #d5dbe3;
    --accent: var(--primary);
    --accent2: var(--primary);
    --text: #1a1f29;
    --muted: #5b6573;
    --correct: #2e7d32;
    --wrong: #c62828;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }

a { color: var(--primary); }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px; background: var(--navy); color: #fff;
    flex-wrap: wrap; gap: 8px;
}
.brand { font-size: 1.3rem; font-weight: 700; color: #fff; letter-spacing: .01em; }
.who { color: #c9d4e3; }
.who strong, .who #myScore { color: #fff; }
.topbar a { color: #fff; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.4); }
.topbar a:hover { text-decoration-color: #fff; }

/* Player top bar: click the team name to list the team's players. */
.team-menu { position: relative; display: inline-block; }
button.team-toggle {
    background: none; color: #fff; font-weight: 700; font-size: inherit;
    padding: 0; margin: 0; border-radius: 0;
    text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.4);
}
button.team-toggle:hover { background: none; text-decoration-color: #fff; }
.team-popover {
    position: absolute; left: 0; top: calc(100% + 8px); z-index: 20;
    min-width: 200px; max-width: calc(100vw - 32px); padding: 12px 16px;
    background: var(--panel); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.team-popover-title { font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.team-popover ul { list-style: none; margin: 0; padding: 0; }
.team-popover li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.team-popover li:last-child { border-bottom: none; }
.team-popover li.is-me { color: var(--primary); font-weight: 600; }
.team-popover li.hint { margin: 0; border: none; }

.quiz-area { max-width: 720px; margin: 32px auto; padding: 0 16px; }
.panel {
    background: var(--panel); border-radius: 8px; padding: 28px;
    border: 1px solid var(--border); box-shadow: 0 2px 6px rgba(12,42,82,.06);
}
.hidden { display: none !important; }

.round-label { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; font-weight: 600; margin-bottom: 6px; }
h1, h2, h3 { margin-top: 0; color: var(--navy); }

.media-box { margin: 16px 0; text-align: center; }
.media-box img { max-width: 100%; border-radius: 6px; }
.media-box audio, .media-box video { width: 100%; border-radius: 6px; }
.media-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 24px; border-radius: 6px; background: var(--surface); color: var(--muted);
}
.media-placeholder-icon { font-size: 3rem; line-height: 1; }
.media-placeholder-video { position: relative; padding: 0; overflow: hidden; background: var(--navy); }
.media-placeholder-video video { display: block; pointer-events: none; border-radius: 0; }
.media-placeholder-label {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    padding: 8px 14px; border-radius: 999px; background: rgba(8,29,58,.8); color: #fff; font-weight: 600;
}

.timer { font-size: 1.4rem; font-weight: 700; color: var(--navy); margin: 10px 0; }

.options { display: grid; gap: 10px; margin: 16px 0; }
.options label {
    display: block; background: var(--panel); border: 2px solid var(--border); border-radius: 6px;
    padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.options label:hover { border-color: var(--primary); background: #f5f9fd; }
.options input[type=radio] { margin-right: 10px; accent-color: var(--primary); }

input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
    font: inherit; color: var(--text);
    background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
}
.open-answer input {
    width: 100%; padding: 12px; font-size: 1rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 3px solid #7fb2e5; outline-offset: 1px;
}

button {
    background: var(--primary); color: #fff; border: none; border-radius: 6px;
    padding: 12px 20px; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 14px;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }

.hint { color: var(--muted); margin-top: 12px; }
.error { color: var(--wrong); font-weight: 600; }

/* Player page: the whole screen is the quiz - top bar, then the current panel filling the
   rest, sized by quiz.js/fit.js so question, media, options and answer all fit without
   scrolling. Text sizes are em off --fit, which fit.js lowers when there isn't room. */
body.player-page { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
body.player-page .topbar { flex: none; padding: 8px 16px; font-size: .9rem; }
body.player-page .brand { font-size: 1.1rem; }
body.player-page .quiz-area {
    flex: 1 1 auto; min-height: 0; width: 100%; margin: 0 auto; padding: 12px 16px;
    display: flex; flex-direction: column; gap: 10px;
}
body.player-page .quiz-area > .panel {
    flex: 0 1 auto; min-height: 0; overflow-y: auto; /* scrolls only as a last resort */
    padding: 16px 20px; font-size: calc(1rem * var(--fit, 1));
}
body.player-page #connLost { flex: none; padding: 8px 16px; }
body.player-page #connLost p { margin: 0; }
body.player-page .panel h2 { margin-bottom: .4em; }
body.player-page .round-label { font-size: .8em; margin-bottom: .3em; }
body.player-page .tag { font-size: .75em; }
body.player-page .tag-speed { margin-bottom: .5em; }
body.player-page .media-box { margin: .5em 0; }
body.player-page .media-box img { display: block; margin: 0 auto; height: auto; }
body.player-page .media-placeholder { padding: 1em; }
body.player-page .media-placeholder-icon { font-size: 3em; }
body.player-page .timer { font-size: 1.4em; margin: .3em 0; }
body.player-page .hint { margin-top: .5em; }
body.player-page .options { gap: .5em; margin: .6em 0; }
body.player-page .options label { padding: .6em .8em; }
body.player-page .open-answer input { font-size: max(1em, 16px); padding: .6em; } /* 16px+ stops iOS zooming in */
body.player-page .panel button { font-size: 1em; padding: .6em 1.2em; margin-top: .6em; }
body.player-page #revealText { font-size: 1.6em; font-weight: 700; color: var(--correct); margin: .3em 0; }
body.player-page #myResult { font-size: 1.1em; margin: .4em 0 0; }
/* 10 rows visible (height set by fit.js), the rest by scrolling inside the box. */
body.player-page .lb-scroll { margin-top: .6em; overflow-y: auto; border-bottom: 1px solid var(--border); }
body.player-page .lb-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); }
body.player-page table.leaderboard { margin-top: 0; }
body.player-page table.leaderboard tr.is-me td { background: #e3eefa; color: var(--navy); font-weight: 700; }
body.player-page table.leaderboard th, body.player-page table.leaderboard td { padding: .45em .4em; }

/* Auth pages */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-box {
    background: var(--panel); padding: 36px; border-radius: 8px; width: 100%; max-width: 380px;
    border: 1px solid var(--border); border-top: 6px solid var(--navy);
    box-shadow: 0 2px 6px rgba(12,42,82,.06);
}
.auth-box label { display: block; margin: 14px 0 6px; font-size: .9rem; font-weight: 600; color: var(--text); }
.auth-box input {
    width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
.auth-box a { color: var(--primary); }

/* Leaderboard */
table.leaderboard { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.leaderboard th, table.leaderboard td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.leaderboard th { color: var(--muted); font-weight: 600; }
/* Team mode: each teammate's points under their team. */
.lb-players { color: var(--muted); font-size: .9em; }
.lb-player { display: inline-block; margin: 0 12px 2px 0; white-space: nowrap; }
.lb-player strong { color: var(--text); }

/* Admin */
.admin-nav { margin-bottom: 20px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table th { color: var(--muted); font-weight: 600; }
.media-thumb { display: block; max-width: 70px; max-height: 50px; border-radius: 4px; object-fit: cover; background: var(--surface); }
.media-thumb-audio { display: block; max-width: 160px; height: 32px; }

@keyframes row-highlight { from { background: #dbe9f8; } to { background: transparent; } }
.row-highlight td { animation: row-highlight 2s ease-out; }

.round-separator td { padding: 0; border-bottom: none; }
.round-separator { scroll-margin-top: 12px; }
/* "Jump to: Round 1, Round 2, ..." links at the top of quiz.php. */
.round-jump { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.round-jump .hint { margin: 0 4px 0 0; }
.round-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    background: var(--surface); border-left: 4px solid var(--navy); border-bottom: 1px solid var(--border);
    padding: 12px 10px; margin-top: 6px;
}
.round-header strong { color: var(--navy); font-size: 1.05rem; letter-spacing: .02em; }
.round-name-form { display: flex; align-items: center; gap: 6px; }
.round-name-form input[type=text] {
    padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); width: 220px;
}
.round-name-form button, .round-jump button { margin-top: 0; padding: 6px 12px; font-size: .85rem; }.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.btn-row button, .btn-row a.button {
    background: var(--primary); color: #fff; text-decoration: none; padding: 10px 16px;
    border-radius: 6px; font-weight: 600; display: inline-block;
}
.btn-row button:hover, .btn-row a.button:hover { background: var(--primary-dark); }
.btn-danger { background: var(--wrong) !important; }

/* Compact per-question buttons in the quiz.php list: one line, side by side. */
.row-actions { white-space: nowrap; }
.row-actions-inner { display: flex; align-items: center; gap: 6px; }
.row-actions-inner form { margin: 0; }
.row-actions-inner button, .row-actions-inner a.button {
    margin: 0; padding: 6px 12px; font-size: .85rem; font-weight: 600; line-height: 1.4;
    background: var(--primary); color: #fff; text-decoration: none; border-radius: 6px; display: inline-block;
}
.row-actions-inner button:hover, .row-actions-inner a.button:hover { background: var(--primary-dark); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.tag-live { background: #dff3e1; color: var(--correct); }
.tag-draft { background: var(--surface); color: var(--muted); }
.tag-category { background: var(--surface); color: var(--navy); border: 1px solid var(--border); margin-bottom: 4px; }
.tag-finished { background: #e3e6eb; color: var(--muted); }
.tag-speed { background: #fff4d6; color: #7a5600; display: inline-block; margin-bottom: 10px; }

.active-question {
    margin: 16px 0; padding: 18px 20px; border: 1px solid var(--border); border-left: 4px solid var(--navy);
    border-radius: 6px; background: var(--surface);
}
/* Host page: the card sits in the question list, right above the active question's row. */
.active-question-row > td { padding: 4px 0 8px; border-bottom: none; }
.active-question-row { scroll-margin-top: 12px; }
.active-question-row .active-question { margin-top: 0; }
tr.is-active-question td { background: var(--surface); font-weight: 600; }
.active-question-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.active-question-timer { font-weight: 700; color: var(--navy); }
.active-question-text { font-size: 1.25rem; font-weight: 600; margin: 6px 0 12px; }
.active-question-media { display: block; max-width: 100%; max-height: 240px; border-radius: 6px; margin-bottom: 12px; }
.active-question-options { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.active-question-options li { background: var(--panel); border: 2px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.active-question-options li.is-correct { border-color: var(--correct); background: #e8f5e9; color: #1b4d1e; font-weight: 600; }
.active-question-answer { margin: 0; }
/* While the question is live the answer is hidden; options look neutral. */
.answer-pending { display: none; }
.answer-hidden .answer-pending { display: block; }
.answer-hidden .answer-only { display: none; }
.answer-hidden .active-question-options li.is-correct { border-color: var(--border); background: var(--panel); color: inherit; font-weight: normal; }

.waiting-message-form textarea { width: 100%; padding: 8px; resize: vertical; }
.waiting-message-form button { margin-top: 8px; }
#waitingText { white-space: pre-line; } /* keep the host's line breaks */

.blank-screen-tool { margin: 16px 0; }
.blank-screen-tool summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
.blank-screen-tool summary:hover { text-decoration: underline; }
.blank-screen-tool .hint { margin-top: 8px; }
.blank-screen-tool form { margin-top: 10px; }

.grading-group { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.grading-group:last-child { border-bottom: none; }
.grading-group h3 { color: var(--navy); margin-bottom: 4px; }
.grading-question { font-size: 1.15rem; font-weight: 600; margin: 6px 0; }
