* {
    box-sizing: border-box;
}

:root {
    --bg: #101417;
    --panel: #182026;
    --panel-2: #202a31;
    --text: #f5f7f8;
    --muted: #a7b2b9;
    --accent: #79c96b;
    --accent-dark: #4f9845;
    --danger: #e45d5d;
    --line: #34414a;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top, #1d2a31 0, transparent 38rem),
        var(--bg);
}

button {
    font: inherit;
}

.game-shell {
    width: 100%;
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
}

.game-card {
    width: min(100%, 860px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.6rem);
    line-height: 1;
}

.scores {
    display: flex;
    gap: 12px;
}

.score-box {
    min-width: 95px;
    padding: 12px 16px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    text-align: center;
}

.score-box span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.score-box strong {
    display: block;
    margin-top: 3px;
    font-size: 1.5rem;
}

.game-area {
    position: relative;
    width: calc(100% - 48px);
    margin: 0 24px;
    aspect-ratio: 1 / 1;
    max-height: 70vh;
    background: #0d1215;
    border: 2px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
        #0d1215;
    background-size: 5% 5%;
}

.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5, 8, 10, 0.62);
    backdrop-filter: blur(4px);
}

.overlay.hidden {
    display: none;
}

.overlay-panel {
    width: min(100%, 420px);
    padding: 28px;
    text-align: center;
    background: rgba(24, 32, 38, 0.96);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.overlay-panel h2 {
    margin: 0 0 10px;
    font-size: 2rem;
}

.overlay-panel p {
    margin: 0 0 22px;
    color: var(--muted);
    line-height: 1.5;
}

button {
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #0b120d;
    background: var(--accent);
    font-weight: 800;
    cursor: pointer;
    transition:
        transform 120ms ease,
        background 120ms ease,
        opacity 120ms ease;
}

button:hover:not(:disabled) {
    background: #91dc83;
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 20px 24px 24px;
}

.controls p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.controls p strong {
    color: var(--text);
}

.actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.actions button {
    color: var(--text);
    background: var(--panel-2);
    border-color: var(--line);
}

.actions button:hover:not(:disabled) {
    background: #2b3841;
}

.mobile-controls {
    display: none;
    padding: 0 24px 24px;
    text-align: center;
}

.mobile-controls > button,
.mobile-controls-row button {
    width: 58px;
    height: 52px;
    padding: 0;
    color: var(--text);
    background: var(--panel-2);
    border-color: var(--line);
}

.mobile-controls-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

@media (max-width: 680px) {
    .game-shell {
        padding: 10px;
    }

    .game-card {
        border-radius: 16px;
    }

    .game-header {
        align-items: flex-start;
        padding: 18px;
    }

    .scores {
        gap: 6px;
    }

    .score-box {
        min-width: 70px;
        padding: 8px 10px;
    }

    .score-box strong {
        font-size: 1.2rem;
    }

    .game-area {
        width: calc(100% - 24px);
        margin: 0 12px;
        max-height: none;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 16px 18px;
    }

    .actions {
        width: 100%;
    }

    .actions button {
        flex: 1;
    }

    .mobile-controls {
        display: block;
    }
}

@media (max-width: 430px) {
    .game-header {
        flex-direction: column;
    }

    .scores {
        width: 100%;
    }

    .score-box {
        flex: 1;
    }
}

/* Lien de retour vers le site, ajouté par-dessus le jeu. */
.retour-site {
    position: fixed;
    top: 10px;
    left: 12px;
    margin: 0;
    z-index: 10;
    font-size: 14px;
}
.retour-site a {
    color: inherit;
    opacity: 0.8;
}
.retour-site a:hover {
    opacity: 1;
    text-decoration: underline;
}
