.tile {
    border: 1px solid black;
    display: inline-block;
    background-color: lightgray;
    text-align: center;
    width: 10px;
    height: 10px;
    position: absolute;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c);
}

#board {
    position: relative;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#board.hidden {
    display: none;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 18px;
    background: linear-gradient(90deg, rgba(32, 69, 104, 0.92), rgba(83, 159, 230, 0.9));
    border-bottom: 2px solid rgba(255, 248, 239, 0.35);
    color: #fff8ef;
    justify-content: space-between;
}

.hud-topline {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hud-compact-level {
    display: flex;
    align-items: center;
    gap: 10px;
}

#hud-level-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 248, 239, 0.12);
    font-weight: 700;
}

#hud-panel {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.hud-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hud-item {
    display: flex;
    flex-direction: column;
    min-width: 80px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 248, 239, 0.12);
}

.hud-best {
    min-width: 150px;
}

.hud-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 248, 239, 0.82);
}

.hud-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

#hud-toggle-button {
    display: none;
}

.icon-button,
#menu-leaderboard-button,
#leaderboard-close,
#submit-score-button,
#win-modal-close,
#confirm-cancel,
#confirm-accept {
    border: 1px solid #1c1c1c;
    border-radius: 999px;
    padding: 10px 18px;
    background: #ab4b7e;
    color: #ffffff;
    font: inherit;
    cursor: pointer;
}

.icon-button {
    width: 52px;
    height: 52px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 248, 239, 0.18);
}

.icon-button svg {
    width: 24px;
    height: 24px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#menu-leaderboard-button,
#leaderboard-close {
    background: #3f87a6;
}

#submit-score-button,
#win-modal-close,
#confirm-cancel {
    margin-left: 0;
}

.hud-danger-button {
    background: rgba(180, 60, 60, 0.2);
    color: #fff1f0;
}

.modal-danger-button {
    background: #b43c3c;
    color: #fff6f3;
}

#menu-leaderboard-button {
    margin-left: 0;
}

#leaderboard-close {
    margin-left: 0;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 24, 40, 0.55);
    z-index: 10;
}

.modal.hidden {
    display: none;
}

.modal-content {
    min-width: 280px;
    max-width: 420px;
    padding: 32px 28px;
    border: 2px solid #1c1c1c;
    border-radius: 18px;
    background: #fff8ef;
    text-align: center;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.modal-confirm {
    max-width: 380px;
}

.modal-content h1 {
    margin: 0 0 12px;
    font-size: 2rem;
}

.modal-content p {
    margin: 0 0 20px;
    font-size: 1.1rem;
}

#win-best-badge {
    display: inline-block;
    margin: 0 0 20px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #ab4b7e;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
}

#win-best-badge.hidden {
    display: none;
}

.modal-content button {
    cursor: pointer;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

#score-name-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#score-name {
    width: 100%;
    margin: 0 0 12px;
    padding: 12px 14px;
    box-sizing: border-box;
    border: 1px solid #1c1c1c;
    border-radius: 12px;
    font: inherit;
    text-transform: uppercase;
    text-align: center;
}

.modal-note {
    min-height: 1.2em;
    margin: 0 0 16px;
    font-size: 0.95rem;
}

.modal-note.error {
    color: #9c1a4d;
}

#leaderboard-status.hidden {
    display: none;
}

.menu-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.level-button {
    min-width: 110px;
}

.level-button[data-level="easy"] {
    background: #2f9e44;
}

.level-button[data-level="medium"] {
    background: #d4a017;
    color: #1f1600;
}

.level-button[data-level="hard"] {
    background: #c0392b;
}

#leaderboard-list {
    margin: 0 0 20px;
    padding-left: 24px;
    text-align: left;
}

#leaderboard-list.hidden {
    display: none;
}

#leaderboard-list li {
    margin-bottom: 10px;
}

html {
    font-family: 'Open Sans', sans-serif;
}

@media (max-width: 720px) {
    #hud {
        padding: 14px;
        align-items: stretch;
    }

    .hud-topline {
        display: flex;
    }

    #hud-toggle-button {
        display: inline-flex;
    }

    #hud-panel {
        display: none;
        padding-top: 4px;
    }

    #hud.hud-expanded #hud-panel {
        display: flex;
    }

    .hud-summary {
        width: 100%;
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
    }

    .hud-item {
        min-width: 100%;
    }

    .hud-best {
        min-width: 100%;
    }

    .hud-actions {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    .icon-button {
        flex: 1 1 0;
        max-width: none;
    }
}
