:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #212529;
    background: #f8f9fa;
}

* {
    box-sizing: border-box;
}

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

.game-nav {
    margin-bottom: 0.7rem;
}

.game-nav a {
    display: inline-block;
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 4px 14px rgba(33, 37, 41, 0.14);
    color: #0069d9;
    font-weight: 700;
    text-decoration: none;
}

.game-nav a:hover {
    text-decoration: underline;
}

.tiletap-layout {
    width: min(100% - 2rem, 900px);
    margin: 0 auto;
    padding: 1.5rem 0 2.5rem;
}

.game-header {
    width: min(100%, 38rem);
    margin: 0 auto 1.5rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(33, 37, 41, 0.14);
    text-align: center;
}

.game-header h1 {
    margin: 0;
}

.game-header p {
    margin: 0.5rem auto 0;
    color: #495057;
}

.game-header .game-kicker {
    margin: 0 0 0.1rem;
    color: #0069d9;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

button,
input {
    font: inherit;
}

button {
    min-height: 44px;
    padding: 0.7rem 1.1rem;
    border: 1px solid #0069d9;
    border-radius: 8px;
    background: #007bff;
    color: #fff;
    cursor: pointer;
}

button:hover {
    background: #0069d9;
}

button:focus-visible,
input:focus-visible,
.gamebox:focus-visible {
    outline: 3px solid #80bdff;
    outline-offset: 2px;
}

.gameform {
    width: min(100%, 34rem);
    margin: 1rem auto;
    border: 1px solid #ced4da;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 6px 18px rgba(33, 37, 41, 0.08);
}

.gameform ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gameform li {
    margin: 1rem;
    text-align: center;
}

.gameform input {
    width: 6rem;
    margin-left: 0.5rem;
    padding: 0.6rem;
    border: 1px solid #868e96;
    border-radius: 8px;
}

.gamegridcontainer {
    display: none;
    flex-direction: column;
    align-items: center;
}

.gamegrid {
    display: grid;
    width: min(84vw, 32rem);
    aspect-ratio: 1;
    margin: 0 auto;
    border: 1px solid #212529;
    background: #fff;
}

.gamebox {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid #adb5bd;
    border-radius: 0;
    background: #fff;
    cursor: pointer;
}

.gamebox:hover {
    background: #e9ecef;
}

.gamebox:active {
    background: #ced4da;
}

.gamescore {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 1rem auto;
    border: 1px solid #ced4da;
    border-radius: 10px;
    background: #fff;
}

.gamescore div {
    padding: 0.75rem 1rem;
}

.actionbuttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

#countdownoverlay {
    position: fixed;
    inset: 0;
    display: none;
    background-color: rgba(0, 0, 0, 0.62);
    z-index: 1000;
}

#countdownoverlay > #countdownvalue {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 5rem;
    margin: 0;
    padding: 1rem;
    border-radius: 50%;
    background: #000;
    color: #fff;
    text-align: center;
    transform: translate(-50%, -50%);
}

#gameendedoverlay {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    background: #fff;
    transform: translate(-50%, -50%);
}

#countdownoverlay h2 {
    min-width: 8rem;
    margin: 0;
    padding: 1rem;
    color: #000;
    text-align: center;
}

.gamebox.highlight {
    background: #111;
}

.gamebox.bomb {
    background: #dc143c;
}

.gamebox.danger {
    background: #6c757d;
}

@media (max-width: 520px) {
    .tiletap-layout {
        width: min(100% - 1rem, 900px);
        padding-top: 1rem;
    }

    .game-header p {
        font-size: 0.9rem;
    }

    .gamegrid {
        width: min(92vw, 32rem);
    }

    .gamescore div {
        padding: 0.55rem 0.65rem;
        font-size: 0.9rem;
    }

    #gameendedoverlay {
        width: min(92vw, 24rem);
        flex-wrap: wrap;
        justify-content: center;
    }

    #gameendedoverlay h2 {
        order: -1;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
    }
}
