* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: Helvetica, Arial, sans-serif;
    background: #808080;
    color: #111;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(260px, 350px) minmax(320px, 1fr) minmax(300px, 400px);
    grid-template-areas: "scores game instructions";
    gap: clamp(16px, 2vw, 32px);
    align-items: start;
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: clamp(18px, 3vw, 40px);
}

.game-main,
#top_scores,
#how_to_play_container {
    min-width: 0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.game-main {
    grid-area: game;
    padding: clamp(14px, 2vw, 24px);
    background: rgba(243, 243, 223, 0.94);
    text-align: center;
}

#timer {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0 0 clamp(16px, 3vw, 28px);
    color: #111;
    font-family: "Courier New", monospace;
    font-size: clamp(2.6rem, 7vw, 5rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: clamp(2px, 0.7vw, 5px);
}

#game_area {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(306px, 100%);
    aspect-ratio: 1;
    margin: 0 auto;
    overflow: hidden;
    border: 2px solid #000;
    background: #000;
}

.number-block {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    aspect-ratio: 1;
    border: 1px solid rgb(0, 8, 56);
    background-color: #da916a;
    font-size: clamp(2.2rem, 12vw, 4.8rem);
    line-height: 1;
    text-align: center;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.void_class {
    cursor: not-allowed;
}

#game_controls {
    width: 100%;
    margin: 20px auto 0;
    text-align: center;
}

.reset_btn,
.backHome,
.backHome a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 18px;
    border: 0;
    border-radius: 10px;
    background-color: #1665cc;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.08rem;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}

.reset_btn:focus,
.backHome:focus {
    outline: 3px solid rgba(22, 101, 204, 0.35);
    outline-offset: 2px;
}

.backHome:hover,
.backHome a:hover {
    background-color: #92d3ff;
    color: rgb(35, 107, 159);
}

#top_scores,
#how_to_play_container {
    width: 100%;
    padding: clamp(16px, 2vw, 22px);
    background: #f3f3df;
}

#top_scores {
    grid-area: scores;
}

#how_to_play_container {
    grid-area: instructions;
}

#top_scores h2,
#how_to_play_container h2 {
    margin-bottom: 15px;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    line-height: 1.25;
    text-align: center;
}

#top_scores ul {
    list-style: none;
}

#top_scores li {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 9px 0;
    padding: 10px;
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.1);
    font-size: clamp(0.9rem, 1.7vw, 1.1rem);
}

#top_scores .rank {
    flex: 0 0 40px;
    font-weight: 700;
    text-align: center;
}

#top_scores .player_name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 700;
    text-align: left;
}

#top_scores .score_time {
    flex: 0 0 auto;
    min-width: 55px;
    color: #333;
    font-family: "Courier New", monospace;
    text-align: right;
}

.medal {
    display: block;
    width: 34px;
    height: auto;
    margin: auto;
}

#how_to_play_container ol,
#how_to_play_container ul {
    padding-left: 22px;
}

#how_to_play_container li {
    margin-bottom: 9px;
    font-size: clamp(0.95rem, 1.7vw, 1.05rem);
    line-height: 1.45;
    text-align: left;
}

@media (max-width: 1099px) {
    .game-layout {
        grid-template-columns: minmax(0, 680px);
        grid-template-areas:
            "game"
            "scores"
            "instructions";
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .game-layout {
        gap: 14px;
        padding: 12px;
    }

    .game-main,
    #top_scores,
    #how_to_play_container {
        border-radius: 9px;
    }

    #top_scores li {
        padding: 9px 8px;
    }

    #top_scores .rank {
        flex-basis: 34px;
    }

    .medal {
        width: 30px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
