/**
 * Bilmeceler Game - Stylesheet
 * Responsive, mobile-first design matching Bilmeceler.com.tr
 */

/* ==========================================================================
   GAME WRAPPER & RESET
   ========================================================================== */
.bm-game-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    font-family: var(--font-system, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    color: var(--text-main, #17181C);
    -webkit-tap-highlight-color: transparent;
}

/* Loading State */
.bm-game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8, 64px) var(--space-4, 16px);
    background: var(--card-bg, #FFFFFF);
    border: 1px solid var(--border, #E7E5E0);
    border-radius: var(--radius-card, 16px);
    text-align: center;
    gap: var(--space-4, 16px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.bm-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--soft-accent, #EEEAFE);
    border-top-color: var(--primary, #5B4AE7);
    border-radius: 50%;
    animation: bm-spin 0.8s linear infinite;
}

@keyframes bm-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   LOBBY / MODE SELECTION
   ========================================================================== */
.bm-lobby {
    display: flex;
    flex-direction: column;
    gap: var(--space-6, 32px);
}

.bm-lobby-hero {
    text-align: center;
    padding: var(--space-6, 32px) var(--space-4, 16px);
    background: linear-gradient(135deg, #FAF8FF 0%, #F5F3FF 100%);
    border: 1px solid var(--soft-accent, #EEEAFE);
    border-radius: var(--radius-card, 16px);
}

.bm-lobby-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--soft-accent, #EEEAFE);
    color: var(--primary, #5B4AE7);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 14px;
    border-radius: var(--radius-badge, 999px);
    margin-bottom: var(--space-3, 12px);
}

.bm-lobby-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: var(--space-2, 8px);
    color: var(--text-main, #17181C);
}

.bm-lobby-desc {
    font-size: 1.05rem;
    color: var(--text-muted, #667085);
    max-width: 580px;
    margin: 0 auto;
}

.bm-modes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5, 24px);
}

@media (max-width: 640px) {
    .bm-modes-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4, 16px);
    }
}

.bm-mode-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--space-6, 32px) var(--space-5, 24px);
    background: var(--card-bg, #FFFFFF);
    border: 2px solid var(--border, #E7E5E0);
    border-radius: var(--radius-card, 16px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
    text-align: left;
}

.bm-mode-card:hover {
    border-color: var(--primary, #5B4AE7);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(91, 74, 231, 0.1);
}

.bm-mode-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-3, 12px);
}

.bm-mode-icon {
    font-size: 2rem;
    line-height: 1;
}

.bm-mode-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main, #17181C);
}

.bm-mode-features {
    list-style: none;
    margin: var(--space-3, 12px) 0 var(--space-5, 24px) 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-muted, #667085);
}

.bm-mode-features li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bm-mode-features li::before {
    content: "✓";
    color: #10B981;
    font-weight: 800;
}

.bm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-btn, 10px);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.bm-btn-primary {
    background: var(--primary, #5B4AE7);
    color: #FFFFFF;
}

.bm-btn-primary:hover {
    background: var(--primary-hover, #4838C7);
    transform: translateY(-1px);
}

.bm-btn-secondary {
    background: var(--soft-accent, #EEEAFE);
    color: var(--primary, #5B4AE7);
}

.bm-btn-secondary:hover {
    background: #E4DDFE;
}

.bm-btn-outline {
    background: transparent;
    border: 1px solid var(--border, #E7E5E0);
    color: var(--text-main, #17181C);
}

.bm-btn-outline:hover {
    border-color: var(--primary, #5B4AE7);
    color: var(--primary, #5B4AE7);
}

.bm-btn-block {
    width: 100%;
}

.bm-lobby-footer {
    text-align: center;
    margin-top: var(--space-2, 8px);
}

/* ==========================================================================
   MODAL (NICKNAME & LEADERBOARD)
   ========================================================================== */
.bm-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    animation: bm-fade-in 0.2s ease;
}

@keyframes bm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bm-modal-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #FFFFFF;
    border-radius: var(--radius-card, 16px);
    padding: var(--space-6, 32px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: bm-slide-up 0.25s ease;
}

.bm-modal-card.bm-modal-large {
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

@keyframes bm-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.bm-modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted, #667085);
    cursor: pointer;
    line-height: 1;
}

.bm-modal-close:hover {
    color: var(--text-main, #17181C);
}

.bm-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: var(--space-2, 8px);
    color: var(--text-main, #17181C);
}

.bm-modal-desc {
    font-size: 0.95rem;
    color: var(--text-muted, #667085);
    margin-bottom: var(--space-5, 24px);
}

.bm-input-group {
    margin-bottom: var(--space-4, 16px);
}

.bm-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--text-main, #17181C);
}

.bm-input-text {
    width: 100%;
    padding: 12px 14px;
    font-size: 1.05rem;
    border: 2px solid var(--border, #E7E5E0);
    border-radius: var(--radius-input, 10px);
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.bm-input-text:focus {
    border-color: var(--primary, #5B4AE7);
    box-shadow: 0 0 0 3px var(--soft-accent, #EEEAFE);
}

.bm-input-error-msg {
    color: #DC2626;
    font-size: 0.85rem;
    margin-top: 6px;
    display: none;
}

/* ==========================================================================
   GAME HUD & HEADER
   ========================================================================== */
.bm-game-card {
    background: var(--card-bg, #FFFFFF);
    border: 1px solid var(--border, #E7E5E0);
    border-radius: var(--radius-card, 16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    padding: var(--space-6, 32px);
    display: flex;
    flex-direction: column;
    gap: var(--space-5, 24px);
}

@media (max-width: 640px) {
    .bm-game-card {
        padding: var(--space-4, 16px);
        gap: var(--space-4, 16px);
    }
}

.bm-game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-4, 16px);
    border-bottom: 1px solid var(--border, #E7E5E0);
    gap: 12px;
}

.bm-hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-badge, 999px);
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

.bm-badge-purple {
    background: var(--soft-accent, #EEEAFE);
    color: var(--primary, #5B4AE7);
}

.bm-badge-gray {
    background: #F3F4F6;
    color: #4B5563;
}

.bm-timer-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bm-timer-text {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main, #17181C);
    min-width: 60px;
    text-align: center;
}

.bm-timer-warning {
    color: #F59E0B !important;
}

.bm-timer-danger {
    color: #DC2626 !important;
    animation: bm-pulse 1s infinite;
}

@keyframes bm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.bm-progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: #E5E7EB;
    border-radius: 999px;
    overflow: hidden;
    margin-top: -8px;
}

.bm-progress-bar-fill {
    height: 100%;
    background: var(--primary, #5B4AE7);
    width: 100%;
    transition: width 0.3s linear, background-color 0.3s ease;
}

/* ==========================================================================
   QUESTION AREA
   ========================================================================== */
.bm-question-box {
    text-align: center;
    padding: var(--space-4, 16px) var(--space-2, 8px);
}

.bm-category-tag {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary, #5B4AE7);
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2, 8px);
}

.bm-question-text {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-main, #17181C);
    max-width: 660px;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .bm-question-text {
        font-size: 1.15rem;
    }
}

/* ==========================================================================
   LETTER BOXES (WORDLE / ÇARKIFELEK STYLE)
   ========================================================================== */
.bm-letters-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: var(--space-3, 12px) 0;
    user-select: none;
}

.bm-word-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.bm-letter-box {
    width: 38px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    border: 2px solid var(--border, #E7E5E0);
    border-radius: 8px;
    font-size: 1.35rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main, #17181C);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (max-width: 480px) {
    .bm-letter-box {
        width: 30px;
        height: 40px;
        font-size: 1.15rem;
        border-radius: 6px;
    }
    .bm-word-row {
        gap: 4px;
    }
}

.bm-letter-box.bm-box-active {
    border-color: var(--primary, #5B4AE7);
    background: #FAF8FF;
    transform: translateY(-2px);
    box-shadow: 0 0 0 3px var(--soft-accent, #EEEAFE);
}

.bm-letter-box.bm-box-hint {
    background: #FEF3C7;
    border-color: #F59E0B;
    color: #92400E;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.bm-letter-box.bm-box-punctuation {
    border: none;
    background: transparent;
    width: auto;
    min-width: 14px;
    box-shadow: none;
    cursor: default;
    font-weight: 700;
}

/* Hidden input to drive mobile and physical typing */
.bm-hidden-input {
    position: fixed;
    opacity: 0;
    pointer-events: none;
    width: 32px;
    height: 32px;
    font-size: 16px; /* Prevents auto-zoom on iOS */
    z-index: -1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0;
    margin: 0;
}

/* ==========================================================================
   FEEDBACK & ALERTS
   ========================================================================== */
.bm-feedback-toast {
    min-height: 24px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.bm-feedback-toast.bm-error {
    color: #DC2626;
    animation: bm-shake 0.4s ease;
}

.bm-feedback-toast.bm-success {
    color: #10B981;
}

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

/* ==========================================================================
   ACTION BUTTONS
   ========================================================================== */
.bm-actions-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: var(--space-2, 8px);
}

.bm-btn-hint {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
}

.bm-btn-hint:hover {
    background: #FDE68A;
}

.bm-btn-pass {
    background: #F3F4F6;
    color: #4B5563;
}

.bm-btn-pass:hover {
    background: #E5E7EB;
}

.bm-btn-submit {
    background: #10B981;
    color: #FFFFFF;
}

.bm-btn-submit:hover {
    background: #059669;
}

/* ==========================================================================
   GAME OVER / RESULTS SCREEN
   ========================================================================== */
.bm-results-card {
    text-align: center;
    padding: var(--space-7, 48px) var(--space-5, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5, 24px);
}

.bm-trophy-icon {
    font-size: 4rem;
    line-height: 1;
    animation: bm-bounce 1s ease;
}

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

.bm-results-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.bm-results-score-banner {
    background: var(--soft-accent, #EEEAFE);
    border: 2px dashed var(--primary, #5B4AE7);
    border-radius: var(--radius-card, 16px);
    padding: var(--space-4, 16px) var(--space-6, 32px);
    margin: var(--space-2, 8px) 0;
}

.bm-results-score-num {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary, #5B4AE7);
    line-height: 1;
}

.bm-results-score-label {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted, #667085);
    margin-top: 4px;
}

.bm-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 600px;
}

@media (max-width: 580px) {
    .bm-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.bm-stat-box {
    background: #F9FAFB;
    border: 1px solid var(--border, #E7E5E0);
    border-radius: var(--radius-btn, 10px);
    padding: 14px 10px;
}

.bm-stat-val {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main, #17181C);
}

.bm-stat-lbl {
    font-size: 0.8rem;
    color: var(--text-muted, #667085);
    margin-top: 2px;
}

.bm-results-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: var(--space-3, 12px);
}

/* ==========================================================================
   LEADERBOARD MODAL TABLE
   ========================================================================== */
.bm-leaderboard-table-wrap {
    overflow-y: auto;
    max-height: 60vh;
    border: 1px solid var(--border, #E7E5E0);
    border-radius: var(--radius-btn, 10px);
    margin-top: var(--space-3, 12px);
}

.bm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    text-align: left;
}

.bm-table th {
    position: sticky;
    top: 0;
    background: #F9FAFB;
    padding: 12px 14px;
    font-weight: 700;
    color: var(--text-main, #17181C);
    border-bottom: 2px solid var(--border, #E7E5E0);
    z-index: 2;
}

.bm-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #F3F4F6;
}

.bm-table tr:hover td {
    background: #FAF8FF;
}

.bm-rank-1 td { background: #FFFBEB; font-weight: 700; }
.bm-rank-2 td { background: #F8FAFC; font-weight: 600; }
.bm-rank-3 td { background: #FFF7ED; font-weight: 600; }

.bm-medal {
    font-size: 1.15rem;
    margin-right: 4px;
}
