/* 🌿 Woordje - Fresh Spring Theme */
/* Color Palette: Light green meadow vibes 🌱 */

:root {
    --bg-dark: #e8f5e9;
    --bg-card: #ffffff;
    --bg-tile: #c8e6c9;
    
    /* Spring colors */
    --correct: #4caf50;      /* Fresh green */
    --present: #ff9800;      /* Warm orange */
    --absent: #90a4ae;       /* Soft gray */
    
    --text-light: #1b5e20;
    --text-muted: #558b2f;
    --accent: #66bb6a;       /* Spring accent */
    --accent-hover: #81c784;
    
    --success: #4caf50;
    --warning: #ff9800;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent double-tap zoom on iOS */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection on game elements */
.tile, .key, .icon-btn, button {
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(150deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
    min-height: 100vh;
    color: var(--text-light);
    display: flex;
    justify-content: center;
}

.container {
    max-width: 500px;
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    color: #2e7d32;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Login */
.login-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-top: 40px;
    border: 2px solid #81c784;
}

.login-box h2 {
    margin-bottom: 10px;
    color: var(--accent);
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.login-box input {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #81c784;
    border-radius: 10px;
    background: #fff;
    color: #1b5e20;
    margin-bottom: 15px;
    text-align: center;
}

.login-box input:focus {
    outline: none;
    border-color: #4caf50;
}

.btn-primary {
    width: 100%;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #66bb6a, #4caf50);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--bg-tile);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#player-display {
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: #e8f5e9;
    border: 2px solid #81c784;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #66bb6a;
    border-color: #66bb6a;
    transform: scale(1.1);
}

/* Game Board */
#board {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.row {
    display: flex;
    gap: 8px;
}

.tile {
    width: 58px;
    height: 58px;
    border: 3px solid #81c784;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #fff;
    color: #1b5e20;
    transition: all 0.3s;
}

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

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
    animation: flip 0.5s ease;
}

.tile.present {
    background: var(--present);
    border-color: var(--present);
    animation: flip 0.5s ease;
}

.tile.absent {
    background: var(--absent);
    border-color: var(--absent);
    animation: flip 0.5s ease;
}

@keyframes pop {
    50% { transform: scale(1.1); }
}

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.row.shake {
    animation: shake 0.3s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.tile.winner {
    animation: bounce 0.5s ease;
}

/* Message */
#message {
    text-align: center;
    height: 30px;
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

#message.error {
    color: var(--accent);
    animation: shake 0.3s;
}

#message.success {
    color: var(--correct);
}

/* Keyboard */
#keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.keyboard-row {
    display: flex;
    gap: 5px;
}

.key {
    min-width: 32px;
    height: 50px;
    padding: 0 10px;
    font-size: 0.95rem;
    font-weight: 600;
    background: #fff;
    color: #1b5e20;
    border: 2px solid #81c784;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
}

.key:hover {
    background: #66bb6a;
    color: #fff;
    border-color: #66bb6a;
}

.key.wide {
    min-width: 65px;
    font-size: 0.75rem;
    padding: 0 12px;
}

/* Enter and backspace keys - bold text */
.key.enter,
.key.wide {
    font-weight: 700;
}

/* Color legend */
.color-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.legend-color.correct { background: var(--correct); }
.legend-color.present { background: var(--present); }
.legend-color.absent { background: var(--absent); }

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

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

.key.absent {
    background: #90a4ae;
    color: #fff;
    border-color: #90a4ae;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(27, 94, 32, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
    border: 2px solid #81c784;
}

@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--accent);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.stat-box {
    text-align: center;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 10px;
    border: 1px solid #81c784;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Distribution */
.distribution {
    margin: 20px 0;
}

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

.dist-num {
    width: 20px;
    text-align: center;
    font-weight: 600;
}

.dist-bar {
    height: 24px;
    background: #c8e6c9;
    border-radius: 4px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: width 0.5s ease;
    color: #1b5e20;
}

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

/* Leaderboard */
.leaderboard-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.leaderboard-table {
    width: 100%;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #e8f5e9;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #c8e6c9;
}

.leaderboard-rank {
    width: 30px;
    font-size: 1.2rem;
    font-weight: 700;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-name {
    flex: 1;
    font-weight: 600;
    text-transform: capitalize;
}

.leaderboard-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.leaderboard-stat {
    text-align: center;
}

.leaderboard-stat span {
    display: block;
    font-weight: 700;
    color: var(--text-light);
}

/* Help */
.help-content h3 {
    color: var(--accent);
    margin: 15px 0 10px 0;
}

.help-content p {
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.help-example {
    display: flex;
    gap: 5px;
    margin: 15px 0;
}

.help-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 5px;
    background: #e8f5e9;
    border: 2px solid #81c784;
    color: #1b5e20;
}

.help-tile.correct { background: var(--correct); }
.help-tile.present { background: var(--present); }
.help-tile.absent { background: var(--absent); }

/* Responsive - iPhone optimized - fit everything on one screen */
@media (max-width: 430px) {
    .container {
        height: 100vh;
        height: 100dvh;
        padding: 8px 6px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    header {
        margin-bottom: 4px;
        flex-shrink: 0;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        display: none;
    }
    
    .game-header {
        padding: 5px 8px;
        margin-bottom: 6px;
        flex-shrink: 0;
    }
    
    #player-display {
        font-size: 1rem;
    }
    
    .icon-btn {
        padding: 5px 7px;
        font-size: 0.9rem;
    }
    
    #board {
        gap: 4px;
        margin-bottom: 4px;
        flex-shrink: 0;
    }
    
    .row {
        gap: 4px;
    }
    
    .tile {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
        border-width: 2px;
    }
    
    #message {
        height: 22px;
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 4px;
    }
    
    #message.success {
        color: #2e7d32;
        font-weight: 700;
    }
    
    #keyboard {
        gap: 4px;
        flex-shrink: 0;
    }
    
    .keyboard-row {
        gap: 3px;
    }
    
    .key {
        min-width: 26px;
        height: 38px;
        padding: 0 5px;
        font-size: 0.8rem;
        border-radius: 5px;
    }
    
    .key.wide {
        min-width: 42px;
        font-size: 0.6rem;
    }
    
    .color-legend {
        padding: 6px 10px;
        gap: 8px;
        margin-top: 6px;
        flex-shrink: 0;
        font-size: 0.65rem;
    }
    
    .legend-item {
        font-size: 0.6rem;
        gap: 4px;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    /* Login box mobile */
    .login-box {
        margin-top: 20px;
        padding: 25px 20px;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .tile {
        width: 46px;
        height: 46px;
        font-size: 1.4rem;
    }
    
    .key {
        min-width: 24px;
        height: 42px;
        font-size: 0.8rem;
    }
    
    .key.wide {
        min-width: 42px;
    }
}
