/* Look & feel of Music Twister: dark background, cards, orange accent, light-blue links,
   a top bar with an orange line under it, and light input fields. */
:root {
    --bg: #0b0d12;
    --panel: #161a22;       /* cards */
    --surface: #1d222c;     /* tiles, inner blocks */
    --border: #2c3340;
    --text: #e9edf3;
    --muted: #9aa5b5;
    --heading: #ffffff;
    --primary: #e8590c;     /* orange: buttons, accents, focus */
    --primary-dark: #c44a08;
    --primary-soft: rgba(232, 89, 12, .18);
    --link: #b5cefc;
    --correct: #5bd17a;
    --wrong: #ff6b6b;
    --warn: #f2c14e;
    --field-bg: #f4f6f9;    /* input fields stay light, like Music Twister */
    --field-text: #111;
    --radius: 10px;
    /* kept for the big-screen display (display.css) and older rules */
    --navy: #0b0d12;
    --accent: var(--primary);
    --accent2: var(--primary);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }

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

.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; background: var(--panel); color: var(--text);
    border-bottom: 4px solid var(--primary); box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
    flex-wrap: wrap; gap: 8px 20px;
}
.brand { font-size: 1.15rem; font-weight: 800; color: #fff; letter-spacing: .01em; white-space: nowrap; }
.brand span { color: var(--primary); font-weight: 700; }
.who { color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.who strong, .who #myScore { color: #fff; }
.topbar a { color: var(--text); font-weight: 600; text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.topbar a:hover { background: var(--surface); }

/* 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,.35);
}
button.team-toggle:hover { background: none; text-decoration-color: var(--primary); }
.team-popover {
    position: absolute; left: 0; top: calc(100% + 8px); z-index: 60;
    min-width: 220px; max-width: calc(100vw - 32px); padding: 12px 16px;
    background: var(--panel); color: var(--text); border: 1px solid var(--border); border-top: 4px solid var(--primary);
    border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.team-popover-title { font-weight: 700; color: var(--heading); margin-bottom: 6px; }
.team-popover ul { list-style: none; margin: 0; padding: 0; }
.team-popover li { display: flex; align-items: center; gap: 8px; padding: 5px 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; }
.topbar .team-popover-link { display: block; margin-top: 8px; padding: 6px 0 0; border-top: 1px solid var(--border); border-radius: 0; color: var(--link); font-size: .9rem; }
.topbar .team-popover-link:hover { background: none; text-decoration: underline; }
button.team-toggle .avatar { vertical-align: -5px; }

.quiz-area { max-width: 720px; margin: 32px auto; padding: 0 16px; }
.panel {
    background: var(--panel); border-radius: var(--radius); padding: 28px;
    border: 1px solid var(--border);
}
.hidden { display: none !important; }

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

.media-box { margin: 16px 0; text-align: center; }
.media-box img { max-width: 100%; border-radius: 8px; }
.media-box audio, .media-box video { width: 100%; border-radius: 8px; }
.media-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 24px; border-radius: 8px; background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.media-placeholder-icon { font-size: 3rem; line-height: 1; }
.media-placeholder-video { position: relative; padding: 0; overflow: hidden; background: #000; }
.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(11,13,18,.85); color: #fff; font-weight: 600;
    border: 1px solid var(--primary);
}

.timer { font-size: 1.4rem; font-weight: 800; color: #3fd0e0; margin: 10px 0; font-variant-numeric: tabular-nums; }

.options { display: grid; gap: 10px; margin: 16px 0; }
.options label {
    display: block; background: var(--surface); border: 2px solid var(--border); border-radius: 8px;
    padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s; color: var(--text);
}
.options label:hover { border-color: var(--primary); }
.options label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.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(--field-text);
    background: var(--field-bg); border: 1px solid var(--border); border-radius: 6px;
}
.open-answer input {
    width: 100%; padding: 12px; font-size: 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--field-bg); color: var(--field-text);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 3px solid #f59f6b; outline-offset: 1px;
}

button {
    background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: 6px;
    padding: 12px 20px; font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 14px;
}
button:hover { background: var(--primary-dark); border-color: 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 { position: static; flex: none; padding: 8px 16px; font-size: .9rem; }
body.player-page .brand { font-size: 1.05rem; }
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; border-color: var(--wrong) !important; background: rgba(255,107,107,.12); }
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 {
    display: inline-block; font-size: 1.6em; font-weight: 800; margin: .3em 0; padding: .15em .6em;
    color: var(--correct); background: rgba(91,209,122,.12); border: 2px solid var(--correct); border-radius: 8px;
}
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: var(--primary-soft); color: #fff; font-weight: 700; }
body.player-page table.leaderboard th, body.player-page table.leaderboard td { padding: .45em .4em; }

/* Teams: the "this team already exists" choice (register.php, team.php), the member list
   and join requests (team.php, and the captain's notice on the quiz screen). */
.team-choice { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface); border-left: 4px solid var(--primary); }
.team-choice p { margin: 0 0 6px; }
.auth-box .team-choice label { display: block; margin: 4px 0; font-weight: 400; }
.auth-box .team-choice input[type=radio] { width: auto; margin-right: 8px; accent-color: var(--primary); }
.team-list { list-style: none; padding: 0; margin: 0 0 12px; }
.team-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.team-list .tag { margin-left: 6px; }
.join-request { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--border); }
.join-request strong { flex: 1; display: inline-flex; align-items: center; gap: 8px; }
.join-request form { margin: 0; }
.join-request button { margin: 0; padding: 6px 12px; font-size: .9rem; }
body.player-page #joinRequests { flex: none; padding: 10px 16px; border: 2px solid var(--primary); }
.join-requests-title { margin: 0 0 4px; font-weight: 700; color: var(--heading); }

/* Auth pages: one card in the middle of the screen, orange line on top (as Music Twister) */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.auth-box {
    background: var(--panel); padding: 28px; border-radius: var(--radius); width: 100%; max-width: 420px;
    border: 1px solid var(--border); border-top: 6px solid var(--primary);
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.auth-box h1 { margin: 0 0 4px; font-size: 1.5rem; }
.auth-box h2 { font-size: 1.15rem; color: var(--muted); font-weight: 600; }
.auth-box label { display: block; margin: 14px 0 6px; font-size: .9rem; font-weight: 600; color: var(--text); }
.auth-box input {
    width: 100%; padding: 11px 12px; font-size: 16px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--field-bg); color: var(--field-text);
}
.auth-box button[type=submit] { width: 100%; margin-top: 18px; }
.auth-box a { color: var(--link); }
@media (max-width: 420px) {
    .auth-page { padding: 0; align-items: flex-start; }
    .auth-box { border-radius: 0; border-left: none; border-right: none; min-height: 100vh; min-height: 100dvh; }
}

/* 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; font-size: .85em; text-transform: uppercase; letter-spacing: .04em; }
table.leaderboard tbody tr:first-child td { color: var(--primary); font-weight: 800; }
/* Team mode: each teammate's points under their team. */
.lb-players { color: var(--muted); font-size: .9em; }
.lb-player { display: inline-flex; align-items: center; gap: 5px; margin: 0 12px 2px 0; white-space: nowrap; }
.lb-player strong { color: var(--text); }
.lb-name { display: inline-flex; align-items: center; gap: 8px; }

/* 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: rgba(232, 89, 12, .35); } 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: 80px; }
/* "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-jump button { background: var(--surface); border-color: var(--border); border-radius: 999px; color: var(--text); }
.round-jump button:hover { border-color: var(--primary); background: var(--primary-soft); }
.round-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    background: var(--surface); border-left: 4px solid var(--primary); border-bottom: 1px solid var(--border);
    border-radius: 8px; padding: 12px 10px; margin-top: 6px;
}
.round-header strong { color: var(--heading); 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; 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: 1px solid var(--primary);
    border-radius: 6px; font-weight: 700; display: inline-block;
}
.btn-row button:hover, .btn-row a.button:hover { background: var(--primary-dark); }
/* Danger: outlined in red, filled on hover (as Music Twister) */
.btn-danger { background: transparent !important; border: 1px solid var(--wrong) !important; color: var(--wrong) !important; }
.btn-danger:hover { background: var(--wrong) !important; color: #fff !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: 700; line-height: 1.4; border: 1px solid var(--primary);
    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: 700; }
.tag-live { background: rgba(91,209,122,.15); color: var(--correct); }
.tag-draft { background: var(--surface); color: var(--muted); }
.tag-category { background: var(--surface); color: var(--link); border: 1px solid var(--border); margin-bottom: 4px; }
.tag-finished { background: rgba(154,165,181,.15); color: var(--muted); }
.tag-speed { background: rgba(242,193,78,.15); color: var(--warn); display: inline-block; margin-bottom: 10px; }

.active-question {
    margin: 16px 0; padding: 18px 20px; border: 1px solid var(--border); border-left: 4px solid var(--primary);
    border-radius: var(--radius); 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: 80px; }
.active-question-row .active-question { margin-top: 0; }
tr.is-active-question td { background: var(--primary-soft); 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: 800; color: #3fd0e0; }
.active-question-text { font-size: 1.25rem; font-weight: 600; margin: 6px 0 12px; color: var(--heading); }
.active-question-media { display: block; max-width: 100%; max-height: 240px; border-radius: 8px; 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: 8px; padding: 10px 12px; }
.active-question-options li.is-correct { border-color: var(--correct); background: rgba(91,209,122,.12); color: var(--correct); font-weight: 700; }
.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; }

fieldset.question-content { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.question-content[disabled] { opacity: .55; }

.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(--link); 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(--heading); margin-bottom: 4px; }
.grading-question { font-size: 1.15rem; font-weight: 600; margin: 6px 0; }

/* Profile photo (includes/avatar.php): round; without a photo the first letter of the name,
   in orange on a dark tint (as Music Twister). */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle;
    background: color-mix(in srgb, var(--primary) 18%, var(--panel)); color: var(--primary);
    font-weight: 800; font-size: .85rem; line-height: 1;
}
.avatar-sm { width: 22px; height: 22px; font-size: .7rem; }
.avatar-md { width: 40px; height: 40px; font-size: 1.1rem; }
.avatar-lg { width: 120px; height: 120px; font-size: 3rem; }
.who-link { display: inline-flex; align-items: center; gap: 8px; color: #fff !important; padding: 3px 10px 3px 3px !important; border-radius: 999px !important; }
.who-link:hover .avatar { box-shadow: 0 0 0 2px var(--primary); }
/* profile page: click the photo to choose another one (a label of the file field) */
.avatar-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 22px; margin: 6px 0 10px; }
.avatar-pick { position: relative; display: inline-block; cursor: pointer; line-height: 0; }
.avatar-pick-icon {
    position: absolute; right: 2px; bottom: 2px; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff;
    border: 3px solid var(--panel); transition: transform .15s; font-size: 1rem; line-height: 1;
}
.avatar-pick:hover .avatar-pick-icon, .avatar-pick:focus-within .avatar-pick-icon { transform: scale(1.1); }
.avatar-pick:hover .avatar { box-shadow: 0 0 0 3px var(--primary); }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-actions form { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.avatar-actions label.btn-like {
    display: inline-block; padding: 10px 16px; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font-weight: 700; cursor: pointer; margin: 0;
}
.avatar-actions label.btn-like:hover { border-color: var(--muted); }
.avatar-actions button { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 14px; }
.flash-ok { background: rgba(91,209,122,.12); border-left: 4px solid var(--correct); }
.flash-error { background: rgba(255,107,107,.12); border-left: 4px solid var(--wrong); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
