/* ============================================================
   2048 Game - CSS with Dark/Light Theme & RTL Support
   ============================================================ */

:root {
    --primary: #f5a623;
    --primary-hover: #e09600;
    --primary-light: rgba(245, 166, 35, 0.15);
    --bg-primary: #faf8ef;
    --bg-secondary: #baa898;
    --bg-card: #eee4da;
    --bg-card-empty: rgba(238, 228, 218, 0.65);
    --bg-overlay: rgba(250, 248, 239, 0.92);
    --text-primary: #776e65;
    --text-secondary: #9a8e82;
    --text-white: #ffffff;
    --text-on-dark: #f9f6f2;
    --text-dark: #776e65;
    --border: rgba(196, 185, 168, 0.5);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    /* 浅色主题 - 经典 2048 配色 */
    --tile-2: #eee4da;
    --tile-4: #ede0c8;
    --tile-8: #f2b179;
    --tile-16: #f59563;
    --tile-32: #f67c5f;
    --tile-64: #f65e3b;
    --tile-128: #edcf72;
    --tile-256: #edcc61;
    --tile-512: #edc850;
    --tile-1024: #edc53f;
    --tile-2048: #edc22e;
    --tile-super: #3c3a32;
    --tile-text-light: #776e65;
    --tile-text-dark: #f9f6f2;
}

[data-theme="dark"] {
    --primary: #f5c542;
    --primary-hover: #e0b335;
    --primary-light: rgba(245, 197, 66, 0.15);
    --bg-primary: #121212;
    --bg-secondary: #2c2c2c;
    --bg-card: #1e1e1e;
    --bg-card-empty: rgba(30, 42, 58, 0.5);
    --bg-overlay: rgba(10, 14, 20, 0.92);
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-white: #ffffff;
    --text-on-dark: #ffffff;
    --text-dark: #e0e0e0;
    --border: rgba(80, 80, 80, 0.6);
    --shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.6);
    /* 深色主题 - 霓虹渐变风格 */
    --tile-2: #1e2a3a;
    --tile-4: #263545;
    --tile-8: #e06070;
    --tile-16: #e87888;
    --tile-32: #f090a0;
    --tile-64: #f5a060;
    --tile-128: #f0c040;
    --tile-256: #f0d020;
    --tile-512: #f0e010;
    --tile-1024: #e040a0;
    --tile-2048: #4090f0;
    --tile-super: #9060f0;
    --tile-text-light: #1a1a1a;
    --tile-text-dark: #ffffff;
}

/* RTL */
[dir="rtl"] .header { flex-direction: row-reverse; }
[dir="rtl"] .header-left { flex-direction: row-reverse; }
[dir="rtl"] .header-right { flex-direction: row-reverse; }
[dir="rtl"] .game-toolbar { flex-direction: row-reverse; }
[dir="rtl"] .game-controls { flex-direction: row-reverse; }
[dir="rtl"] .overlay-buttons { flex-direction: row-reverse; }

/* Dark Theme Overrides for hardcoded elements */
[data-theme="dark"] .game-container {
    background: #141c28;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
[data-theme="dark"] .score-box {
    background: linear-gradient(135deg, #2c2c2c, #1e1e1e);
}
[data-theme="dark"] .new-game-btn {
    background: linear-gradient(135deg, #f5c542, #e0b335);
    box-shadow: 0 3px 8px rgba(245, 197, 66, 0.3);
}
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #f5c542, #e0b335);
    box-shadow: 0 3px 8px rgba(245, 197, 66, 0.3);
}
[data-theme="dark"] .stat-card,
[data-theme="dark"] .level-card,
[data-theme="dark"] .ranking-item {
    border-color: rgba(80, 80, 80, 0.4);
}
[data-theme="dark"] .tabs {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; background-color: var(--bg-primary); color: var(--text-primary); transition: background-color 0.3s, color 0.3s; }
body { display: flex; flex-direction: column; overflow-x: hidden; -webkit-text-size-adjust: 100% !important;}
#app { max-width: 520px; margin: 0 auto; padding: 1rem; width: 100%; }

/* Header */
.header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.header-left { display: flex; align-items: center; }
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logo img {
    width: 75px;
    height: 75px;
    object-fit: contain;
}
.logo-icon { display: inline-flex; align-items: center; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.game-controls { display: flex; gap: 0.5rem; }
.score-box {
    background: linear-gradient(135deg, #d4c4a8, #c0b090);
    color: var(--text-white);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-md);
    text-align: center;
    min-width: 75px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.score-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; opacity: 0.85; letter-spacing: 0.5px; }
.score-box div:last-child { font-size: 1.3rem; font-weight: 800; }

.lang-select select { appearance: auto; padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background-color: var(--bg-card); color: var(--text-primary); cursor: pointer; }
.theme-toggle { display: flex; align-items: center; cursor: pointer; padding: 0.25rem; border-radius: var(--radius-full); user-select: none; font-size: 1rem; }
.theme-toggle:hover { background-color: var(--primary-light); }
.user-profile { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-primary); }
.user-flag {font-size: 1.2rem;}
/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin: 1rem 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}
.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0.25rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn.active {
    background: var(--bg-primary);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.tab-btn:hover:not(.active) { background: rgba(255,255,255,0.5); }
.tab-icon { font-size: 1.25rem; }
.tab-content { position: relative; }
.tab-panel { display: none; }
.tab-panel.active { display: block; padding: 0.5rem 0; }

/* Game Area */
.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.toolbar-score {
    min-width: 0;
    flex: 1;
    padding: 0.25rem 0.75rem;
    text-align: center;
}

.toolbar-score .score-label {
    font-size: 0.6rem;
}

.toolbar-score div:last-child {
    font-size: 1.25rem;
}

.new-game-btn {
    background: var(--primary);
    color: var(--text-white);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
}

.new-game-btn:hover {
    background: var(--primary-hover);
}

.game-hint {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 2.5rem;
    text-align: center;
}
.tile-2 { background: var(--tile-2); color: var(--tile-text-light); } 
.tile-4 { background: var(--tile-4); color: var(--tile-text-light); } 
.tile-8 { background: var(--tile-8); color: var(--tile-text-dark); } 
.tile-16 { background: var(--tile-16); color: var(--tile-text-dark); }
.tile-32 { background: var(--tile-32); color: var(--tile-text-dark); } 
.tile-64 { background: var(--tile-64); color: var(--tile-text-dark); } 
.tile-128 { background: var(--tile-128); color: var(--tile-text-dark); font-size: clamp(1.25rem, 5vw, 2.75rem); box-shadow: 0 0 12px rgba(237, 207, 114, 0.4); }
.tile-256 { background: var(--tile-256); color: var(--tile-text-dark); font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 0 15px rgba(237, 204, 97, 0.5); }
.tile-512 { background: var(--tile-512); color: var(--tile-text-dark); font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 0 20px rgba(237, 200, 80, 0.6); }
.tile-1024 { background: var(--tile-1024); color: var(--tile-text-dark); font-size: clamp(1rem, 4vw, 2rem); box-shadow: 0 0 25px rgba(237, 197, 63, 0.7); }
.tile-2048 { background: var(--tile-2048); color: var(--tile-text-dark); font-size: clamp(1rem, 4vw, 2rem); box-shadow: 0 0 30px rgba(237, 194, 46, 0.8); }
.tile-super { background: var(--tile-super); color: var(--tile-text-dark); font-size: clamp(0.9rem, 3.5vw, 1.75rem); box-shadow: 0 0 35px rgba(60, 58, 50, 0.9); }
.tile-new { animation: tileAppear 0.2s ease; } .tile-merge { animation: tilePop 0.2s ease; }
@keyframes tileAppear { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes tilePop { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }
.game-overlay { position: absolute; inset: 0; background: var(--bg-overlay); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; z-index: 10; backdrop-filter: blur(3px); }
.overlay-content { text-align: center; padding: 2rem; }
.overlay-content h2 { font-size: clamp(1.5rem, 5vw, 2.5rem); margin-bottom: 0.75rem; color: var(--text-primary); }
.overlay-buttons { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, #f5a623, #e09600);
    color: var(--text-white);
    box-shadow: 0 3px 8px rgba(245, 166, 35, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #ffb833, #f5a623);
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.4);
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-primary); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }

/* Stats */
.stats-grid { display: grid; gap: 0.75rem; margin: 1rem 0; grid-template-columns: repeat(3, 1fr); }
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border);
    transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }
.stat-unit { font-size: 0.7rem; color: var(--text-secondary); }
.level-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border);
}
.level-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.level-badge { background: var(--primary); color: var(--text-white); padding: 0.25rem 0.75rem; border-radius: var(--radius-full); font-weight: 700; }
.xp-bar { width: 100%; height: 8px; background: var(--bg-card-empty); border-radius: var(--radius-full); overflow: hidden; margin-top: 0.5rem; }
.xp-progress { height: 100%; background: linear-gradient(90deg, var(--primary), #f5c542); border-radius: var(--radius-full); transition: width 0.5s; }

/* Rankings */
.panel-title { font-size: 1.1rem; font-weight: 700; margin: 0.5rem 0 1rem; color: var(--text-primary); }
.rankings-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.rankings-type-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.rankings-type-btn.active {
    background: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(245, 166, 35, 0.3);
}
.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-card);
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: transform 0.1s;
}
.ranking-item:hover { transform: translateX(2px); }
[dir="rtl"] .ranking-item:hover { transform: translateX(-2px); }
.ranking-item.is-current-user { background: var(--primary-light); }
.rank-position { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); font-weight: 700; flex-shrink: 0; }
.rank-1 { background: gold; color: #333; } .rank-2 { background: silver; color: #333; } .rank-3 { background: #cd7f32; color: #fff; }
.rank-avatar { font-size: 2.1rem; }
.rank-info { flex: 1; min-width: 0; }
.rank-nickname { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 0.75rem; color: var(--text-secondary); }
.rank-metric { font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.loading { text-align: center; padding: 2rem; color: var(--text-secondary); }

/* Profile & Custom Dropdown */
.profile-panel { padding-bottom: 2rem; }
.settings-section { display: flex; flex-direction: column; gap: 1.5rem; margin: 1rem 0; }
.setting-item { display: flex; flex-direction: column; gap: 0.4rem; }
.setting-label { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }
.setting-input, .custom-select-display {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
}
.setting-input:focus, .custom-select-wrapper.open .custom-select-display {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.setting-input-readonly {
    cursor: not-allowed !important;
    border-color: var(--border) !important;
    box-shadow: none !important;
}
/* Email Section */
.email-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.email-input-row .setting-input {
    flex: 1;
}
.email-input-row .btn-sm {
    white-space: nowrap;
}
.settings-actions .btn { width: 100%; padding: 0.8rem; margin-top: 0.5rem; }

.custom-select-wrapper { position: relative; user-select: none; }
.custom-select-wrapper.open .custom-select-display { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.custom-select-dropdown { display: none; position: absolute; top: calc(100% + 4px); left: 0; width: 100%; max-height: 240px; overflow-y: auto; background: var(--bg-card); border-radius: var(--radius-md); box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 100; }
.custom-select-wrapper.open .custom-select-dropdown { display: block; }
.custom-select-dropdown::-webkit-scrollbar { width: 6px; } .custom-select-dropdown::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
.custom-option { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; cursor: pointer; }
.custom-option:hover { background: var(--bg-secondary); }
.custom-option img, .custom-select-display img { width: 24px; height: 18px; border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.custom-select-display img { height: 18px; object-fit: cover; }

/* Modal & Toast */
.modal { position: fixed; inset: 0; z-index: 1000; } .modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-card); border-radius: var(--radius-lg); padding: 1.5rem; max-width: 400px; width: 90%; }
.modal-close { position: absolute; top: 10px; right: 15px; background: none; border: none; font-size: 1.5rem; color: var(--text-secondary); cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1rem; }

/* Auth Modal */
.auth-modal { max-width: 380px; padding: 2rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.75rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.form-error { color: #e74c3c; font-size: 0.85rem; padding: 0.35rem 0; }
.btn-block { width: 100%; padding: 0.7rem; font-size: 1rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.85rem; }
.auth-links a { color: var(--primary); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* Verify Email Form */
.verify-icon {
    font-size: 3rem;
    text-align: center;
    margin: 1rem 0;
}
.verify-message {
    text-align: center;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}
.verify-code-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-weight: 700;
    padding: 0.75rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: var(--text-white);
}

/* Auth Button (Header) */
.hidden { display: none !important; }
.auth-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary);
    color: var(--text-white);
    border: none;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.auth-btn:hover { background: var(--primary-hover); }
.auth-btn-icon { font-size: 1rem; }

.logout-btn {
    font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols2", Symbola, sans-serif;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem;
    margin-left: 0.3rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.logout-btn:hover { background: var(--bg-card); color: var(--text-primary); }

.toast-container { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast { padding: 0.75rem 1.5rem; border-radius: var(--radius-full); color: #fff; font-size: 0.9rem; animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; }
.toast-success { background: #27ae60; } .toast-error { background: #e74c3c; } .toast-info { background: #3498db; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* Responsive */
@media (max-width: 500px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-btn { padding: 0.4rem 0.15rem; font-size: 0.7rem; }
    .setting-item { gap: 0.25rem; }
    .user-profile { display: none; }
    .auth-btn span:last-child { display: none; }
}

/* ============================================================
   Game Area - Grid & Tiles (Core Layout)
   ============================================================ */

.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.new-game-btn {
    background: linear-gradient(135deg, #f5a623, #e09600);
    color: var(--text-white);
    border: none;
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(245, 166, 35, 0.3);
    transition: all 0.2s;
}

.new-game-btn:hover {
    background: linear-gradient(135deg, #ffb833, #f5a623);
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.4);
    transform: translateY(-1px);
}

/* Game Container */
.game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: #d6c8b4;
    border-radius: var(--radius-lg);
    padding: 10px;
    aspect-ratio: 1 / 1;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Grid - 4x4 Layout */
#grid {
    touch-action: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    height: 100%;
}

/* Tile - Base */
.tile {
    background: rgba(238, 228, 218, 0.55);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 7vw, 3rem);
    font-weight: 800;
    color: var(--text-dark);
    user-select: none;
    aspect-ratio: 1 / 1;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Tile Colors - Light Theme */
.tile-2   { background: #eee4da; color: #776e65; box-shadow: 0 2px 4px rgba(0,0,0,0.06); }
.tile-4   { background: #eee1c9; color: #776e65; box-shadow: 0 2px 4px rgba(0,0,0,0.06); }
.tile-8   { background: #f3b27a; color: #f9f6f2; box-shadow: 0 3px 8px rgba(243, 178, 122, 0.3); }
.tile-16  { background: #f69664; color: #f9f6f2; box-shadow: 0 3px 8px rgba(246, 150, 100, 0.3); }
.tile-32  { background: #f77c5f; color: #f9f6f2; box-shadow: 0 3px 10px rgba(247, 124, 95, 0.35); }
.tile-64  { background: #f75f3b; color: #f9f6f2; box-shadow: 0 3px 10px rgba(247, 95, 59, 0.4); }
.tile-128 { background: #f0d06c; color: #f9f6f2; font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 4px 14px rgba(240, 208, 108, 0.4); }
.tile-256 { background: #f0c858; color: #f9f6f2; font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 4px 16px rgba(240, 200, 88, 0.45); }
.tile-512 { background: #f0c044; color: #f9f6f2; font-size: clamp(1rem, 4vw, 2rem); box-shadow: 0 4px 18px rgba(240, 192, 68, 0.5); }
.tile-1024 { background: #f0b830; color: #f9f6f2; font-size: clamp(0.9rem, 3.5vw, 1.75rem); box-shadow: 0 5px 20px rgba(240, 184, 48, 0.55); }
.tile-2048 { background: #f0b020; color: #f9f6f2; font-size: clamp(0.9rem, 3.5vw, 1.75rem); box-shadow: 0 0 30px rgba(240, 176, 32, 0.6), 0 5px 20px rgba(240, 176, 32, 0.4); }
.tile-super { background: #5a4e44; color: #f9f6f2; font-size: clamp(0.8rem, 3vw, 1.5rem); box-shadow: 0 4px 16px rgba(90, 78, 68, 0.4); }

/* Dark Theme Tile Colors */
[data-theme="dark"] .tile-2   { background: #1e2a3a; color: #6888a8; }
[data-theme="dark"] .tile-4   { background: #263545; color: #7898b8; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
[data-theme="dark"] .tile-8   { background: #e06070; color: #fff; box-shadow: 0 3px 10px rgba(224,96,112,0.35); }
[data-theme="dark"] .tile-16  { background: #e87888; color: #fff; box-shadow: 0 3px 10px rgba(232,120,136,0.35); }
[data-theme="dark"] .tile-32  { background: #f090a0; color: #fff; box-shadow: 0 3px 12px rgba(240,144,160,0.4); }
[data-theme="dark"] .tile-64  { background: #f5a060; color: #fff; box-shadow: 0 4px 14px rgba(245,160,96,0.45); }
[data-theme="dark"] .tile-128 { background: #f0c040; color: #1a1a1a; font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 0 16px rgba(240,192,64,0.4); }
[data-theme="dark"] .tile-256 { background: #f0d020; color: #1a1a1a; font-size: clamp(1.25rem, 5vw, 2.5rem); box-shadow: 0 0 20px rgba(240,208,32,0.5); }
[data-theme="dark"] .tile-512 { background: #f0e010; color: #1a1a1a; font-size: clamp(1rem, 4vw, 2rem); box-shadow: 0 0 24px rgba(240,224,16,0.55); }
[data-theme="dark"] .tile-1024 { background: #e040a0; color: #fff; font-size: clamp(0.9rem, 3.5vw, 1.75rem); box-shadow: 0 0 28px rgba(224,64,160,0.5); }
[data-theme="dark"] .tile-2048 { background: #4090f0; color: #fff; font-size: clamp(0.9rem, 3.5vw, 1.75rem); box-shadow: 0 0 35px rgba(64,144,240,0.6), 0 0 60px rgba(64,144,240,0.25); }
[data-theme="dark"] .tile-super { background: #9060f0; color: #fff; font-size: clamp(0.8rem, 3vw, 1.5rem); box-shadow: 0 0 30px rgba(144,96,240,0.5); }

/* Tile Animations */
.tile-new { animation: tileAppear 0.2s ease; }
.tile-merge { animation: tilePop 0.2s ease; }
@keyframes tileAppear {
    0% { opacity: 0; transform: scale(0); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes tilePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(250, 248, 239, 0.92);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.overlay-content {
    text-align: center;
    padding: 2rem;
}

.overlay-content h2 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.overlay-content p {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.overlay-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Mobile Responsive */
@media (max-width: 500px) {
    #app { padding: 0.75rem; }
    .header { gap: 0.5rem; text-align: center;}
    .logo{
        font-size: 1rem;
        gap: 0.1rem;
    }
.logo img {
    width: 50px;
    height: 50px;
}
    .header-right {
        gap: 0.2rem;
    }
    .game-controls { gap: 0.35rem; }
    .score-box {
        padding: 0.5rem 0.5rem;
        min-width: 60px;
    }
    .score-box div:last-child { font-size: 1.1rem; }
    .lang-select select {
        padding: 0.2rem 0.3rem;
        font-size: 0.9rem;
        max-width: 80px;
    }
    .user-profile { 
        display: none; 
        gap: 0.45rem;
        font-size: 0.85rem;
    }
    .game-container { padding: 6px; }
    .game-hint {
    font-size: 0.85rem;
    }
    #grid { gap: 6px; }
    .tabs { gap: 2px; padding: 3px; }
    .tab-btn { padding: 0.4rem 0.15rem; font-size: 0.9rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Footer */
.footer {
    margin-top: 2rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.footer-content {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 1rem;
}
.footer-links {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.footer-label {
    font-weight: 600;
    color: var(--text-primary);
}
.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}
.footer-copyright p {
    margin: 0.25rem 0;
}
.footer-disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted, #999);
    margin-top: 0.5rem;
}

@media (max-width: 500px) {
    .footer-links {
        flex-direction: column;
        gap: 0.25rem;
    }
}