/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 3px solid var(--primary-accent);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    position: relative;
}

.header-left,
.header-right {
    display: flex;
    gap: 8px;
    flex: 1;
}

.header-right {
    justify-content: flex-end;
}

h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
    flex: 1;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: var(--bg-secondary);
}

/* Tooltips */
.icon-btn {
    position: relative;
}

.icon-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.icon-btn[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.icon-btn[data-tooltip]:hover::before,
.icon-btn[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Practice button special styling */
#practice-header-btn {
    color: var(--primary-accent);
}

#practice-header-btn:hover {
    background-color: rgba(228, 0, 124, 0.1);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 16px;
}

.game-container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

/* Game Board */
.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    padding: 10px;
    width: 350px;
    max-width: 100%;
    margin: 0 auto;
    min-height: 420px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.tile {
    width: 100%;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    text-transform: uppercase;
    border: 2px solid var(--tile-border);
    border-radius: 6px;
    background-color: var(--tile-bg);
    color: var(--tile-text);
    user-select: none;
    transition: transform 0.1s ease;
}

.tile.filled {
    border-color: var(--text-secondary);
    animation: pop 0.1s ease;
}

/* Tile States */
.tile.correct {
    background-color: var(--correct);
    border-color: var(--correct);
    color: white;
}

.tile.present {
    background-color: var(--present);
    border-color: var(--present);
    color: white;
}

.tile.absent {
    background-color: var(--absent);
    border-color: var(--absent);
    color: white;
}

/* Keyboard */
.keyboard {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 8px;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 8px;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.key {
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    min-width: 43px;
    height: 58px;
    background-color: var(--key-bg);
    color: var(--key-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background-color 0.15s;
}

.key:hover {
    background-color: var(--key-bg-hover);
}

.key.wide {
    min-width: 65px;
    font-size: 12px;
}

.key.correct {
    background-color: var(--correct);
    color: white;
}

.key.present {
    background-color: var(--present);
    color: white;
}

.key.absent {
    background-color: var(--absent);
    color: white;
}

/* Message Display */
.message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    box-shadow: var(--shadow-md);
    will-change: opacity;
}

.message.show {
    opacity: 1;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--modal-bg);
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

/* Examples in How to Play */
.examples {
    margin-top: 20px;
}

.example-row {
    display: grid;
    grid-template-columns: repeat(5, 40px);
    gap: 5px;
    margin: 12px 0;
}

.example-row .tile {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.distribution {
    margin: 16px 0;
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.dist-label {
    min-width: 12px;
    font-weight: 600;
}

.dist-bar-container {
    flex: 1;
    height: 24px;
    position: relative;
}

.dist-bar {
    background-color: var(--absent);
    height: 100%;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.dist-bar.current {
    background-color: var(--correct);
}

.share-section {
    text-align: center;
    margin-top: 24px;
}

.primary-btn {
    background-color: var(--primary-accent);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.primary-btn:hover {
    opacity: 0.9;
}

.secondary-btn {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background-color: var(--border-color);
    border-color: var(--text-secondary);
}

/* Settings */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 600;
    margin-bottom: 4px;
}

.setting-description {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-secondary);
    transition: 0.4s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-accent);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Language Select */
#language-select {
    padding: 8px 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 480px) {
    h1 {
        font-size: 28px;
    }

    .tile {
        font-size: 28px;
    }

    .key {
        min-width: 30px;
        height: 50px;
        font-size: 12px;
    }

    .key.wide {
        min-width: 50px;
        font-size: 10px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-value {
        font-size: 28px;
    }
}
