/* css/style.css - Premium 2026 Gaming UI - Dark Blue/Purple Neon Theme */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;800&family=Outfit:wght@300;400;600;700&family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
    --bg-main: radial-gradient(ellipse at 30% 20%, #0a1628 0%, #060d1a 40%, #030712 100%);
    --bg-darker: #020409;
    --accent-gold: linear-gradient(135deg, #f0c27f 0%, #e0a243 50%, #c4842d 100%);
    --accent-gold-glow: rgba(240, 194, 127, 0.35);
    --accent-green: #00e5a0;
    --accent-red: #ff4757;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    --accent-cyan: #06d6e0;
    --accent-neon: #7c3aed;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(148, 163, 184, 0.12);
    --glass-highlight: rgba(148, 163, 184, 0.2);
    --tile-bone: radial-gradient(circle at 35% 35%, #fffdf9 0%, #f4f0df 70%, #dfd9c4 100%);
    --tile-pip: #1c1c1c;
    --font-arabic: 'Tajawal', 'Cairo', sans-serif;
    --font-english: 'Outfit', sans-serif;
    --neon-glow-purple: 0 0 15px rgba(168, 85, 247, 0.4), 0 0 30px rgba(168, 85, 247, 0.1);
    --neon-glow-blue: 0 0 15px rgba(59, 130, 246, 0.4), 0 0 30px rgba(59, 130, 246, 0.1);
    --neon-glow-cyan: 0 0 15px rgba(6, 214, 224, 0.4), 0 0 30px rgba(6, 214, 224, 0.1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-darker);
    color: #e2e8f0;
    font-family: var(--font-arabic), var(--font-english);
    height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- APP CONTAINERS --- */
#app-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg-main);
    box-shadow: 0 0 80px rgba(124, 58, 237, 0.08), 0 0 120px rgba(0,0,0,0.9);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.app-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.app-screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

/* --- CORE GLASSMORPHISM STYLES --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}

.glass-btn {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
    padding: 13px 24px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-arabic);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.glass-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(168, 85, 247, 0.15) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.glass-btn:hover::after { opacity: 1; }

.glass-btn:hover:not(:disabled) {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(168, 85, 247, 0.35);
    transform: translateY(-2px);
    box-shadow: var(--neon-glow-purple);
}

.glass-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
    transition-duration: 0.1s;
}

.glass-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.glass-btn.primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #5b21b6 100%);
    color: #fff;
    border: 1px solid rgba(168, 85, 247, 0.5);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35), inset 0 1px 0 rgba(255,255,255,0.1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.glass-btn.primary:hover {
    box-shadow: 0 6px 30px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255,255,255,0.15);
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
}

.glass-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    width: 100%;
    text-align: center;
    font-family: var(--font-arabic);
    transition: border-color 0.2s ease;
}

.glass-input:focus {
    border-color: #ffd700;
}

/* --- PREMIUM MAIN MENU --- */
#screen-main-menu {
    justify-content: flex-start;
    align-items: center;
    padding: 20px 24px;
    gap: 24px;
}

/* Profile Island */
.menu-profile-island {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.profile-island-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-island-info {
    display: flex;
    flex-direction: column;
}

.pi-name {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.pi-level {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-green);
}

.profile-island-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.coins-badge-premium {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 6px 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 13px;
    font-weight: 800;
    color: #ffd700;
    box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.1);
}

.add-coins-btn {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #000;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
    transition: transform 0.2s;
}
.add-coins-btn:hover { transform: scale(1.1); }

.logout-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 62, 62, 0.15);
    border: 1px solid rgba(255, 62, 62, 0.3);
    color: #ff4757;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.logout-icon-btn:hover { background: rgba(255, 62, 62, 0.3); color: #fff; }

.menu-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.menu-logo-3d {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(25deg) rotateY(-20deg);
    animation: floatingLogo 4s ease-in-out infinite;
}

.logo-tile {
    position: absolute;
    width: 90px;
    height: 45px;
    background: var(--tile-bone);
    border-radius: 6px;
    border: 1px solid #c9c3ad;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.logo-tile-1 { top: 5px; left: 5px; transform: translateZ(10px); }
.logo-tile-2 { top: 40px; left: 15px; transform: translateZ(-10px) rotate(45deg); }

.logo-title-ar {
    font-size: 34px;
    font-weight: 900;
    background: linear-gradient(to bottom, #fff 30%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    letter-spacing: 1px;
}

.logo-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

.qa-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.qa-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.qa-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.qa-card span {
    font-size: 11px;
    font-weight: 700;
    color: #e2e8f0;
}

/* Premium Main Buttons */
.premium-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.main-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: right;
    position: relative;
    overflow: hidden;
}

.main-action-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: translateX(100%);
    transition: transform 0.5s ease;
}

.main-action-btn:hover::before {
    transform: translateX(-100%);
}

.main-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-left: 16px;
    background: rgba(0,0,0,0.2);
}

.btn-texts {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}

.bt-title {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    font-family: var(--font-arabic);
}

.bt-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-family: var(--font-arabic);
}

.btn-arrow {
    color: rgba(255,255,255,0.3);
    font-size: 14px;
    transition: transform 0.3s ease;
}

.main-action-btn:hover .btn-arrow {
    transform: translateX(-5px);
    color: #fff;
}

/* Specific Button Styles */
.lobby-btn {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(0, 136, 255, 0.05));
    border-color: rgba(0, 240, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}
.lobby-btn:hover { border-color: rgba(0, 240, 255, 0.6); box-shadow: 0 0 25px rgba(0, 240, 255, 0.2); }
.lobby-btn .btn-icon { background: linear-gradient(135deg, #00f0ff, #0088ff); color: #000; }
.lobby-btn .bt-title { color: #00f0ff; text-shadow: 0 0 10px rgba(0,240,255,0.5); }

.create-btn {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(124, 58, 237, 0.05));
    border-color: rgba(168, 85, 247, 0.3);
}
.create-btn:hover { border-color: rgba(168, 85, 247, 0.6); box-shadow: 0 0 20px rgba(168, 85, 247, 0.2); }
.create-btn .btn-icon { background: linear-gradient(135deg, #a855f7, #7c3aed); color: #fff; }

.join-btn {
    background: linear-gradient(135deg, rgba(0, 255, 170, 0.1), rgba(0, 150, 100, 0.05));
    border-color: rgba(0, 255, 170, 0.3);
}
.join-btn:hover { border-color: rgba(0, 255, 170, 0.6); box-shadow: 0 0 20px rgba(0, 255, 170, 0.2); }
.join-btn .btn-icon { background: linear-gradient(135deg, #00ffaa, #00b377); color: #000; }

.ai-btn {
    opacity: 0.9;
}
.ai-btn .btn-icon { background: rgba(255,255,255,0.1); color: #aaa; }

/* --- MODALS --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    max-height: 85%;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #ffd700;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mode-selectors {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.mode-option {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-option-card {
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.02);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.mode-option input:checked + .mode-option-card {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.15);
}

.modal-footer {
    display: flex;
    gap: 12px;
}

.modal-footer button {
    flex: 1;
}

/* --- LOBBY SCREEN --- */
#screen-lobby {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lobby-room-code-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.code-title {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.code-value-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.code-val {
    font-size: 28px;
    font-weight: 800;
    color: #ffd700;
    letter-spacing: 2px;
    font-family: var(--font-english);
}

.lobby-players-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
}

#lobby-players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-player-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-player-name {
    font-weight: 700;
}

.lobby-player-role {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.05);
    padding: 4px 8px;
    border-radius: 6px;
}

/* --- GAMEPLAY AREA --- */
#screen-game {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.game-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--glass-border);
}

.game-title-info {
    display: flex;
    flex-direction: column;
}

.game-code-badge {
    font-size: 14px;
    font-weight: 700;
    color: #ffd700;
    font-family: var(--font-english);
}

.score-hud-bar {
    display: flex;
    gap: 12px;
    background: rgba(255,255,255,0.05);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
}

.score-hud-item {
    display: flex;
    gap: 6px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 0;
}

.header-action-btn.muted {
    background: var(--accent-red);
    box-shadow: 0 0 10px rgba(255, 62, 62, 0.4);
}

/* --- THE GAME BOARD VELVET TABLE --- */
.table-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #0f4e37 0%, #03120d 100%);
    overflow: hidden;
}

.felt-ring {
    position: absolute;
    width: 90%;
    height: 90%;
    border: 2px dashed rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    pointer-events: none;
}

#board-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
    height: 180px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 40px;
    scroll-behavior: smooth;
    direction: ltr; /* Dominoes chain runs left to right in ltr display naturally */
}

/* Hide scrollbars but preserve scrolling */
#board-container::-webkit-scrollbar {
    display: none;
}

.board-empty-hint {
    color: rgba(255,255,255,0.4);
    font-size: 15px;
    width: 100%;
    text-align: center;
    font-style: italic;
    direction: rtl;
}

/* --- PLACING DOMINOS IN 3D BONE STYLE --- */
.domino-tile {
    position: relative;
    background: var(--tile-bone);
    border-radius: 6px;
    border: 1px solid #bfb799;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.5), 
                inset 1px 1px 1px rgba(255,255,255,0.8),
                inset -1px -1px 2px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    flex-shrink: 0;
    cursor: pointer;
}

/* Size standards */
.domino-tile.horizontal {
    width: 70px;
    height: 35px;
    flex-direction: row;
}

.domino-tile.vertical {
    width: 35px;
    height: 70px;
    flex-direction: column;
}

.domino-tile.hand-tile {
    width: 58px;
    height: 116px;
    flex-direction: column;
    margin: 0 4px;
}

.domino-tile.flipped {
    transform: rotate(180deg);
}

.tile-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.tile-divider {
    position: relative;
    background: #a89f7f;
}

.domino-tile.horizontal .tile-divider {
    width: 1px;
    height: 80%;
}

.domino-tile.vertical .tile-divider,
.domino-tile.hand-tile .tile-divider {
    height: 1px;
    width: 80%;
}

.brass-pin {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffd700 0%, #b8860b 100%);
    border: 0.5px solid #8b6508;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

/* --- DIPS/PIPS RENDERING SYSTEM --- */
.pip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 80%;
    height: 80%;
    padding: 2px;
}

.pip {
    border-radius: 50%;
    background: var(--tile-pip);
    box-shadow: inset 1px 1px 1px rgba(0,0,0,0.8), 0.5px 0.5px 0.5px rgba(255,255,255,0.3);
    margin: auto;
}

/* Size pips context-aware */
.domino-tile.horizontal .pip,
.domino-tile.vertical .pip {
    width: 5px;
    height: 5px;
}

.domino-tile.hand-tile .pip {
    width: 8px;
    height: 8px;
}

.pip.empty {
    opacity: 0;
}

/* --- HAND TILES INTERACTIVES --- */
.domino-tile.hand-tile.dimmed {
    opacity: 0.4;
    filter: grayscale(20%);
    pointer-events: none;
}

.domino-tile.hand-tile.playable {
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.4), 
                2px 4px 8px rgba(0,0,0,0.5);
}

.domino-tile.hand-tile.playable:hover {
    transform: translateY(-16px) scale(1.05);
    z-index: 10;
    box-shadow: 0 0 15px var(--accent-green), 
                0 10px 20px rgba(0,0,0,0.6);
}

.domino-tile.hand-tile.selected {
    transform: translateY(-24px) scale(1.08);
    border-color: #ffd700;
    box-shadow: 0 0 20px #ffd700, 
                0 12px 25px rgba(0,0,0,0.7);
    z-index: 15;
}

/* --- PLAY DROPAREA ZONES --- */
.board-dropzone {
    width: 50px;
    height: 60px;
    border: 2px dashed #ffd700;
    border-radius: 8px;
    background: rgba(255, 215, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffd700;
    font-size: 12px;
    font-weight: 700;
    animation: pulseDropzone 1.5s infinite;
    cursor: pointer;
    flex-shrink: 0;
}

@keyframes pulseDropzone {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.05); opacity: 0.9; }
    100% { transform: scale(1); opacity: 0.5; }
}

/* --- HUD POSITIONING SYSTEM (MESH 2v2/1v1) --- */
#players-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.player-slot {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 8px 12px;
    pointer-events: auto;
    max-width: 150px;
}

.player-slot.active-turn {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.08);
}

.player-slot.offline {
    opacity: 0.4;
}

/* Position mapping classes */
.player-slot.position-bottom {
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
}

.player-slot.position-top {
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
}

.player-slot.position-left {
    top: 45%;
    left: 10px;
    transform: translateY(-50%);
}

.player-slot.position-right {
    top: 45%;
    right: 10px;
    transform: translateY(-50%);
}

/* Avatar details */
.player-avatar-wrapper {
    position: relative;
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gold);
    color: #000;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.player-avatar-wrapper.speaking .player-avatar {
    animation: avatarSpeakWave 0.8s infinite;
}

@keyframes avatarSpeakWave {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 170, 0.6); }
    100% { box-shadow: 0 0 0 10px rgba(0, 255, 170, 0); }
}

.mic-status-indicator {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #333;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #000;
}

.mic-status-indicator.active {
    background: var(--accent-green);
    color: #000;
}

.mic-status-indicator.muted {
    background: var(--accent-red);
    color: #fff;
}

.mic-status-indicator.offline {
    background: #666;
    color: #fff;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

.player-status-line {
    display: flex;
    gap: 4px;
    font-size: 9px;
    color: rgba(255,255,255,0.6);
}

/* --- BOTTOM CONTROLS & HAND PANEL --- */
.game-bottom-controls {
    background: rgba(0, 0, 0, 0.7);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
}

.game-hud-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.hud-action-btn {
    flex: 1;
    font-size: 13px;
    padding: 8px 12px;
}

.hud-action-btn.glow {
    animation: glowButton 1.5s infinite alternate;
}

@keyframes glowButton {
    0% { border-color: rgba(0, 255, 170, 0.4); box-shadow: 0 0 5px rgba(0, 255, 170, 0.2); }
    100% { border-color: var(--accent-green); box-shadow: 0 0 15px rgba(0, 255, 170, 0.5); }
}

#hand-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 130px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 10px;
    direction: ltr; /* Flex hand rendering naturally in row direction */
}

#hand-container::-webkit-scrollbar {
    display: none;
}

/* --- SOCIAL BOX & CHAT DRAWER --- */
.social-drawer {
    display: flex;
    flex-direction: column;
    height: 180px;
    background: rgba(0,0,0,0.5);
    border-top: 1px solid var(--glass-border);
}

.reaction-bar {
    display: flex;
    justify-content: space-around;
    padding: 6px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.emoji-btn:active {
    transform: scale(1.3);
}

/* Floating Emoji bubble animations */
.emoji-bubble-container {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    width: 100px;
    height: 100px;
}

.emoji-bubble {
    position: absolute;
    bottom: 0;
    left: 50%;
    font-size: 28px;
    animation: riseEmoji 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes riseEmoji {
    0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; }
    80% { opacity: 0.8; }
    100% { transform: translate(calc(-50% + var(--drift-x)), -80px) scale(0.8); opacity: 0; }
}

/* Chat drawer UI */
.chat-drawer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11px;
    align-self: flex-start;
    max-width: 80%;
}

.chat-message.self {
    background: rgba(255, 215, 0, 0.15);
    align-self: flex-end;
}

.chat-sender {
    font-weight: 700;
    color: #ffd700;
    margin-left: 4px;
}

.chat-text {
    word-break: break-all;
}

/* Quick chat layout */
#quick-chat-phrases {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 12px;
    background: rgba(0,0,0,0.2);
}

#quick-chat-phrases::-webkit-scrollbar {
    display: none;
}

.quick-phrase-tag {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
}

.quick-phrase-tag:active {
    background: var(--glass-highlight);
}

.chat-input-row {
    display: flex;
    padding: 8px;
    gap: 8px;
    background: rgba(0,0,0,0.4);
}

#chat-input {
    flex: 1;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    text-align: right;
}

#send-chat-btn {
    padding: 6px 12px;
    font-size: 12px;
}

/* --- GENERAL UTILS / TOASTS --- */
.toast-msg {
    position: fixed;
    bottom: 220px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: rgba(0,0,0,0.85);
    border: 1.5px solid #ffd700;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.toast-msg.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Animations */
@keyframes floatingLogo {
    0% { transform: rotateX(25deg) rotateY(-20deg) translateY(0); }
    50% { transform: rotateX(25deg) rotateY(-20deg) translateY(-8px); }
    100% { transform: rotateX(25deg) rotateY(-20deg) translateY(0); }
}

/* --- PREMIUM TILE SKINS --- */
/* 1. Ivory Skin (Classic) */
.domino-tile.skin-ivory {
    background: radial-gradient(circle at 30% 30%, #fffdf0 0%, #ede6cd 70%, #dcd1a7 100%);
    border-color: #bfb799;
}
.domino-tile.skin-ivory .pip {
    background: #1c1c1c;
    box-shadow: inset 1px 1px 1px rgba(0,0,0,0.8), 0.5px 0.5px 0.5px rgba(255,255,255,0.4);
}

/* 2. Royal Marble Skin (Blue & Gold Veins) */
.domino-tile.skin-marble {
    background: linear-gradient(135deg, #091e36 0%, #123e6b 50%, #0d2f52 100%);
    border-color: #ffd700;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.6), inset 1px 1px 2px rgba(255,255,255,0.2);
}
.domino-tile.skin-marble .pip {
    background: radial-gradient(circle, #ffe875 0%, #d4af37 100%);
    box-shadow: 0.5px 0.5px 2px rgba(0,0,0,0.5);
}
.domino-tile.skin-marble .tile-divider {
    background: #ffd700;
}
.domino-tile.skin-marble .brass-pin {
    background: radial-gradient(circle, #ffffff 0%, #b0c4de 100%);
    border-color: #b0c4de;
}

/* 3. Gold Gilded Skin (Solid Gold Chrome) */
.domino-tile.skin-gold {
    background: linear-gradient(135deg, #fff3a1 0%, #d4af37 40%, #aa7c11 75%, #f3e5ab 100%);
    border-color: #ffd700;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4), 2px 2px 8px rgba(0,0,0,0.5);
}
.domino-tile.skin-gold .pip {
    background: #111;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.9);
}
.domino-tile.skin-gold .tile-divider {
    background: #aa7c11;
}

/* 4. Carbon Fiber Skin (Dark Tech Neon) */
.domino-tile.skin-carbon {
    background: linear-gradient(45deg, #111 25%, #1c1c1c 25%, #1c1c1c 50%, #111 50%, #111 75%, #1c1c1c 75%, #1c1c1c 100%);
    background-size: 8px 8px;
    border-color: #333;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.7);
}
.domino-tile.skin-carbon .pip {
    background: #00ffaa;
    box-shadow: 0 0 6px #00ffaa;
}
.domino-tile.skin-carbon .tile-divider {
    background: #555;
}
.domino-tile.skin-carbon .brass-pin {
    background: #00ffaa;
    border-color: #00ffaa;
}

/* 5. Cyber Neon Skin (Dark Glow) */
.domino-tile.skin-neon {
    background: #0c0813;
    border-color: #ff007f;
    box-shadow: 0 0 8px rgba(255, 0, 127, 0.5), inset 0 0 4px rgba(255, 0, 127, 0.3);
}
.domino-tile.skin-neon .pip {
    background: #00f0ff;
    box-shadow: 0 0 6px #00f0ff;
}
.domino-tile.skin-neon .tile-divider {
    background: #ff007f;
}
.domino-tile.skin-neon .brass-pin {
    background: #ff007f;
    border-color: #ff007f;
}

/* 6. Ruby Crystal Skin (ياقوت الجمر) */
.domino-tile.skin-ruby {
    background: radial-gradient(circle at 30% 30%, #ff4b4b 0%, #a80000 70%, #5e0000 100%);
    border-color: #ff2a2a;
    box-shadow: 0 0 10px rgba(255, 75, 75, 0.4), 2px 2px 8px rgba(0,0,0,0.5);
}
.domino-tile.skin-ruby .pip {
    background: #fff;
    box-shadow: 0 0 4px #fff, inset 0.5px 0.5px 1px rgba(0,0,0,0.4);
}
.domino-tile.skin-ruby .tile-divider {
    background: #ff7575;
}
.domino-tile.skin-ruby .brass-pin {
    background: #fff;
    border-color: #fff;
}

/* 7. Obsidian Magma Skin (الأوبسيديان البركاني) */
.domino-tile.skin-obsidian {
    background: radial-gradient(circle at 30% 30%, #2b2b2b 0%, #151515 70%, #050505 100%);
    border-color: #ff5500;
    box-shadow: 0 0 8px rgba(255, 85, 0, 0.3), 2px 2px 8px rgba(0,0,0,0.6);
}
.domino-tile.skin-obsidian .pip {
    background: #ff5500;
    box-shadow: 0 0 6px #ff7700;
}
.domino-tile.skin-obsidian .tile-divider {
    background: #ff5500;
}
.domino-tile.skin-obsidian .brass-pin {
    background: #ff7700;
    border-color: #ff7700;
}

/* 8. Polished Pearl Skin (اللؤلؤ المصقول) */
.domino-tile.skin-pearl {
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #f4e8ff 60%, #dec9ff 100%);
    border-color: #dec9ff;
    box-shadow: 0 0 8px rgba(222, 201, 255, 0.3), 2px 2px 8px rgba(0,0,0,0.3);
}
.domino-tile.skin-pearl .pip {
    background: #8e44ad;
    box-shadow: inset 0.5px 0.5px 1px rgba(0,0,0,0.3);
}
.domino-tile.skin-pearl .tile-divider {
    background: #c39bd3;
}
.domino-tile.skin-pearl .brass-pin {
    background: #8e44ad;
    border-color: #8e44ad;
}

/* 9. Forest Emerald Wood (زمرد الغابة) */
.domino-tile.skin-forest {
    background: linear-gradient(135deg, #1e4620 0%, #0f3011 50%, #051a06 100%);
    border-color: #ffd700;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.6);
}
.domino-tile.skin-forest .pip {
    background: radial-gradient(circle, #ffe875 0%, #d4af37 100%);
    box-shadow: 0.5px 0.5px 2px rgba(0,0,0,0.5);
}
.domino-tile.skin-forest .tile-divider {
    background: #ffd700;
}
.domino-tile.skin-forest .brass-pin {
    background: #ffd700;
    border-color: #ffd700;
}

/* 10. Cyberpunk 2077 Skin (سايبر بانك 2077) */
.domino-tile.skin-cyberpunk {
    background: #fcee0a;
    border-color: #00f0ff;
    box-shadow: 0 0 8px rgba(252, 238, 10, 0.4), 2px 2px 8px rgba(0,0,0,0.5);
}
.domino-tile.skin-cyberpunk .pip {
    background: #00f0ff;
    box-shadow: 0 0 4px #00f0ff;
}
.domino-tile.skin-cyberpunk .tile-divider {
    background: #902e9f;
}
.domino-tile.skin-cyberpunk .brass-pin {
    background: #902e9f;
    border-color: #902e9f;
}

/* 11. Galactic Nebula Skin (المجرة النجمية) */
.domino-tile.skin-galactic {
    background: radial-gradient(circle at center, #6600cc 0%, #1a0033 60%, #050010 100%);
    border-color: #bf00ff;
    box-shadow: 0 0 10px rgba(191, 0, 255, 0.5), 2px 2px 8px rgba(0,0,0,0.6);
}
.domino-tile.skin-galactic .pip {
    background: #fff;
    box-shadow: 0 0 8px #fff, 0 0 12px #bf00ff;
}
.domino-tile.skin-galactic .tile-divider {
    background: #bf00ff;
}
.domino-tile.skin-galactic .brass-pin {
    background: #fff;
    border-color: #fff;
}

/* 12. Vintage Copper Skin (النحاس العتيق) */
.domino-tile.skin-copper {
    background: linear-gradient(135deg, #d37546 0%, #a14c22 40%, #703010 80%, #d37546 100%);
    border-color: #552200;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}
.domino-tile.skin-copper .pip {
    background: #2e1405;
    box-shadow: inset 1px 1px 1px rgba(0,0,0,0.8);
}
.domino-tile.skin-copper .tile-divider {
    background: #552200;
}
.domino-tile.skin-copper .brass-pin {
    background: #552200;
    border-color: #552200;
}

/* --- PREMIUM TABLE FELT THEMES --- */
/* 1. Emerald (Classic) */
.table-area.theme-emerald {
    background: radial-gradient(circle at center, #0f4e37 0%, #03120d 100%);
}
/* 2. Royal Blue */
.table-area.theme-royal {
    background: radial-gradient(circle at center, #0e3054 0%, #030a12 100%);
}
/* 3. Shadow Obsidian */
.table-area.theme-obsidian {
    background: radial-gradient(circle at center, #262626 0%, #0a0a0a 100%);
    background-image: radial-gradient(circle at center, #262626 0%, #0a0a0a 100%), repeating-linear-gradient(45deg, rgba(255,255,255,0.01) 0px, rgba(255,255,255,0.01) 2px, transparent 2px, transparent 10px);
}
/* 4. Velvet Crimson */
.table-area.theme-crimson {
    background: radial-gradient(circle at center, #6b0f1a 0%, #1f0307 100%);
}

/* 5. Royal Amethyst (الأرجوان الملكي) */
.table-area.theme-amethyst {
    background: radial-gradient(circle at center, #4b0e5c 0%, #180321 100%);
}
/* 6. Desert Dunes (رمل الصحراء) */
.table-area.theme-sand {
    background: radial-gradient(circle at center, #cfa863 0%, #59411c 100%);
    background-image: radial-gradient(circle at center, #cfa863 0%, #59411c 100%), repeating-radial-gradient(circle, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 4px, transparent 4px, transparent 20px);
}
/* 7. Futuristic Grid (مقصورة المستقبل) */
.table-area.theme-futuristic {
    background: radial-gradient(circle at center, #062630 0%, #020b0e 100%);
    background-image: linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}
/* 8. Mahogany Wood (طاولة الخشب الكلاسيكية) */
.table-area.theme-wooden {
    background: radial-gradient(circle at center, #572d15 0%, #1f0b01 100%);
    background-image: radial-gradient(circle at center, rgba(87,45,21,0.5) 0%, rgba(31,11,1,0.9) 100%), repeating-linear-gradient(0deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 10px, transparent 10px, transparent 20px);
}
/* 9. Sakura Blossom (أزهار الكرز) */
.table-area.theme-sakura {
    background: radial-gradient(circle at center, #b55a79 0%, #3d1421 100%);
}
/* 10. Frozen Ice Felt (الجليد الأزرق) */
.table-area.theme-ice {
    background: radial-gradient(circle at center, #4293a3 0%, #0e272d 100%);
    background-image: radial-gradient(circle at center, #4293a3 0%, #0e272d 100%), repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 2px, transparent 2px, transparent 12px);
}
/* 11. Luxury Gold Lounge (صالة كبار الشخصيات) */
.table-area.theme-gold_lounge {
    background: radial-gradient(circle at center, #2e2612 0%, #0d0a04 100%);
    background-image: radial-gradient(circle at center, #2e2612 0%, #0d0a04 100%), repeating-linear-gradient(135deg, rgba(212,175,55,0.015) 0px, rgba(212,175,55,0.015) 2px, transparent 2px, transparent 15px);
}

/* --- PREMIUM AVATAR FRAMES --- */
.avatar-frame-wrapper {
    position: relative;
    padding: 3px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 1. Normal */
.avatar-frame-wrapper.normal {
    border: 2px solid transparent;
}
/* 2. Neon */
.avatar-frame-wrapper.neon {
    border: 2px solid #00ffaa;
    box-shadow: 0 0 10px #00ffaa;
    animation: pulseFrameNeon 1.5s infinite alternate;
}
@keyframes pulseFrameNeon {
    0% { box-shadow: 0 0 4px #00ffaa; }
    100% { box-shadow: 0 0 12px #00ffaa; }
}
/* 3. Gold Spark */
.avatar-frame-wrapper.gold {
    border: 2px solid #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, #ffd700, #b8860b);
}
/* 4. Fire */
.avatar-frame-wrapper.fire {
    border: 2px solid #ff4500;
    box-shadow: 0 0 12px #ff4500;
    animation: pulseFrameFire 1s infinite alternate;
}
@keyframes pulseFrameFire {
    0% { box-shadow: 0 0 6px #ff4500, 0 0 12px #ff8c00; border-color: #ff4500; }
    100% { box-shadow: 0 0 14px #ff4500, 0 0 20px #ff3e3e; border-color: #ff8c00; }
}
/* 5. Ice */
.avatar-frame-wrapper.ice {
    border: 2px solid #00f0ff;
    box-shadow: 0 0 12px #00f0ff;
    background: linear-gradient(135deg, #00f0ff, #0077ff);
}

/* 6. Rainbow Pulse (إطار قوس قزح) */
.avatar-frame-wrapper.rainbow {
    border: 2px solid transparent;
    background-image: linear-gradient(#121829, #121829), linear-gradient(135deg, #ff007f, #ff7f00, #ffea00, #00ffaa, #00f0ff, #7f00ff, #ff007f);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 12px rgba(255, 0, 127, 0.4);
    animation: rotateRainbow 3s linear infinite;
}
@keyframes rotateRainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

/* 7. Diamond Shimmer (إطار الألماس) */
.avatar-frame-wrapper.diamond {
    border: 2px solid #e0f7fa;
    box-shadow: 0 0 15px #e0f7fa, inset 0 0 4px #ffffff;
    animation: flashDiamond 2s infinite alternate;
}
@keyframes flashDiamond {
    0% { box-shadow: 0 0 8px rgba(224, 247, 250, 0.6); }
    100% { box-shadow: 0 0 20px rgba(224, 247, 250, 1), 0 0 30px #ffffff; }
}

/* 8. Lightning Flashing (إطار البرق الصاعق) */
.avatar-frame-wrapper.lightning {
    border: 2px solid #ffd700;
    box-shadow: 0 0 12px #ffd700;
    animation: flashLightning 0.8s infinite steps(2);
}
@keyframes flashLightning {
    0%, 100% { border-color: #ffd700; box-shadow: 0 0 10px #ffd700; }
    50% { border-color: #ffffff; box-shadow: 0 0 20px #ffffff, 0 0 30px #ffd700; }
}

/* 9. Nature Green (إطار الطبيعة الأخضر) */
.avatar-frame-wrapper.nature {
    border: 2px solid #00ffaa;
    box-shadow: 0 0 10px #00ffaa;
    animation: pulseFrameGreen 2s infinite ease-in-out;
}
@keyframes pulseFrameGreen {
    0%, 100% { box-shadow: 0 0 4px rgba(0, 255, 170, 0.5); }
    50% { box-shadow: 0 0 16px rgba(0, 255, 170, 0.9); }
}

/* 10. Portal vortex (إطار الثقب الدودي) */
.avatar-frame-wrapper.portal {
    border: 2px dashed #9900ff;
    box-shadow: 0 0 15px #9900ff;
    animation: rotatePortal 4s linear infinite;
}
@keyframes rotatePortal {
    100% { transform: rotate(-360deg); }
}

/* 11. Dark Shadow (إطار الظل المظلم) */
.avatar-frame-wrapper.shadow {
    border: 2px solid #333333;
    box-shadow: 0 0 15px #000000;
    background: rgba(0, 0, 0, 0.6);
}
.avatar-frame-wrapper.shadow:hover {
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
    border-color: #000000;
}

/* 12. Mechanical Steampunk (إطار ستيمبانك) */
.avatar-frame-wrapper.steampunk {
    border: 2px solid #b8860b;
    box-shadow: 0 0 10px rgba(184, 134, 11, 0.5);
    background: repeating-conic-gradient(from 0deg, #b8860b 0deg 30deg, #8b4513 30deg 60deg);
}

/* --- LUCKY WHEEL INTERNAL LABELS --- */
.wheel-seg {
    position: absolute;
    width: 50%;
    height: 50%;
    top: 50%;
    left: 50%;
    transform-origin: 0% 0%;
    transform: rotate(var(--rot)) translate(-50%, -100%);
    text-align: center;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    font-family: var(--font-english);
    z-index: 5;
    padding-top: 15px;
}

/* --- SHOP PANEL GRID --- */
.shop-item-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    transition: all 0.2s ease;
}
.shop-item-card:hover {
    border-color: rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
}
.shop-item-card.equipped {
    border-color: var(--accent-green);
    background: rgba(0, 255, 170, 0.05);
}
.shop-item-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- PROFILE STATS ROW --- */
.history-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 11px;
}
.history-item-row.win {
    border-color: rgba(0, 255, 170, 0.15);
    background: rgba(0, 255, 170, 0.02);
}
.history-item-row.loss {
    border-color: rgba(255, 62, 62, 0.15);
    background: rgba(255, 62, 62, 0.02);
}

/* --- LEADERBOARD CARD --- */
.leaderboard-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12px;
}
.leaderboard-item-row.rank-1 {
    border-color: #ffd700;
    background: rgba(255,215,0,0.05);
}

/* --- SCREEN SHAKE EFFECT --- */
.shake-effect {
    animation: screenShake 0.4s ease-out;
}
@keyframes screenShake {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-4px, 3px); }
    30% { transform: translate(4px, -3px); }
    50% { transform: translate(-3px, -2px); }
    70% { transform: translate(2px, 3px); }
    90% { transform: translate(-1px, -1px); }
    100% { transform: translate(0, 0); }
}

/* ================================================================
   LOGIN / REGISTER SCREEN
   ================================================================ */
#screen-login {
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: var(--bg-main);
    overflow-y: auto;
}

.login-container {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.login-form {
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}

.login-form-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 4px;
}

/* Phone input with country code */
.phone-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
    direction: ltr;
}

.country-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    transition: border-color 0.2s ease;
    min-width: 110px;
    justify-content: center;
}

.country-selector:hover {
    border-color: #ffd700;
}

.phone-input {
    flex: 1;
    text-align: left !important;
    font-family: var(--font-english), var(--font-arabic) !important;
    font-size: 16px !important;
    letter-spacing: 1px;
}

/* Country Dropdown */
.country-dropdown {
    position: absolute;
    top: 115px;
    left: 20px;
    right: 20px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid #ffd700;
    border-radius: 12px;
    padding: 10px;
    max-height: 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 99;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.country-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.country-list::-webkit-scrollbar {
    width: 4px;
}
.country-list::-webkit-scrollbar-thumb {
    background: rgba(255,215,0,0.3);
    border-radius: 4px;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #fff;
    transition: background 0.15s ease;
    direction: ltr;
}

.country-item:hover {
    background: rgba(255, 215, 0, 0.1);
}

.country-item.selected {
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.country-item img {
    width: 24px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
}

.country-item-code {
    color: #ffd700;
    font-weight: 700;
    font-family: var(--font-english);
    min-width: 50px;
}

.country-item-name {
    flex: 1;
    text-align: right;
    font-family: var(--font-arabic);
}

/* Password input group */
.password-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-group .glass-input {
    padding-left: 44px;
}

.toggle-pass-btn {
    position: absolute;
    left: 10px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: color 0.2s;
}

.toggle-pass-btn:hover {
    color: #ffd700;
}

/* Login button */
.login-btn {
    width: 100%;
    padding: 14px !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    border-radius: 14px !important;
    margin-top: 4px;
}

.login-hint {
    text-align: center;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    line-height: 1.5;
}

.login-error {
    background: rgba(255, 62, 62, 0.15);
    border: 1px solid rgba(255, 62, 62, 0.3);
    color: #ff6b6b;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    width: 100%;
    max-width: 380px;
    animation: shakeError 0.4s ease;
}

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

/* Loading spinner on login button */
.login-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.login-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ================================================================
   MOBILE LANDSCAPE ORIENTATION (Portrait -> rotate to landscape)
   Only on mobile devices, NOT on desktop
   ================================================================ */
@media screen and (max-width: 900px) and (orientation: portrait) {
    #app-wrapper {
        width: 100%;
        height: 100%;
        max-width: none;
    }

    /* Adjust login screen for portrait view */
    #screen-login {
        padding: 24px 16px;
    }

    .login-container {
        flex-direction: column;
        max-width: 100%;
        gap: 20px;
        align-items: center;
        justify-content: center;
    }

    .login-form {
        max-width: 100%;
        width: 100%;
    }
}

/* Already landscape on mobile - no rotation needed */
@media screen and (max-width: 900px) and (orientation: landscape) {
    #app-wrapper {
        max-width: none;
        width: 100%;
        height: 100%;
    }

    #screen-login {
        padding: 10px 20px;
    }

    .login-container {
        flex-direction: row;
        max-width: 100%;
        gap: 24px;
        align-items: center;
        justify-content: center;
    }

    .login-logo-area {
        flex: 0 0 auto;
    }

    .login-form {
        max-width: 320px;
    }
}

/* Desktop - no rotation, centered layout */
@media screen and (min-width: 901px) {
    #app-wrapper {
        max-width: 100%;
        width: 100%;
        height: 100vh;
    }

    #screen-login .login-container {
        flex-direction: row;
        max-width: 700px;
        gap: 40px;
    }

    .login-logo-area {
        flex: 0 0 auto;
    }

    .login-form {
        max-width: 380px;
    }
}

/* ================================================================
   MOBILE GAME SCREEN COMPATIBILITY (landscape forced)
   ================================================================ */
@media screen and (max-width: 900px) and (orientation: portrait) {
    /* Game elements scale for landscape-rotated view */
    .game-header {
        padding: 6px 10px;
    }

    .game-code-badge {
        font-size: 11px;
    }

    .score-hud-bar {
        font-size: 10px;
        padding: 4px 8px;
    }

    .header-action-btn {
        width: 30px;
        height: 30px;
    }

    #board-container {
        height: 120px;
        padding: 10px 20px;
    }

    .domino-tile.horizontal {
        width: 52px;
        height: 26px;
    }

    .domino-tile.vertical {
        width: 26px;
        height: 52px;
    }

    .domino-tile.hand-tile {
        width: 40px;
        height: 80px;
        margin: 0 2px;
    }

    .domino-tile.hand-tile .pip {
        width: 6px;
        height: 6px;
    }

    #hand-container {
        height: 95px;
        padding: 8px 6px;
    }

    .game-bottom-controls {
        padding: 6px 8px;
        gap: 6px;
    }

    .social-drawer {
        height: 100px;
    }

    .emoji-btn {
        font-size: 16px;
    }

    .player-slot {
        padding: 4px 8px;
        max-width: 120px;
    }

    .player-slot.position-bottom {
        bottom: 8px;
    }
    .player-slot.position-top {
        top: 8px;
    }
    .player-slot.position-left {
        left: 8px;
        top: 45%;
    }
    .player-slot.position-right {
        right: 8px;
        top: 45%;
    }

    .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .player-name {
        font-size: 10px;
        max-width: 65px;
    }

    /* Main menu responsive in landscape rotation */
    #screen-main-menu {
        padding: 12px;
        gap: 12px;
    }

    .menu-logo-3d {
        width: 60px !important;
        height: 60px !important;
    }

    .logo-title-ar {
        font-size: 22px;
    }

    .menu-buttons {
        gap: 8px;
    }

    .menu-buttons .glass-btn {
        padding: 8px 14px !important;
        font-size: 13px;
    }

    /* Lobby responsive */
    #screen-lobby {
        padding: 12px;
        gap: 12px;
    }

    .code-val {
        font-size: 20px;
    }
}

/* Landscape mobile native */
@media screen and (max-width: 900px) and (orientation: landscape) {
    .game-header {
        padding: 6px 10px;
    }

    #board-container {
        height: 120px;
        padding: 10px 20px;
    }

    .domino-tile.hand-tile {
        width: 42px;
        height: 84px;
        margin: 0 2px;
    }

    #hand-container {
        height: 100px;
        padding: 8px 6px;
    }

    .social-drawer {
        height: 110px;
    }

    #screen-main-menu {
        padding: 12px;
        gap: 16px;
    }

    .player-slot {
        padding: 4px 8px;
        max-width: 120px;
    }

    .player-slot.position-bottom {
        bottom: 8px;
    }
    .player-slot.position-top {
        top: 8px;
    }
    .player-slot.position-left {
        left: 8px;
        top: 45%;
    }
    .player-slot.position-right {
        right: 8px;
        top: 45%;
    }

    .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .player-name {
        font-size: 10px;
        max-width: 65px;
    }
}

/* ================================================================
   NATIVE PORTRAIT MOBILE RESPONSIVENESS FIXES (100% COMPATIBILITY)
   ================================================================ */
@media screen and (max-width: 600px) and (orientation: portrait) {
    /* App Wrapper full screen */
    #app-wrapper {
        width: 100%;
        height: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Main Menu Adjustments */
    .menu-profile-bar {
        flex-direction: column !important;
        gap: 12px;
        text-align: center;
        padding: 16px !important;
    }
    .menu-profile-bar > div {
        justify-content: center;
        width: 100%;
    }
    #screen-main-menu > div[style*="justify-content:center"] {
        flex-direction: column;
        gap: 8px !important;
    }
    .logo-title-ar { font-size: 28px !important; }
    .menu-buttons .glass-btn { padding: 12px !important; font-size: 13px; }
    
    /* Modals (Create Room, Join, Profile, Shop) */
    .modal-content {
        padding: 16px !important;
        width: 92% !important;
        margin: 0 auto;
        gap: 12px !important;
    }
    .modal-header h3 { font-size: 16px !important; }
    .mode-selectors { flex-direction: column; gap: 8px; }
    .modal-footer { flex-direction: column; gap: 8px; }
    .modal-footer button { width: 100%; }

    /* Game Room Header & Layout */
    .game-header {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        min-height: auto;
    }
    .game-title-info { align-items: center; }
    .header-actions {
        width: 100%;
        justify-content: center;
        gap: 12px;
    }
    
    /* Bottom Controls */
    .game-bottom-controls { padding: 8px; }
    .game-hud-buttons { flex-wrap: wrap; justify-content: center; }
    .hud-action-btn { max-width: 100%; }

    /* Lobby Waiting Room */
    .lobby-header { flex-direction: column; gap: 10px; }
    .lobby-header button { align-self: flex-start; }
    .lobby-room-code-card { padding: 12px; }
    .code-val { font-size: 20px !important; }

    /* Social 3D Lobby */
    .lobby-top-bar {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }
    .lobby-top-bar .lobby-online-badge { align-self: flex-end; margin-top: -30px; }
    .lobby-bottom-bar { flex-wrap: wrap; }
    .lobby-chat-input-wrap {
        width: 100%;
        order: 3;
        margin-top: 8px;
    }
    .lobby-player-panel { padding: 16px; }
    .panel-actions { flex-direction: column; }
    
    /* Profile Stats */
    #modal-profile .stat-card { padding: 8px; }
    #profile-avatar-initials { width: 50px !important; height: 50px !important; font-size: 20px !important; }

    /* Shop Adjustments */
    .ts-grid { grid-template-columns: 1fr; }
    .ts-category-tabs { padding: 0 4px; }
    .ts-cat-tab { padding: 8px 4px; font-size: 10px; }
}
