/* אפס ובסיס */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* כותרת */
header {
    background: linear-gradient(135deg, #1e293b, #334155);
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #3b82f6;
    flex-shrink: 0;
}

.home-link {
    text-decoration: none;
    font-size: 1.2rem;
    padding: 3px 6px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
}

header h1 {
    font-size: 1.1rem;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#score-bar {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Mode bar - difficulty + bonus */
.mode-bar {
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding: 6px 10px;
    background: #1e293b;
    flex-shrink: 0;
    justify-content: center;
}

.difficulty-selector {
    display: flex;
    gap: 6px;
}

.diff-btn {
    flex: 1;
    max-width: 80px;
    padding: 5px 4px;
    border: 2px solid #475569;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.diff-btn.active {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-color: #3b82f6;
}

.diff-btn small {
    display: block;
    font-weight: normal;
    font-size: 0.62rem;
    opacity: 0.8;
}

/* Bonus toggle */
.bonus-toggle {
    padding: 5px 4px;
    border: 2px solid #f59e0b;
    background: #0f172a;
    color: #fbbf24;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

.bonus-toggle.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-color: #f59e0b;
}

/* Bonus menu */
.bonus-menu {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: #1a1f2e;
    border-top: 1px solid #334155;
    flex-shrink: 0;
    justify-content: center;
    flex-wrap: wrap;
}

.bonus-menu.hidden {
    display: none;
}

.bonus-btn {
    padding: 5px 10px;
    border: 1px solid #475569;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bonus-btn.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-color: #f59e0b;
}

.bonus-btn:active {
    transform: scale(0.95);
}

/* Mode indicator */
.mode-indicator {
    text-align: center;
    padding: 3px;
    background: #1a1f2e;
    font-size: 0.7rem;
    color: #fbbf24;
    flex-shrink: 0;
}

.mode-indicator.hidden {
    display: none;
}

/* לוח המשחק */
#game-board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: #1e293b;
    align-items: center;
    flex: 1;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

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

.tile {
    width: 50px;
    height: 50px;
    border: 2px solid #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    font-weight: bold;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 4px;
    transition: transform 0.1s;
}

.tile.filled {
    border-color: #64748b;
    animation: pop 0.1s;
}

.tile.correct {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.tile.present {
    background: #eab308;
    border-color: #eab308;
    color: white;
}

.tile.absent {
    background: #475569;
    border-color: #475569;
    color: white;
}

.tile.flip {
    animation: flip 0.5s ease forwards;
}

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

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

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

@keyframes bounce {
    50% { transform: translateY(-10px); }
}

/* Tile selection */
.tile.selected {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Hint styling */
.tile.hint {
    border-color: #a78bfa !important;
    color: #a78bfa;
}

/* Hint bar */
.hint-bar {
    display: flex;
    justify-content: center;
    padding: 2px 10px;
    background: #1e293b;
    flex-shrink: 0;
}

.hint-btn {
    padding: 4px 16px;
    border: 1px solid #a78bfa;
    background: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.hint-btn:active {
    transform: scale(0.95);
}

.hint-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Clickable previous rows */
.row {
    cursor: pointer;
}

/* הודעת שגיאה */
.error-message {
    text-align: center;
    color: #fbbf24;
    font-weight: bold;
    padding: 4px;
    font-size: 0.8rem;
    background: #1e293b;
    flex-shrink: 0;
}

.error-message.hidden {
    display: none;
}

/* מקלדת */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 4px 8px 4px;
    background: #1e293b;
    flex-shrink: 0;
}

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

.key {
    min-width: 30px;
    height: 42px;
    border: none;
    border-radius: 4px;
    background: #475569;
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0 4px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.key.wide {
    min-width: 48px;
    font-size: 0.72rem;
    background: #3b82f6;
}

.key.correct {
    background: #22c55e;
    color: white;
}

.key.present {
    background: #eab308;
    color: white;
}

.key.absent {
    background: #1e293b;
    color: #64748b;
}

/* מודאל */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: #1e293b;
    border: 2px solid #3b82f6;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    max-width: 350px;
    width: 90%;
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: #60a5fa;
}

.modal-content.win h2 {
    color: #22c55e;
}

.modal-content.lose h2 {
    color: #ef4444;
}

.modal-content p {
    font-size: 1.05rem;
    margin-bottom: 18px;
    color: #cbd5e1;
    line-height: 1.5;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.97);
}

/* Mobile - medium screens */
@media (max-height: 700px) {
    .tile {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
    }
    
    .key {
        min-width: 27px;
        height: 38px;
        font-size: 0.9rem;
    }
    
    .key.wide {
        min-width: 42px;
    }
    
    header {
        padding: 4px 10px;
    }
    
    header h1 {
        font-size: 1rem;
    }
    
    .mode-bar {
        padding: 4px 6px;
    }
    
    #game-board {
        padding: 4px;
        gap: 3px;
    }
    
    .row {
        gap: 3px;
    }
    
    .keyboard {
        padding: 3px 4px 6px 4px;
        gap: 3px;
    }
}

/* Mobile - small screens */
@media (max-height: 580px) {
    .tile {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
    
    .key {
        min-width: 24px;
        height: 34px;
        font-size: 0.82rem;
        padding: 0 3px;
    }
    
    .key.wide {
        min-width: 38px;
        font-size: 0.65rem;
    }
    
    header {
        padding: 3px 8px;
    }
    
    header h1 {
        font-size: 0.9rem;
    }
    
    #score-bar {
        font-size: 0.7rem;
    }
    
    .mode-bar {
        padding: 3px 4px;
        gap: 4px;
    }
    
    .diff-btn {
        padding: 3px 2px;
        font-size: 0.65rem;
    }
    
    .diff-btn small {
        font-size: 0.55rem;
    }
    
    .bonus-toggle {
        padding: 3px 6px;
        font-size: 0.65rem;
    }
    
    .bonus-menu {
        padding: 4px 6px;
    }
    
    .bonus-btn {
        padding: 3px 6px;
        font-size: 0.6rem;
    }
    
    #game-board {
        padding: 2px;
        gap: 2px;
    }
    
    .row {
        gap: 2px;
    }
    
    .keyboard {
        padding: 2px 3px 4px 3px;
        gap: 2px;
    }
    
    .keyboard-row {
        gap: 2px;
    }
}

/* Very small screens */
@media (max-height: 500px) {
    .tile {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-width: 1px;
    }
    
    .key {
        min-width: 22px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    .key.wide {
        min-width: 34px;
    }
}
