:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --text-primary: #333;
    --text-secondary: #666;
    --accent-color: #667eea;
    --cell-border: #d3d6da;
    --cell-bg: white;
    --cell-filled-border: #888;
    --key-bg: #d3d6da;
    --key-text: #000;
    --key-hover: #bbb;
    --info-bg: #f8f9ff;
    --correct-color: #6aaa64;
    --present-color: #c9b458;
    --absent-color: #787c7e;
    --menu-btn-bg: #f0f4ff;
    --menu-btn-border: #667eea;
}

[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #1e1e2f;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-color: #818cf8;
    --cell-border: #3a3a4a;
    --cell-bg: #2a2a3a;
    --cell-filled-border: #6a6a7a;
    --key-bg: #3a3a4a;
    --key-text: #e0e0e0;
    --key-hover: #4a4a5a;
    --info-bg: #252535;
    --correct-color: #538d4e;
    --present-color: #b59f3b;
    --absent-color: #3a3a3c;
    --menu-btn-bg: #252535;
    --menu-btn-border: #818cf8;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--container-bg);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: background 0.3s;
}

.container {
    max-width: 500px;
    width: 100%;
    background: var(--container-bg);
    border-radius: 0;
    padding: 15px;
    padding-top: env(safe-area-inset-top, 10px);
    padding-bottom: env(safe-area-inset-bottom, 10px);
    box-shadow: none;
    margin: 0 auto;
    transition: background 0.3s;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Menu Header */
.menu-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    padding-top: 10px;
}

.menu-header h1 {
    color: var(--accent-color);
    font-size: 2.5em;
    margin-bottom: 5px;
}

.menu-header .subtitle {
    color: var(--text-secondary);
    font-size: 1em;
}

.theme-toggle {
    position: absolute;
    right: 0;
    top: 0;
    background: var(--key-bg);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--key-hover);
    transform: scale(1.1);
}

/* Menu Content */
.menu-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--menu-btn-bg);
    border: 3px solid var(--menu-btn-border);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.menu-btn:active {
    transform: translateY(0);
}

.menu-check {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 2px solid var(--cell-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    background: var(--cell-bg);
    transition: all 0.3s;
}

.menu-check.done {
    background: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
    font-weight: bold;
}

.menu-title {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.menu-streak {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-secondary);
    background: transparent;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.menu-streak.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.menu-desc {
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--cell-border);
}

.home-btn {
    background: var(--key-bg);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-btn:hover {
    background: var(--key-hover);
    transform: scale(1.1);
}

.game-title {
    text-align: center;
    flex: 1;
}

.game-title h2 {
    color: var(--accent-color);
    font-size: 1.3em;
    margin-bottom: 2px;
}

.game-title p {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.suite-progress {
    text-align: center;
    padding: 8px;
    background: var(--info-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: var(--accent-color);
    font-weight: bold;
}

/* Game Board */
.game-board {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
    padding: 10px 0;
    min-height: 250px;
}

.row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.cell {
    width: 48px;
    height: 48px;
    border: 2px solid var(--cell-border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: bold;
    text-transform: uppercase;
    background: var(--cell-bg);
    color: var(--text-primary);
    transition: all 0.3s;
}

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

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

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

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

.cell.revealed {
    background: var(--correct-color);
    color: white;
    border-color: var(--correct-color);
}

.cell.hint {
    background: transparent;
    color: var(--correct-color);
    border-color: var(--correct-color);
    opacity: 0.7;
}

.cell.flip {
    animation: flip 0.5s;
}

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

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

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

/* Message */
.message {
    text-align: center;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    font-weight: bold;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.message.error {
    background: #e74c3c;
    color: white;
}

.message.info {
    background: #3498db;
    color: white;
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    width: 100%;
}

.key {
    padding: 16px 0;
    flex: 1;
    min-width: 0;
    max-width: 50px;
    border: none;
    border-radius: 6px;
    background: var(--key-bg);
    color: var(--key-text);
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.key:active {
    transform: scale(0.95);
}

.key.wide {
    flex: 1.5;
    max-width: 65px;
    font-size: 0.7em;
    padding: 14px 4px;
}

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

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

.key.absent {
    background: #1a1a1a;
    color: #555;
    opacity: 0.6;
}

/* Instructions */
.instructions {
    background: var(--info-bg);
    padding: 20px;
    border-radius: 15px;
}

.instructions h3 {
    color: var(--accent-color);
    margin-bottom: 15px;
    text-align: center;
}

.instructions p {
    margin: 8px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-box {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
}

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

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

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

/* Progress dots */
.progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cell-border);
}

.dot.completed {
    background: var(--correct-color);
}

.dot.current {
    background: var(--accent-color);
}

/* Mobile optimizations */
@media (max-width: 500px) {
    .container {
        padding: 15px;
        border-radius: 0;
        margin: 0;
        min-height: 100vh;
    }

    .menu-header h1 {
        font-size: 2em;
    }

    .cell {
        width: 42px;
        height: 42px;
        font-size: 1.2em;
    }

    .row {
        gap: 5px;
    }

    .key {
        padding: 12px 0;
        font-size: 0.9em;
        max-width: 38px;
    }

    .key.wide {
        max-width: 55px;
        font-size: 0.65em;
    }

    .game-title h2 {
        font-size: 1.1em;
    }
}

@media (max-width: 380px) {
    .cell {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }

    .row {
        gap: 4px;
    }

    .key {
        padding: 10px 0;
        font-size: 0.8em;
        max-width: 32px;
    }

    .key.wide {
        max-width: 48px;
        font-size: 0.6em;
    }
}
