/* ============================================
   FRUIT MATCH GAME - PRODUCTION CSS
   Enhanced Dark Mode & Leaderboard Fix
   ============================================ */

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

body {
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f5;
    color: #2d3748;
    overflow: hidden;
    user-select: none;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[data-theme="dark"] body {
    background: #0f172a;
    color: #e2e8f0;
}

/* ============================================
   BACKGROUND LAYERS
   ============================================ */
#bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

#game-bg {
    position: fixed;
    inset: 0;
    background-image: url('/static/images/background.jpg');
    background-size: cover;
    background-position: center 70%;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 1;
    filter: brightness(1);
    transition: opacity 0.4s ease, filter 0.4s ease;
}

[data-theme="dark"] #game-bg {
    filter: brightness(0.6);
}

.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.bg-layer.active {
    opacity: 1;
}

[data-theme="dark"] .bg-layer {
    filter: brightness(0.6);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-style: italic;
}

[data-theme="dark"] .loading {
    color: #94a3b8;
}

.empty {
    text-align: center;
    padding: 30px;
    color: #94a3b8;
    font-style: italic;
}

[data-theme="dark"] .empty {
    color: #64748b;
}

.error {
    text-align: center;
    padding: 20px;
    color: #ef4444;
    font-weight: 600;
}

[data-theme="dark"] .error {
    color: #f87171;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4 {
    text-align: center;
    margin: 0.5em 0;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    font-weight: 700;
}

h1 {
    color: #ffffff;
    font-size: 2.2rem;
    text-shadow: 0 0 25px rgba(0,0,0,0.6);
}

h2 {
    color: #fbbf24;
    font-size: 1.9rem;
}

h3 {
    color: #f59e0b;
    font-size: 1.4rem;
}

[data-theme="dark"] h1 {
    color: #fbbf24;
    text-shadow: 0 0 40px rgba(251, 191, 36, 0.7);
}

[data-theme="dark"] h2 {
    color: #60a5fa;
}

[data-theme="dark"] h3 {
    color: #fcd34d;
}

p {
    line-height: 1.6;
}

/* ============================================
   SCREENS & CONTAINERS
   ============================================ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MENU SCREEN
   ============================================ */
.logo-title {
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #fb923c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 20px 0;
    animation: gradientShift 3s ease infinite;
    background-size: 200% 200%;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
    max-width: 360px;
    margin-top: 25px;
}

/* ============================================
   HEADER CONTROLS (Top-right buttons)
   ============================================ */
.header-controls {
    position: fixed;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.btn-control {
    background: rgba(255, 255, 255, 0.97);
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    font-size: 1.15rem;
    color: #667eea;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

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

[data-theme="dark"] .btn-control {
    background: rgba(30, 41, 59, 0.97);
    color: #fbbf24;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.btn-lang {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ============================================
   BUTTONS
   ============================================ */
button {
    font-family: 'Fredoka', sans-serif;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 18px 24px;
    border-radius: 18px;
    font-size: 1.35rem;
    font-weight: 700;
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-primary:hover {
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    padding: 14px 30px;
    border-radius: 32px;
    font-weight: 700;
    margin-top: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.97);
    color: #667eea;
    padding: 18px 24px;
    border-radius: 18px;
    font-size: 1.15rem;
    font-weight: 700;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0,0,0,0.2);
}

[data-theme="dark"] .btn-icon {
    background: rgba(30, 41, 59, 0.97);
    color: #fbbf24;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

/* ============================================
   LEVEL SELECT
   ============================================ */
.level-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: 340px;
    margin-top: 25px;
}

.btn-level-large {
    padding: 24px;
    border-radius: 20px;
    color: white;
    font-size: 1.7rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.btn-level-large:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.btn-level-large::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    pointer-events: none;
}

.btn-level-large small {
    font-size: 1rem;
    opacity: 0.95;
    margin-top: 8px;
    font-weight: 500;
}

.easy {
    background: linear-gradient(135deg, #10b981, #059669);
}

.medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.hard {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* ============================================
   GAME SCREEN - UNIFIED CONTAINER
   ============================================ */
#game-screen {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    align-items: center;
    justify-content: center;
}

#game-controls-container {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 22px;
    padding: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(255,255,255,0.4);
    gap: 0;
}

[data-theme="dark"] #game-controls-container {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(251, 191, 36, 0.25);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

/* ============================================
   HUD (Score, Timer, Combo)
   ============================================ */
#hud {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.hud-box {
    background: rgba(248, 250, 252, 0.9);
    padding: 10px 16px;
    border-radius: 14px;
    text-align: center;
    min-width: 85px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: all 0.2s ease;
}

[data-theme="dark"] .hud-box {
    background: rgba(51, 65, 85, 0.9);
    box-shadow: 0 3px 12px rgba(0,0,0,0.4);
    border-color: rgba(71, 85, 105, 0.6);
}

.hud-box span {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 700;
}

[data-theme="dark"] .hud-box span {
    color: #cbd5e1;
}

.hud-box div {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1e293b;
}

#score-display {
    color: #f59e0b;
}

#timer-display {
    color: #3b82f6;
}

#timer-display.warning {
    color: #ef4444;
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#combo-display {
    color: #ec4899;
}

[data-theme="dark"] #score-display {
    color: #fbbf24;
}

[data-theme="dark"] #timer-display {
    color: #60a5fa;
}

[data-theme="dark"] #timer-display.warning {
    color: #f87171;
}

[data-theme="dark"] #combo-display {
    color: #f472b6;
}

/* ============================================
   GAME BOARD
   ============================================ */
#game-board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0;
    margin: 0;
}

.cards-grid-large {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 11px;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    box-sizing: border-box;
    margin: 0 auto;
}

[data-theme="dark"] .cards-grid-large {
    background: rgba(15, 23, 42, 0.3);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
    position: relative;
    transition: all 0.25s ease;
    font-size: 0.9rem;
    text-align: center;
    padding: 8px;
    aspect-ratio: 1;
    border: 2px solid rgba(102, 126, 234, 0.25);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

[data-theme="dark"] .card {
    background: linear-gradient(135deg, #1e293b, #334155);
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    border: 2px solid rgba(251, 191, 36, 0.35);
}

.card img {
    max-width: 88%;
    max-height: 88%;
    object-fit: contain;
    transition: transform 0.25s ease;
    pointer-events: none;
}

.card:active {
    transform: scale(0.96);
}

/* Hidden Text Cards */
.card.hidden-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 2px solid rgba(255,255,255,0.35);
}

[data-theme="dark"] .card.hidden-card {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    border: 2px solid rgba(96, 165, 250, 0.5);
}

.question-mark {
    font-size: 2.6rem;
    color: rgba(255,255,255,0.95);
    font-weight: 800;
    text-shadow: 0 3px 10px rgba(0,0,0,0.4);
    pointer-events: none;
}

[data-theme="dark"] .question-mark {
    color: #fbbf24;
    text-shadow: 0 3px 12px rgba(251, 191, 36, 0.6);
}

.card.selected {
    transform: scale(0.98);
    border: 3px solid #3b82f6;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.6);
}

[data-theme="dark"] .card.selected {
    border: 3px solid #fbbf24;
    box-shadow: 0 0 28px rgba(251, 191, 36, 0.7);
}

.card.revealed {
    background: linear-gradient(135deg, #ffffff, #f0f9ff);
    animation: revealCard 0.45s ease-out;
}

[data-theme="dark"] .card.revealed {
    background: linear-gradient(135deg, #1e293b, #1e3a5f);
}

@keyframes revealCard {
    0% {
        transform: rotateY(90deg) scale(0.9);
        opacity: 0;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.card.matched {
    animation: matchSuccess 0.7s forwards;
    pointer-events: none;
}

@keyframes matchSuccess {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    30% {
        transform: scale(1.15);
        opacity: 0.9;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.card.wrong {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    animation: shake 0.5s ease-in-out;
    border: 3px solid #ef4444 !important;
}

[data-theme="dark"] .card.wrong {
    background: linear-gradient(135deg, #7f1d1d, #991b1b) !important;
    border: 3px solid #f87171 !important;
}

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

.card.text-only {
    font-weight: 700;
    color: #1e293b;
    padding: 10px;
    font-size: 0.78rem;
    line-height: 1.35;
}

[data-theme="dark"] .card.text-only {
    color: #f1f5f9;
}

.card.shuffling {
    animation: shuffleSpin 0.55s ease-in-out;
}

@keyframes shuffleSpin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(0.88);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* ============================================
   BOTTOM CONTROLS (Pause, Home buttons)
   ============================================ */
#bottom-controls {
    display: flex;
    gap: 14px;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin-top: 14px;
    width: 100%;
}

.btn-game-control {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.14);
    font-size: 1.35rem;
    color: #667eea;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-game-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

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

[data-theme="dark"] .btn-game-control {
    background: rgba(51, 65, 85, 0.9);
    color: #fbbf24;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border-color: rgba(71, 85, 105, 0.6);
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: white;
    padding: 35px;
    border-radius: 26px;
    width: 90%;
    max-width: 540px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 70px rgba(0,0,0,0.5);
    animation: slideUp 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    position: relative;
}

[data-theme="dark"] .modal-content {
    background: #1e293b;
    color: #f1f5f9;
}

@keyframes slideUp {
    from {
        transform: translateY(70px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.25rem;
    color: #64748b;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    background: rgba(0,0,0,0.2);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: scale(0.9);
}

[data-theme="dark"] .modal-close {
    background: rgba(255,255,255,0.1);
    color: #cbd5e1;
}

/* ============================================
   INSTRUCTIONS MODAL
   ============================================ */
.instructions-modal h2 {
    color: #667eea;
    margin-bottom: 22px;
}

[data-theme="dark"] .instructions-modal h2 {
    color: #fbbf24;
}

.instructions-content {
    text-align: left;
}

.instruction-section {
    margin-bottom: 28px;
    padding: 22px;
    background: rgba(102, 126, 234, 0.06);
    border-radius: 18px;
    border-left: 5px solid #667eea;
}

[data-theme="dark"] .instruction-section {
    background: rgba(251, 191, 36, 0.1);
    border-left-color: #fbbf24;
}

.instruction-section h3 {
    color: #667eea;
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 1.15rem;
    text-align: left;
}

[data-theme="dark"] .instruction-section h3 {
    color: #fbbf24;
}

.instruction-section p,
.instruction-section li {
    color: #475569;
    line-height: 1.7;
    margin: 10px 0;
}

[data-theme="dark"] .instruction-section p,
[data-theme="dark"] .instruction-section li {
    color: #cbd5e1;
}

.instruction-section ol,
.instruction-section ul {
    padding-left: 24px;
    margin: 12px 0;
}

/* ============================================
   LOGIN MODAL
   ============================================ */
#login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.login-box {
    background: white;
    padding: 42px;
    border-radius: 30px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(0,0,0,0.6);
    animation: slideUp 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

[data-theme="dark"] .login-box {
    background: #1e293b;
    color: #f1f5f9;
}

.login-box h2 {
    margin-top: 0;
    color: #667eea;
    margin-bottom: 28px;
}

[data-theme="dark"] .login-box h2 {
    color: #fbbf24;
}

.login-box input {
    width: 100%;
    padding: 16px;
    margin: 14px 0;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    box-sizing: border-box;
    font-size: 1.08rem;
    font-family: inherit;
    transition: all 0.25s ease;
    background: #f8fafc;
}

[data-theme="dark"] .login-box input {
    background: #334155;
    border-color: #475569;
    color: white;
}

.login-box input::placeholder {
    color: #94a3b8;
}

[data-theme="dark"] .login-box input::placeholder {
    color: #64748b;
}

.login-box input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12);
    background: white;
}

[data-theme="dark"] .login-box input:focus {
    border-color: #fbbf24;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
    background: #1e293b;
}

.phone-input {
    display: flex;
    align-items: center;
    margin: 14px 0;
}

.prefix {
    background: #e2e8f0;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-right: none;
    border-radius: 16px 0 0 16px;
    color: #475569;
    font-weight: 700;
}

[data-theme="dark"] .prefix {
    background: #475569;
    border-color: #475569;
    color: #cbd5e1;
}

.phone-input input {
    margin: 0;
    border-radius: 0 16px 16px 0;
}

/* ============================================
   LEADERBOARD & PROFILE - FIXED DARK MODE
   ============================================ */
.scroll-box {
    background: rgba(255,255,255,0.98);
    border-radius: 24px;
    width: 100%;
    max-width: 540px;
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    margin: 18px 0;
    box-shadow: 0 8px 28px rgba(0,0,0,0.12);
    border: 2px solid rgba(226, 232, 240, 0.5);
}

[data-theme="dark"] .scroll-box {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(71, 85, 105, 0.5);
    box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}

/* Leaderboard List Styling - FIXED DARK MODE */
#leaderboard-list,
.history-list,
.promo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard-list li,
.history-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    animation: fadeIn 0.4s ease-out;
    animation-fill-mode: forwards;
}

#leaderboard-list li:hover,
.history-list li:hover {
    background: rgba(102, 126, 234, 0.05);
}

[data-theme="dark"] #leaderboard-list li,
[data-theme="dark"] .history-list li {
    border-bottom-color: #475569;
}

[data-theme="dark"] #leaderboard-list li:hover,
[data-theme="dark"] .history-list li:hover {
    background: rgba(251, 191, 36, 0.08);
}

#leaderboard-list li:last-child,
.history-list li:last-child {
    border-bottom: none;
}

/* Rank Badge */
.rank {
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] .rank {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.5);
}

/* Player Name - FIXED COLOR IN DARK MODE */
.name {
    flex: 1;
    text-align: left;
    padding: 0 16px;
    font-weight: 700;
    color: #1e293b;
    font-size: 1.05rem;
}

[data-theme="dark"] .name {
    color: #f1f5f9;  /* Clear white text in dark mode */
}

/* Score - FIXED COLOR IN DARK MODE */
.score {
    font-weight: 800;
    color: #10b981;
    font-size: 1.1rem;
}

[data-theme="dark"] .score {
    color: #34d399;  /* Bright green in dark mode */
}

/* Date in History */
.date {
    color: #64748b;
    font-size: 0.9rem;
}

[data-theme="dark"] .date {
    color: #94a3b8;
}

/* ============================================
   PROFILE SCREEN - ENHANCED
   ============================================ */
.profile-header {
    text-align: center;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 28px;
    border-radius: 20px;
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .profile-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.profile-header h3 {
    color: white;
    margin: 0 0 8px 0;
    font-size: 1.6rem;
}

.profile-header p {
    margin: 0;
    opacity: 0.95;
    font-size: 1.05rem;
}

/* Profile Actions (History/Promos tabs) */
.profile-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    width: 100%;
}

.btn-tab {
    flex: 1;
    background: rgba(255, 255, 255, 0.97);
    color: #64748b;
    padding: 16px 22px;
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

[data-theme="dark"] .btn-tab {
    background: rgba(51, 65, 85, 0.97);
    color: #94a3b8;
}

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

.btn-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.5);
}

[data-theme="dark"] .btn-tab.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
}

/* Profile Logout Button */
.btn-logout {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 700;
    margin-top: 16px;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-logout:hover {
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.5);
}

/* ============================================
   PROMO CODES - ENHANCED DARK MODE
   ============================================ */
.promo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.promo-item {
    background: linear-gradient(135deg, #ffffff, #fef3c7);
    margin-bottom: 14px !important;
    border-radius: 16px;
    padding: 16px 18px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-left: 6px solid #f59e0b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    animation: fadeIn 0.4s ease-out;
}

.promo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

[data-theme="dark"] .promo-item {
    background: linear-gradient(135deg, #334155, #1e293b);
    border-left-color: #fbbf24;
    border-bottom: none;
}

.code-text {
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 1.1rem;
    font-weight: 800;
    color: #d97706;
    background: rgba(251, 191, 36, 0.2);
    padding: 6px 10px;
    border-radius: 8px;
    display: inline-block;
    letter-spacing: 1px;
}

[data-theme="dark"] .code-text {
    background: rgba(251, 191, 36, 0.25);
    color: #fbbf24;
}

.btn-copy-small {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .btn-copy-small {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4);
}

/* Promo Win Box (Game Over) */
.promo-win-box {
    background: rgba(255,255,255,0.99);
    padding: 28px;
    border-radius: 24px;
    box-shadow: 0 14px 40px rgba(0,0,0,0.3);
    margin: 28px auto;
    max-width: 340px;
    text-align: center;
    animation: matchSuccess 0.7s reverse;
    border: 4px solid #f59e0b;
}

[data-theme="dark"] .promo-win-box {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #fbbf24;
}

.promo-code-display {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 18px;
    border-radius: 16px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

[data-theme="dark"] .promo-code-display {
    background: linear-gradient(135deg, #334155, #475569);
}

.promo-code-display code {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #d97706;
    font-family: 'Courier New', monospace;
}

[data-theme="dark"] .promo-code-display code {
    color: #fbbf24;
}

.btn-copy {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] .btn-copy {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
    padding: 16px 28px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 5000;
    transition: all 0.3s ease;
    animation: slideUp 0.4s ease-out;
}

[data-theme="dark"] .toast {
    background: linear-gradient(135deg, #334155, #475569);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.toast i {
    color: #10b981;
    font-size: 1.3rem;
}

[data-theme="dark"] .toast i {
    color: #34d399;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */
#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    color: white;
    z-index: 3000;
    text-shadow: 0 3px 10px rgba(0,0,0,0.6);
    font-weight: 700;
}

/* ============================================
   RESPONSIVE - MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 500px) {
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.2rem; }

    .menu-grid { max-width: 95%; }

    #game-controls-container {
        max-width: 95%;
        padding: 12px;
    }

    #hud {
        gap: 8px;
        margin-bottom: 12px;
    }

    .hud-box {
        min-width: 80px;
        padding: 8px 14px;
    }

    .hud-box span {
        font-size: 0.68rem;
    }

    .hud-box div {
        font-size: 1.25rem;
    }

    #bottom-controls {
        margin-top: 12px;
    }

    .btn-game-control {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .cards-grid-large {
        gap: 9px;
        padding: 10px;
    }

    .question-mark {
        font-size: 2.2rem;
    }

    .card.text-only {
        font-size: 0.7rem;
    }

    .modal-content {
        padding: 24px;
    }

    .login-box {
        padding: 32px 26px;
    }

    .header-controls {
        top: 12px;
        right: 12px;
        gap: 8px;
    }

    .btn-control {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }

    .rank {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .name {
        font-size: 0.95rem;
        padding: 0 12px;
    }

    .score {
        font-size: 1rem;
    }
}

@media (max-height: 700px) {
    #game-controls-container {
        padding: 10px;
    }

    #hud {
        margin-bottom: 10px;
    }

    .hud-box {
        padding: 6px 12px;
    }

    #bottom-controls {
        margin-top: 10px;
    }

    .cards-grid-large {
        gap: 8px;
    }
}

@media (max-height: 600px) {
    .menu-grid { margin-top: 16px; }
    .btn-primary, .btn-icon { padding: 14px; }
    h1 { font-size: 1.7rem; margin: 12px 0; }
}

/* ============================================
   DESKTOP / LARGE SCREEN OPTIMIZATIONS
   ============================================ */
@media (min-width: 768px) {
    #game-controls-container {
        max-width: 500px;
        padding: 18px;
        border-radius: 26px;
    }

    #hud {
        gap: 14px;
        margin-bottom: 18px;
    }

    .hud-box {
        min-width: 95px;
        padding: 12px 18px;
    }

    .hud-box span {
        font-size: 0.78rem;
    }

    .hud-box div {
        font-size: 1.55rem;
    }

    #bottom-controls {
        margin-top: 18px;
    }

    .btn-game-control {
        width: 58px;
        height: 58px;
        font-size: 1.45rem;
    }

    .cards-grid-large {
        gap: 15px;
        padding: 15px;
    }
}

/* ============================================
   ACCESSIBILITY & PRINT
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible for Keyboard Navigation */
button:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

[data-theme="dark"] button:focus-visible {
    outline-color: #fbbf24;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.scroll-box::-webkit-scrollbar {
    width: 8px;
}

.scroll-box::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}

.scroll-box::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.scroll-box::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

[data-theme="dark"] .scroll-box::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.3);
}

[data-theme="dark"] .scroll-box::-webkit-scrollbar-thumb:hover {
    background: rgba(251, 191, 36, 0.5);
}

