/* ---- colours and sizes */

:root {
    --bg: #f4f1ec;
    --surface: #ffffff;
    --field: #faf8f5;
    --text: #1b1a22;
    --muted: #686675;
    --border: #e3ded5;
    --accent: #c2410c;
    --accent-soft: #fdebe0;
    --error: #b91c1c;
    --ok: #15803d;
    --warn: #b45309;
    /* The main buttons: white text reads on both ends, in the light and in the dark. */
    --primary: linear-gradient(135deg, #c2410c, #be185d);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
    --shadow: 0 1px 2px rgb(27 26 34 / 0.05), 0 8px 24px rgb(27 26 34 / 0.06);
    --radius: 16px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121118;
        --surface: #1c1a25;
        --field: #15141c;
        --text: #eeedf3;
        --muted: #a3a0b3;
        --border: #302d3e;
        --accent: #fb923c;
        --accent-soft: #3a2418;
        --error: #f87171;
        --ok: #4ade80;
        --warn: #fbbf24;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    }
}

/* ---- the page */

* { box-sizing: border-box; }
/* The pages hide parts of themselves with the hidden attribute; a display rule must never show them. */
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 10px 24px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--text);
}
.logo { width: 30px; height: 30px; flex: none; }
.logo rect { fill: #c2410c; }
.logo path { stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }

/* On a small screen a menu of several pages folds behind a button: a checkbox, so that it opens without any
   script. A menu with nothing but the game has no button: the name of the application leads to the game. */
.menu-toggle { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.menu-button { display: none; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav form { margin: 0; }
.topbar nav a {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}
.topbar nav a:hover { color: var(--text); background: var(--field); }
.topbar nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.who { color: var(--muted); margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--border); }
.topbar nav button.link { margin-left: 8px; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 24px auto; padding: 0 16px; display: grid; gap: 16px; align-content: start; }
main > * { min-width: 0; }  /* a wide table scrolls in its card instead of widening the page */
.table-wrap { overflow-x: auto; }
h2.spaced { margin-top: 20px; }
form.spaced { margin-top: 12px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.narrow { max-width: 400px; margin: 40px auto; width: 100%; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.inline { display: flex; gap: 8px; }

h1, h2 { margin: 0 0 12px; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

footer { text-align: center; color: var(--muted); padding: 24px; font-size: 0.8rem; }

/* ---- forms and buttons */

label { display: grid; gap: 4px; font-weight: 600; }

input, select, textarea, button {
    font: inherit;
    color: inherit;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--field);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
    border-color: var(--accent);
    border-radius: 10px;
}
input[type="checkbox"], input[type="radio"], input[type="range"] { padding: 0; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; flex: none; }
::placeholder { color: var(--muted); opacity: 0.8; }

button, a.button {
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    transition: filter 0.12s, transform 0.06s;
}
a.button { display: inline-block; padding: 9px 16px; text-decoration: none; }
button:hover:not([disabled]), a.button:hover { filter: brightness(1.1); }
button:active:not([disabled]), a.button:active { transform: translateY(1px); }
button:focus-visible, a.button:focus-visible { border-radius: 10px; }
button.secondary { background: var(--field); color: var(--text); border-color: var(--border); }
button.secondary:hover:not([disabled]) { filter: none; border-color: var(--muted); }
button.danger { background: var(--error); color: #fff; }
@media (prefers-color-scheme: dark) {
    button.danger { background: #b91c1c; }
}
button.link { background: none; color: var(--accent); padding: 0; border: none; font-weight: 400; text-decoration: underline; text-underline-offset: 2px; }
button.big { font-size: 1.2rem; padding: 14px 32px; border-radius: 14px; justify-self: start; min-height: 56px; }
/* What cannot be pressed now is flat, grey and dashed: no colour left to call the eye. */
button[disabled] {
    cursor: not-allowed;
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    opacity: 0.7;
}

fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; display: grid; gap: 8px; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 6px; }
legend .muted { font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
fieldset.plain { border: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.tags { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; margin-bottom: 8px; }
.filters { flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type="search"] { min-width: 220px; flex: 1; }
.actions { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.actions button, .controls button { white-space: nowrap; }
.selection > .actions { margin-bottom: 8px; }
.durations { flex-wrap: wrap; gap: 16px; }
.durations input { width: 12em; }

details > summary { cursor: pointer; color: var(--accent); }

/* ---- tables and what they show */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--field) 70%, transparent); }
td.source { word-break: break-all; max-width: 320px; }
tr.excluded td { opacity: 0.55; }

.cover { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; }
audio { height: 32px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
ul.error { margin: 0 0 12px; padding: 10px 14px 10px 32px; border-radius: 10px; background: color-mix(in srgb, var(--error) 10%, transparent); }
.status-resolved { color: var(--ok); }
.status-failed { color: var(--error); }
.status-pending, .status-leased { color: var(--muted); }

.badge { display: inline-block; background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 12px; font-size: 0.85rem; font-weight: 600; }
.muted-badge { background: var(--border); color: var(--muted); }

.score { display: inline-block; min-width: 2.5em; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 6px; color: #fff; }
.score-high { background: #15803d; }
.score-mid { background: #b45309; }
.score-low { background: #686675; }

.pages { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 12px; }

/* ---- the page of a track */

.track-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.track-head p { margin: 0; }
.cover-large { width: 160px; height: 160px; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow); }

.timeline { display: flex; height: 32px; margin: 8px 0 20px; border-radius: 8px; overflow: hidden; gap: 2px; }
.section {
    min-width: 0;
    padding: 6px 4px;
    font-size: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #fff;
    background: #8a8a90;
}
.section-intro, .section-outro { background: #6b7280; }
.section-verse { background: #2563eb; }
.section-chorus { background: #c2410c; }
.section-bridge, .section-break { background: #7c3aed; }
.section-inst, .section-solo { background: #0f766e; }
.section-start, .section-end { background: var(--border); color: var(--muted); }

table.passages td { vertical-align: middle; }
table.passages audio { width: 100%; min-width: 150px; }
table.passages td:nth-child(n + 3):nth-child(-n + 5) { width: 20%; }

/* ---- a new game: every choice is a pill to tick, with a finger or a mouse */

.setup-head p { margin: 0 0 8px; }
fieldset.choice { border: none; padding: 0; gap: 10px; }
fieldset.choice legend { padding: 0; margin-bottom: 8px; }
fieldset.choice > p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips > p { margin: 0; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 14px 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--field);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.12s, background 0.12s;
}
.chip:hover, .level:hover { border-color: var(--muted); }
.chip:has(input:checked), .level:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.chip:has(input:focus-visible), .level:has(input:focus-visible) { box-shadow: var(--ring); }
.chip input:focus-visible, .level input:focus-visible { box-shadow: none; }

.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.level {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--field);
    font-weight: 400;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.level input { grid-row: 1 / span 3; align-self: start; margin-top: 3px; }
.level strong { font-size: 1.05rem; }
.level-time { color: var(--accent); font-weight: 600; font-size: 0.85rem; }

/* The launch stays in reach under a long list of themes. */
.launch {
    position: sticky;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

/* ---- the game: a dark stage, read from the other end of the room, in the light as in the dark */

@property --progress {
    syntax: "<number>";
    inherits: true;
    initial-value: 0;
}

@property --glow {
    syntax: "<color>";
    inherits: true;
    initial-value: #7c2d92;
}

.game {
    --surface: #17141f;
    --field: rgb(255 255 255 / 0.07);
    --text: #f5f3fa;
    --muted: #b4afc6;
    --border: rgb(255 255 255 / 0.16);
    --accent: #fdba74;
    --accent-soft: rgb(251 146 60 / 0.16);
    --glow: #7c2d92;
    display: grid;
    padding: clamp(20px, 4vw, 40px);
    border: none;
    color: var(--text);
    color-scheme: dark;
    background:
        radial-gradient(90% 70% at 50% -10%, color-mix(in srgb, var(--glow) 55%, transparent), transparent 70%),
        radial-gradient(60% 50% at 100% 100%, rgb(194 65 12 / 0.22), transparent 70%),
        #13111b;
    transition: --glow 0.6s;
}
.game:has(.stage[data-phase="answer"]) { --glow: #0f766e; }

.intro { display: grid; justify-items: center; gap: 20px; padding: clamp(24px, 8vh, 80px) 0; text-align: center; }
.intro h1, .intro h2 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); }
.intro p { margin: 0; }
.intro button.big { justify-self: center; font-size: 1.4rem; padding: 18px 44px; }
.summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
.summary li { padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--field); color: var(--muted); }

.stage { display: grid; gap: 20px; }
.stage-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.position { font-size: 1.1rem; letter-spacing: 0.08em; text-transform: uppercase; }
.stage-theme { color: var(--muted); margin-right: auto; }
.stage-theme:not(:empty)::before { content: "· "; }

.scene {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px 40px;
    min-height: min(46vh, 420px);
}

/* The time left: a ring that fills, the seconds in its middle. */
.dial {
    --size: clamp(220px, 38vh, 340px);
    --thick: 14px;
    position: relative;
    flex: none;
    width: var(--size);
    aspect-ratio: 1;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 6px;
    transition: --progress 0.12s linear, opacity 0.2s;
}
.dial::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(#fb923c, #ec4899 calc(var(--progress) * 360deg), rgb(255 255 255 / 0.1) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
    mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
}
.countdown { font-size: calc(var(--size) * 0.42); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.dial-label { color: var(--muted); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.12em; }
.dial-label span { display: none; }
.stage[data-phase="listen"] .when-listen,
.stage[data-phase="answer"][data-kept="false"] .when-answer,
.stage[data-kept="true"] .when-kept { display: inline; }

.bars { display: flex; align-items: flex-end; gap: 5px; height: calc(var(--size) * 0.1); }
.bars i { width: 6px; height: 100%; border-radius: 3px; background: #fb923c; transform-origin: bottom; animation: beat 0.9s ease-in-out infinite alternate; }
.bars i:nth-child(2) { animation-delay: -0.35s; animation-duration: 0.7s; }
.bars i:nth-child(3) { animation-delay: -0.6s; animation-duration: 1.1s; }
.bars i:nth-child(4) { animation-delay: -0.2s; animation-duration: 0.8s; }
.bars i:nth-child(5) { animation-delay: -0.5s; animation-duration: 1s; }
@keyframes beat { from { transform: scaleY(0.2); } to { transform: scaleY(1); } }

/* Once answered, the ring steps aside: small, quiet, counting what is left before the next track. */
.stage[data-phase="answer"] .dial, .stage[data-phase="over"] .dial { --size: 132px; --thick: 8px; gap: 2px; }
.stage[data-phase="answer"] .dial::before, .stage[data-phase="over"] .dial::before {
    background: conic-gradient(#2dd4bf calc(var(--progress) * 360deg), rgb(255 255 255 / 0.1) 0);
}
.stage[data-phase="answer"] .countdown, .stage[data-phase="over"] .countdown { font-size: 2.25rem; }
.stage[data-phase="answer"] .dial-label, .stage[data-phase="over"] .dial-label { font-size: 0.62rem; letter-spacing: 0.08em; }
.stage[data-phase="answer"] .bars, .stage[data-phase="over"] .bars { display: none; }
.stage.paused .dial { opacity: 0.45; }
.stage.paused .bars i { animation-play-state: paused; }

.answer { flex: 1 1 420px; display: flex; gap: 28px; align-items: center; flex-wrap: wrap; animation: appear 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.answer-text { flex: 1 1 260px; min-width: 0; }
.answer h2 { font-size: clamp(2rem, 5vw, 3.5rem); margin: 0; overflow-wrap: anywhere; }
.answer p { margin: 8px 0 0; font-size: clamp(1.25rem, 2.6vw, 2rem); }
.answer p:empty { display: none; }
.cover-answer { width: clamp(180px, 32vh, 300px); aspect-ratio: 1; object-fit: cover; border-radius: 16px; box-shadow: 0 20px 50px rgb(0 0 0 / 0.5); }
@keyframes appear { from { opacity: 0; transform: translateY(14px) scale(0.97); } }

.message { min-height: 1.5em; margin: 0; text-align: center; color: var(--muted); }
.stage.paused .message { color: var(--text); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* The buttons, grouped by the moment they serve; a group whose moment is not now fades with its buttons. */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 26px 10px 10px; position: relative; border: 1px solid var(--border); border-radius: 14px; transition: opacity 0.2s; }
.group-title { position: absolute; top: 6px; left: 12px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.controls button { min-height: 48px; padding: 9px 16px; font-size: 1.05rem; touch-action: manipulation; }
.controls button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.controls button[data-action="keep"][aria-pressed="true"]::before { content: "✓ "; }
.stage[data-phase="answer"] .group-listen,
.stage[data-phase="over"] .group-listen,
.stage[data-phase="listen"] .group-answer,
.stage[data-phase="over"] .group-answer { opacity: 0.5; border-style: dashed; }
.controls .volume { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--muted); margin-left: auto; min-height: 48px; }
.controls .volume input { width: 140px; }

kbd {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: 6px;
    font: 600 0.7rem/1.5 system-ui, sans-serif;
    opacity: 0.6;
    vertical-align: 2px;
}
/* No keyboard on a phone or a tablet: the shortcuts would only take room. */
@media (hover: none) and (pointer: coarse) {
    kbd { display: none; }
}

@media (max-width: 640px) {
    .topbar { padding: 10px 16px; }
    .card { padding: 16px; }
    .menu-button {
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        color: var(--muted);
        cursor: pointer;
    }
    .menu-button path { stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
    .menu-toggle:checked + .menu-button { color: var(--accent); background: var(--accent-soft); }
    .menu-toggle:focus-visible + .menu-button { box-shadow: var(--ring); }
    .menu-toggle ~ nav { display: none; }
    .menu-toggle:checked ~ nav {
        display: grid;
        flex-basis: 100%;
        justify-content: stretch;
        gap: 2px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }
    .menu-toggle ~ nav a { padding: 10px 12px; border-radius: 10px; }
    .menu-toggle ~ nav .who { margin: 8px 0 0; padding: 10px 12px 0; border-left: none; border-top: 1px solid var(--border); font-size: 0.85rem; }
    .menu-toggle ~ nav button.link { margin: 0; padding: 10px 12px; text-align: left; }
    .group { flex: 1 1 100%; }
    .group button { flex: 1 1 auto; }
    .controls .volume { margin-left: 0; flex: 1 1 100%; }
    .controls .volume input { flex: 1; width: auto; }
    .launch { position: static; }
    .launch button.big { width: 100%; }
}

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

/* Full screen, offered where the browser allows it (lot 12). */
.controls .fullscreen { min-height: 48px; }
@media (max-width: 640px) {
    .controls .fullscreen { flex: 1 1 100%; }
}

/* The saved games of the device (page « Hors ligne », lot 13). */
.offline-save .durations { align-items: flex-end; }
.shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.shelf li { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; }
.shelf p { margin: 0; color: var(--muted); }
.shelf .actions button { min-height: 44px; padding: 8px 18px; touch-action: manipulation; }
