* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100dvh;
    padding: 10px;
    font-family: 'Arial', sans-serif;
    touch-action: manipulation;
}

#game-container {
    background: #c0c0c0;
    border-top: 3px solid #fff;
    border-left: 3px solid #fff;
    border-right: 3px solid #808080;
    border-bottom: 3px solid #808080;
    padding: 6px;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
}

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #c0c0c0;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    padding: 4px 6px;
}

.lcd-display {
    background: #000;
    color: #f00;
    font-family: 'Courier New', monospace;
    font-size: 28px;
    font-weight: bold;
    padding: 2px 4px;
    min-width: 58px;
    text-align: right;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    letter-spacing: 2px;
    line-height: 1;
}

#face-button {
    width: 36px;
    height: 36px;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#face-button:active {
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

#board {
    display: block;
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -ms-user-select: none;
}

.header-btn {
    width: 36px;
    height: 36px;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.header-btn:active {
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

.header-btn.active {
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    background: #a0a0a0;
}

#advice-btn.blocked {
    animation: advice-pulse 1s ease-in-out infinite;
}

@keyframes advice-pulse {
    0%, 100% { background: #c0c0c0; }
    50% { background: #ffb0b0; }
}

.header-group {
    display: flex;
    gap: 4px;
}

#seed-wrapper,
#difficulty-wrapper {
    position: relative;
}

#seed-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    padding: 4px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#seed-menu.hidden {
    display: none;
}

#seed-input {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 4px 6px;
    border: 1px solid #808080;
    text-align: center;
    letter-spacing: 1px;
    width: 100px;
}

#difficulty-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    padding: 2px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#difficulty-menu.hidden {
    display: none;
}

.diff-btn,
.menu-btn {
    background: #c0c0c0;
    border: none;
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Arial', sans-serif;
    text-align: left;
    white-space: nowrap;
}

.diff-btn:hover,
.menu-btn:hover {
    background: #000080;
    color: #fff;
}

.diff-btn.active {
    font-weight: bold;
}

/* Leaderboard overlay */
#leaderboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

#leaderboard-dialog {
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    min-width: 320px;
    max-width: 90vw;
}

#leaderboard-titlebar {
    background: #000080;
    color: #fff;
    padding: 3px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: bold;
}

#leaderboard-close {
    background: #c0c0c0;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    border-right: 1px solid #808080;
    border-bottom: 1px solid #808080;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#leaderboard-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 6px 0;
}

.lb-tab {
    background: #c0c0c0;
    border: 1px solid #808080;
    border-bottom: none;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: 'Arial', sans-serif;
}

.lb-tab.active {
    background: #c0c0c0;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    border-right: 1px solid #808080;
    font-weight: bold;
    position: relative;
    top: 1px;
    padding-bottom: 5px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
    font-family: 'Arial', sans-serif;
    border: 1px solid #808080;
    margin: 0 6px 6px;
    width: calc(100% - 12px);
}

#leaderboard-table th {
    background: #c0c0c0;
    border-bottom: 1px solid #808080;
    padding: 4px 8px;
    text-align: left;
    font-size: 12px;
}

#leaderboard-table td {
    padding: 3px 8px;
    background: #fff;
    border-bottom: 1px solid #dfdfdf;
}

#leaderboard-table tr.highlight td {
    background: #ffffa0;
    font-weight: bold;
}

@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    #game-container {
        border-width: 2px;
        padding: 2px;
        gap: 3px;
        width: 100%;
    }

    #board {
        align-self: center;
    }

    #header {
        border-width: 1px;
        padding: 2px 4px;
    }

    #board {
        border-width: 2px;
    }

    .lcd-display {
        font-size: 22px;
        min-width: 48px;
        border-width: 1px;
    }

    #face-button,
    .header-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
        border-width: 1px;
    }
}
