:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2933;
    background: #f2f4f7;
}

* {
    box-sizing: border-box;
}

/*
 * button, .button { display: inline-flex } plus bas dans ce fichier est une
 * règle de l'auteur, qui l'emporte toujours sur la règle du navigateur
 * [hidden] { display: none }, quelle que soit la spécificité. Sans cette
 * règle, un bouton avec l'attribut hidden restait visible malgré tout —
 * c'est ce qui rendait "Installer" et "Plein écran" toujours visibles.
 */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
}

.auth-shell,
.page-shell {
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
    padding: 24px;
}

.panel {
    width: min(100%, 520px);
    background: #fff;
    border: 1px solid #d9e0e7;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #d9e0e7;
}

form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 650;
}

input {
    min-height: 44px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #aeb8c2;
    border-radius: 8px;
    font: inherit;
}

button,
.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    background: #2457c5;
    color: #fff;
}

.button-secondary {
    background: #4b5563;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
}

.alert-error {
    background: #feecec;
    color: #8b1e1e;
    border: 1px solid #f3b7b7;
}

.muted {
    color: #697786;
}

.invite-link-row {
    display: flex;
    gap: 8px;
}

.invite-link-row input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border, #d9e0e7);
    border-radius: 8px;
    font: inherit;
    background: var(--panel-bg, #fff);
    color: var(--text, #1f2933);
}

@media (max-width: 600px) {
    .panel {
        padding: 20px;
    }

    .topbar {
        padding: 0 16px;
    }
}


select {
    min-height: 44px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #aeb8c2;
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.checkbox-label {
    grid-template-columns: auto 1fr;
    align-items: center;
    font-weight: 500;
}

.checkbox-label input {
    width: 20px;
    min-height: 20px;
}

.alert-success {
    background: #e8f6ec;
    color: #17622d;
    border: 1px solid #a9dbb7;
}

.preferences-panel {
    width: min(100%, 640px);
}


.home-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 18px 0;
}

.wide-shell {
    max-width: 1000px;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #dfe5ea;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f4f6f8;
}


.move-timeline {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.move-card {
    border: 1px solid #d9e0e7;
    border-radius: 10px;
    padding: 14px 16px;
    background: #fff;
}

.move-card header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #edf1f4;
    padding-bottom: 8px;
    margin-bottom: 8px;
}


:root {
    --page-bg: #f4f6f8;
    --panel-bg: #ffffff;
    --text: #1f2933;
    --muted: #5f6c78;
    --border: #d9e0e7;
    --accent: #2457c5;
    --accent-text: #ffffff;
}

body {
    background: var(--page-bg);
    color: var(--text);
}

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

a:visited {
    color: var(--accent);
}

a:hover,
a:focus-visible {
    text-decoration-thickness: 2px;
}

.panel,
.move-card,
.stat-card {
    background: var(--panel-bg);
    border-color: var(--border);
}

body[data-theme="dark"] {
    --page-bg: #11161d;
    --panel-bg: #1b232d;
    --text: #edf2f7;
    --muted: #b8c2cc;
    --border: #384554;
    --accent: #79a7ff;
    --accent-text: #07101d;
}

body[data-theme="wood"] {
    --page-bg: #12241c;
    --panel-bg: #1e140c;
    --text: #f4ecd8;
    --muted: #c9b9a0;
    --border: #8a6a34;
    --accent: #c9a35d;
    --accent-text: #241810;
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    background:
        radial-gradient(ellipse at 50% -10%, #24463a 0%, #173226 45%, #0f221a 100%);
}

body[data-theme="wood"] .topbar {
    background: linear-gradient(180deg, #22150e, #1a100b);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

body[data-theme="wood"] .topbar strong,
body[data-theme="wood"] .score-card h1,
body[data-theme="wood"] h1 {
    font-family: var(--font-display);
    letter-spacing: .02em;
}

body[data-theme="wood"] .panel,
body[data-theme="wood"] .move-card,
body[data-theme="wood"] .stat-card {
    background: linear-gradient(155deg, #3a281a, #1e140c);
    border-color: var(--border);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}

body[data-theme="wood"] button,
body[data-theme="wood"] .button {
    background: linear-gradient(180deg, var(--accent), #8a6a34);
    color: var(--accent-text);
    border: 1px solid #e8c877;
    box-shadow: 0 4px 10px rgba(201, 163, 93, .3);
}

body[data-theme="wood"] .button-secondary,
body[data-theme="wood"] .button-light {
    background: linear-gradient(180deg, #4a3220, #2a1b10);
    color: var(--accent);
    border: 1px solid var(--border);
    box-shadow: none;
}

body[data-theme="wood"] input,
body[data-theme="wood"] select {
    background: #241810;
    color: var(--text);
    border-color: var(--border);
}

body[data-theme="wood"] .alert {
    background: linear-gradient(155deg, #25211a, #1a1712);
    border: 1px solid rgba(201, 163, 93, .3);
}

body[data-theme="wood"] .alert-error {
    background: #3a1a1a;
    color: #f5b8b8;
    border-color: #7a2e2b;
}

body[data-theme="wood"] .alert-success {
    background: #16301f;
    color: #b7e0c4;
    border-color: #2f6b46;
}

body[data-theme="wood"] th {
    background: #241810;
    color: var(--accent);
}

body[data-theme="wood"] th,
body[data-theme="wood"] td {
    border-bottom-color: var(--border);
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] dialog {
    background: #111820;
    color: var(--text);
    border-color: var(--border);
}

body[data-high-contrast="true"] {
    --border: currentColor;
}

body[data-high-contrast="true"] a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 14px;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    gap: 6px;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

input[type="file"] {
    min-height: 48px;
    padding: 10px;
}


.replay-controls {
    display: grid;
    grid-template-columns: auto auto minmax(120px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}

.replay-description {
    text-align: center;
    font-weight: 700;
    min-height: 1.5em;
}

.replay-board {
    max-width: 720px;
    margin-inline: auto;
}

@media (max-width: 720px) {
    .replay-controls {
        grid-template-columns: repeat(2, 1fr);
    }

    .replay-controls input[type="range"] {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}


.quality-excellent { font-weight: 800; }
.analysis-summary { margin-block: 1rem; }
table td { vertical-align: top; }


html {
    color-scheme: light;
}

body[data-theme="dark"] {
    color-scheme: dark;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

button {
    touch-action: manipulation;
}

.offline-panel {
    max-width: 520px;
    margin: 12vh auto 0;
    text-align: center;
}

.offline-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #f1d398;
    border: 2px solid #8c6a3c;
    color: #1f2933;
    font-size: 2.8rem;
    font-weight: 850;
    box-shadow: 0 8px 20px rgb(0 0 0 / 16%);
}

@media (display-mode: standalone) {
    [data-install-app] {
        display: none !important;
    }
}


.app-footer {
    padding: 20px;
    text-align: center;
    opacity: .68;
    font-size: .9rem;
}


.button-light {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.logout-panel {
    text-align: center;
    max-width: 470px;
}

.logout-panel h1 { margin-bottom: .5rem; }
.logout-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #f3e8ff;
    color: #6d28d9;
    font-size: 2rem;
    font-weight: 800;
}
.logout-actions { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:24px; }
.logout-actions form { margin:0; }
.logout-actions button,.logout-actions .button { width:100%; }
@media (max-width:480px) { .logout-actions { grid-template-columns:1fr; } }


.auth-secondary {
    margin: 18px 0 0;
    text-align: center;
}

.auth-secondary a {
    font-weight: 700;
}
