:root {
    --red: #8b1e24;
    --deep-red: #681318;
    --gold: #c69a43;
    --dark-gold: #95691e;
    --ivory: #fff8e9;
    --ink: #38231d;
    --jade: #527b67;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
    background-color: #d9b5a4;
    background-image:
        linear-gradient(
            135deg,
            rgba(255, 247, 229, 0.34),
            rgba(255, 240, 221, 0.16) 55%,
            rgba(90, 38, 28, 0.10)
        ),
        url("/assets/images/fond-sudoku-asiatique-sans-texte.webp");
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: scroll;
}

/* Le voile est intégré au fond du body. */
.page-overlay {
    display: none;
}

.app-container {
    position: relative;
    z-index: 1;
    width: min(100% - 32px, 1100px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 42px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero {
    width: 100%;
    text-align: center;
    margin-bottom: 26px;
}

.chinese-symbols {
    color: var(--dark-gold);
    font-size: clamp(2.2rem, 5vw, 3.7rem);
    letter-spacing: 0.2em;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.65);
}

h1 {
    margin: 12px 0 5px;
    color: var(--red);
    font-size: clamp(2.5rem, 6vw, 4.8rem);
    font-style: italic;
    font-weight: 700;
    text-shadow: 0 2px 3px rgba(255, 255, 255, 0.75);
}

.subtitle {
    margin: 8px 0;
    font-size: clamp(1rem, 2vw, 1.25rem);
}

.ornament {
    width: min(420px, 75%);
    margin: 24px auto 0;
    border-top: 1px solid var(--dark-gold);
    color: var(--dark-gold);
    line-height: 0;
}

.ornament span {
    position: relative;
    top: -13px;
    display: inline-block;
    padding: 0 18px;
    background: rgba(255, 246, 226, 0.72);
    font-size: 1.7rem;
}

.home-screen {
    width: min(100%, 790px);
    text-align: center;
    padding: 24px 28px 30px;
    border: 1px solid rgba(174, 125, 43, 0.65);
    border-radius: 24px;
    background: rgba(255, 248, 233, 0.78);
    box-shadow: 0 14px 40px rgba(65, 31, 23, 0.22);
    backdrop-filter: blur(7px);
}

.home-screen h2,
.game-heading h2 {
    margin: 0;
    color: var(--deep-red);
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.section-intro {
    margin: 8px 0 22px;
}

.difficulty-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.difficulty-card {
    min-height: 190px;
    padding: 17px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--ink);
    font-family: inherit;
    border: 2px solid #b98b37;
    border-radius: 19px;
    background: linear-gradient(145deg, #fff9ed, #f4dfb9);
    box-shadow:
        inset 0 0 0 4px rgba(255, 255, 255, 0.5),
        0 5px 12px rgba(80, 40, 20, 0.12);
    cursor: pointer;
    transition:
        transform 180ms ease,
        box-shadow 180ms ease,
        background 180ms ease;
}

.difficulty-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(80, 40, 20, 0.2);
}

.difficulty-card.selected {
    border: 3px solid var(--red);
    background: linear-gradient(145deg, #fffaf0, #f0d5a2);
    box-shadow:
        0 0 0 3px rgba(139, 30, 36, 0.13),
        0 8px 18px rgba(80, 40, 20, 0.18);
}

.difficulty-symbol {
    color: var(--red);
    font-size: 3rem;
    line-height: 1;
}

.difficulty-name {
    color: var(--deep-red);
    font-size: 1.45rem;
    font-weight: bold;
}

.difficulty-description {
    font-size: 0.9rem;
    line-height: 1.3;
}

.lotus {
    color: var(--dark-gold);
    font-size: 1.6rem;
}

.primary-button {
    min-width: min(100%, 390px);
    margin-top: 28px;
    padding: 17px 30px;
    color: #fff8e9;
    font-family: inherit;
    font-size: 1.45rem;
    font-weight: bold;
    border: 3px solid #e2bd67;
    border-radius: 50px;
    background: linear-gradient(180deg, #b52c31, #78151b);
    box-shadow:
        inset 0 2px 2px rgba(255, 255, 255, 0.25),
        0 7px 17px rgba(76, 20, 20, 0.3);
    cursor: pointer;
    transition: transform 180ms ease, filter 180ms ease;
}

.primary-button:hover {
    transform: translateY(-3px);
    filter: brightness(1.08);
}

.primary-button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.play-icon {
    margin-right: 12px;
    font-size: 1.05rem;
}

.status-message {
    min-height: 24px;
    margin: 16px 0 0;
    color: var(--deep-red);
    font-weight: bold;
}

.footer {
    margin-top: auto;
    padding-top: 28px;
    text-align: center;
    color: #fff8e9;
    text-shadow: 0 1px 4px rgba(50, 20, 15, 0.8);
}

.footer span {
    color: #f4d58d;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
}

.footer p {
    margin: 6px 0 0;
}

.hidden {
    display: none !important;
}

.game-screen {
    width: min(100%, 720px);
    padding: 24px;
    border: 1px solid rgba(174, 125, 43, 0.75);
    border-radius: 22px;
    background: rgba(255, 249, 237, 0.94);
    box-shadow: 0 14px 40px rgba(65, 31, 23, 0.25);
}

.game-heading {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.game-heading h2 {
    font-size: 1.5rem;
}

.game-heading p {
    margin: 5px 0 0;
}

.back-button {
    justify-self: start;
    padding: 9px 12px;
    border: 1px solid var(--gold);
    border-radius: 20px;
    color: var(--deep-red);
    background: #fff8e9;
    font-family: inherit;
    cursor: pointer;
}

.timer-panel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: end;
}

.timer-panel strong {
    color: var(--red);
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
}

.board-wrapper {
    width: min(100%, 510px);
    margin: 0 auto;
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    aspect-ratio: 1;
    border: 3px solid var(--deep-red);
    background: #fffdf6;
}

.sudoku-cell {
    min-width: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-right: 1px solid #b8a58a;
    border-bottom: 1px solid #b8a58a;
    background: transparent;
    color: #315b75;
    font-family: Arial, sans-serif;
    font-size: clamp(0.85rem, 3vw, 1.55rem);
    cursor: pointer;
}

.sudoku-cell:nth-child(3n) {
    border-right: 2px solid var(--deep-red);
}

.sudoku-cell:nth-child(9n) {
    border-right: 0;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--deep-red);
}

.sudoku-cell:nth-child(n+73) {
    border-bottom: 0;
}

.sudoku-cell.given {
    color: #38231d;
    font-weight: bold;
    cursor: default;
}

.sudoku-cell.selected-cell {
    background: #f2dca9;
    box-shadow: inset 0 0 0 2px var(--gold);
}

.sudoku-cell.related-cell {
    background: #f8edcf;
}

.sudoku-cell.same-number {
    background: #ead4a5;
}

.number-pad {
    width: min(100%, 510px);
    margin: 18px auto 0;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 5px;
}

.number-pad button {
    min-height: 44px;
    border: 1px solid #bd934b;
    border-radius: 9px;
    color: var(--deep-red);
    background: #fff7e6;
    font-size: 1.15rem;
    font-weight: bold;
    cursor: pointer;
}

.number-pad button:hover {
    background: #f0dfba;
}

.number-pad .erase-button {
    grid-column: span 9;
    font-size: 1rem;
}

@media (max-width: 650px) {
    .app-container {
        padding: 25px 8px 18px;
    }

    .home-screen {
        padding: 20px 12px 24px;
    }

    .difficulty-list {
        gap: 7px;
    }

    .difficulty-card {
        min-height: 155px;
        padding: 10px 5px;
    }

    .difficulty-symbol {
        font-size: 2.35rem;
    }

    .difficulty-name {
        font-size: 1.05rem;
    }

    .difficulty-description {
        font-size: 0.73rem;
    }

    .game-screen {
        padding: 14px 8px;
    }

    .game-heading {
        grid-template-columns: 1fr 1.5fr 0.8fr;
        gap: 5px;
    }

    .game-heading h2 {
        font-size: 1.15rem;
    }

    .back-button {
        padding: 7px;
        font-size: 0.8rem;
    }

    .sudoku-cell {
        font-size: clamp(0.75rem, 4.5vw, 1.25rem);
    }

    .number-pad {
        gap: 3px;
    }

    .number-pad button {
        min-height: 40px;
    }
}

@media (max-width: 380px) {
    .difficulty-description {
        display: none;
    }

    .difficulty-card {
        min-height: 125px;
    }
}


/* Présentation dédiée à l'écran de jeu */
.app-container:has(#game-screen:not(.hidden)) {
    justify-content: center;
    padding-top: 24px;
}

.app-container:has(#game-screen:not(.hidden)) > .hero {
    display: none;
}

