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

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #eaeaea;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 1rem;
}

h1 {
    font-size: clamp(1.4rem, 5vw, 2.5rem);
    font-weight: 300;
    letter-spacing: clamp(0.15rem, 1.5vw, 0.5rem);
    color: #444;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    text-align: center;
}

h1::after {
    content: '';
    display: block;
    width: 60%;
    margin: 0.4rem auto 0;
    border-bottom: 1.5px solid #aaa;
}

.grid {
    --cell: clamp(80px, 28vw, 140px);
    display: grid;
    grid-template-columns: repeat(3, var(--cell));
    grid-template-rows: repeat(3, var(--cell));
    gap: 0;
    margin: 2rem 0 1.5rem;
}

.startbtn {
    width: var(--cell, 140px);
    height: var(--cell, 140px);
    background-color: #fff;
    border: 1.5px solid #ccc;
    font-size: clamp(1.6rem, 8vw, 3rem);
    font-weight: 300;
    cursor: pointer;
    transition: background-color 0.15s;
    outline: none;
    /* ensures tap targets are never cramped */
    touch-action: manipulation;
}

.startbtn:hover:not(:disabled) {
    background-color: #f5f5f5;
}

.startbtn:disabled {
    cursor: default;
}

.result {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: #555;
    letter-spacing: 0.05rem;
    min-height: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.reset {
    padding: 0.75rem 2.5rem;
    background-color: #fff;
    border: 1.5px solid #bbb;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    letter-spacing: 0.15rem;
    text-transform: uppercase;
    color: #555;
    cursor: pointer;
    transition: background-color 0.15s;
    outline: none;
    touch-action: manipulation;
}

.reset:hover {
    background-color: #f0f0f0;
}

/* Tablet */
@media (max-width: 480px) {
    .grid {
        margin: 1.25rem 0 1.25rem;
    }

    .reset {
        padding: 0.75rem 2rem;
        width: 100%;
        max-width: calc(3 * clamp(80px, 28vw, 140px));
    }
}

/* Landscape phones — prevent grid from being too tall */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        justify-content: flex-start;
        padding-top: 0.75rem;
    }

    h1 {
        font-size: 1.2rem;
        margin-bottom: 0.1rem;
    }

    .grid {
        --cell: clamp(60px, 18vh, 100px);
        margin: 0.75rem 0 0.75rem;
    }

    .result {
        margin-bottom: 0.75rem;
    }
}