/* Global Styles */
:root {
    /* Light theme variables */
    --bg-color: #f5f5f5;
    --text-color: #333;
    --tile-bg: #fff;
    --tile-text: #000;
    --tile-border: #ddd;
    --header-bg: #e0e0e0;
    --button-bg: #DAA520;
    --button-text: #1a1a1a;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --modal-content-bg: #fff;
}

[data-theme="dark"] {
    /* Dark theme variables */
    --bg-color: #222;
    --text-color: #f5f5f5;
    --tile-bg: #333;
    --tile-text: #fff;
    --tile-border: #555;
    --header-bg: #1a1a1a;
    --button-bg: #C8960C;
    --button-text: #1a1a1a;
    --modal-bg: rgba(0, 0, 0, 0.75);
    --modal-content-bg: #2a2a2a;
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    background-color: var(--header-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    margin: 0;
}

button {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: filter 0.15s;
}

button:hover {
    filter: brightness(1.12);
}

button:active {
    filter: brightness(0.9);
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.2rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--tile-border);
    color: var(--text-color);
    font-weight: 400;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    filter: none;
}

.error-msg {
    color: #e05050;
    font-size: 0.85rem;
    margin-top: 6px;
    min-height: 1.2em;
}

/* Game Container Styles */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

#puzzle-container {
    width: min(400px, calc(100vw - 40px));
    height: min(400px, calc(100vw - 40px));
    position: relative;
}

.game-info {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 1rem;
}

/* Leaderboard Styles */
.leaderboard-section {
    background-color: var(--header-bg);
    padding: 20px;
    border-radius: 8px;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.leaderboard-header h2 {
    margin: 0;
}

#refresh-leaderboard-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#refresh-leaderboard-btn:hover {
    transform: rotate(180deg);
}

.leaderboard-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--tile-border);
}

th {
    background-color: var(--button-bg);
    color: var(--button-text);
}

tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--modal-content-bg);
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
}

.modal h2 {
    margin-bottom: 15px;
}

.player-name-input {
    margin: 20px 0;
}

.player-name-input input {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--tile-border);
    border-radius: 4px;
    background-color: var(--tile-bg);
    color: var(--text-color);
}

#win-message {
    margin: 15px 0;
    font-weight: bold;
    font-size: 1.1em;
}

#submit-score-btn,
#save-name-btn,
#continue-btn {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
}

/* Remove debug display styles */
#debug-tiles-display {
    display: none;
}

@media (max-width: 768px) {
    #debug-tiles-display > div {
        flex-direction: column;
    }
}

/* WebGL Error Styles */
.webgl-error {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 400px;
    background-color: var(--header-bg);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.error-content {
    max-width: 600px;
}

.webgl-error h2 {
    color: #f44336;
    margin-bottom: 20px;
}

.webgl-error p {
    margin-bottom: 15px;
    line-height: 1.5;
}

/* Mobile styles */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 6px;
    }

    h1 {
        font-size: 1.1rem;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1.05rem;
    }

    .header-row {
        gap: 6px;
    }

    .game-info {
        justify-content: space-between;
        gap: 0;
        font-size: 0.8rem;
    }

    .game-container {
        margin-bottom: 16px;
    }

    .leaderboard-section {
        padding: 12px;
    }

    th, td {
        padding: 7px 5px;
        font-size: 0.85rem;
    }
}