:root {
    --primary: #38bdf8;
    --primary-dark: #0f3d5c;
    --primary-light: #93c5fd;
    --secondary: #f59e0b;
    --accent: #34d399;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #03050a;
    --dark-1: rgba(8, 13, 24, 0.9);
    --dark-2: rgba(13, 20, 34, 0.94);
    --dark-3: rgba(28, 39, 58, 0.94);
    --text: #f8fbff;
    --text-muted: #a8b4c7;
    --gold: #fbbf24;
    --silver: #cbd5e1;
    --bronze: #b45309;
    --gradient-main: linear-gradient(135deg, #38bdf8 0%, #34d399 100%);
    --gradient-gold: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
    --gradient-fire: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
    --gradient-win: linear-gradient(135deg, #34d399 0%, #38bdf8 100%);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 22px rgba(56, 189, 248, 0.22);
    --glass-border: rgba(147, 197, 253, 0.16);
    --glass-fill: rgba(5, 10, 20, 0.82);
    --scanline: rgba(255, 255, 255, 0.028);
    --radius: 8px;
    --radius-sm: 10px;
    --radius-xs: 6px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background:
        radial-gradient(circle at 18% 12%, rgba(64, 255, 191, 0.16), transparent 22rem),
        radial-gradient(circle at 86% 20%, rgba(0, 213, 255, 0.19), transparent 24rem),
        radial-gradient(circle at 50% 100%, rgba(255, 122, 24, 0.13), transparent 26rem),
        linear-gradient(145deg, #05070c 0%, #09111f 48%, #0d1320 100%);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    touch-action: pan-y;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    z-index: 0;
    background:
        linear-gradient(var(--scanline) 1px, transparent 1px),
        linear-gradient(90deg, var(--scanline) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(circle at center, black 0%, transparent 72%);
    animation: gridDrift 14s linear infinite;
}

body::after {
    z-index: 0;
    background:
        linear-gradient(115deg, transparent 0 42%, rgba(0, 213, 255, 0.12) 48%, transparent 54% 100%);
    transform: translateX(-120%);
    animation: arenaSweep 5.5s ease-in-out infinite;
}

@keyframes gridDrift {
    to { background-position: 46px 46px; }
}

@keyframes arenaSweep {
    0%, 36% { transform: translateX(-120%); opacity: 0; }
    48% { opacity: 1; }
    66%, 100% { transform: translateX(120%); opacity: 0; }
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.32;
    box-shadow: 0 0 16px currentColor;
    animation: float 5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.3; }
    50% { transform: translateY(-30px) rotate(180deg); opacity: 0.6; }
}

.app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app::before {
    content: "";
    position: fixed;
    left: 50%;
    top: 50%;
    width: min(92vw, 520px);
    height: min(92vw, 520px);
    border: 1px solid rgba(125, 211, 252, 0.14);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        inset 0 0 70px rgba(0, 213, 255, 0.06),
        0 0 80px rgba(64, 255, 191, 0.08);
    pointer-events: none;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.lang-toggle {
    min-width: 92px;
    padding: 9px 12px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

[dir="rtl"] .top-bar {
    justify-content: flex-start;
}

.screen {
    display: none;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
    padding-bottom: 20px;
    width: 100%;
}

.screen.active {
    display: flex;
    min-height: calc(100vh - 72px);
    min-height: calc(100dvh - 72px);
    position: relative;
}

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

/* Menu Screen */
.logo {
    text-align: center;
    margin-bottom: 26px;
    padding-top: 6px;
}

.crown {
    font-size: 4rem;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(251, 191, 36, 0.62));
}

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

.logo h1 {
    font-size: clamp(2.55rem, 11vw, 4.15rem);
    font-weight: 900;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0;
    text-shadow: 0 0 38px rgba(0, 213, 255, 0.18);
}

.logo h1 span {
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 5px;
    letter-spacing: 0;
    text-transform: uppercase;
}

/* Player Setup */
.player-setup {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
}

.player-card {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 42%),
        var(--glass-fill);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 22px 46px rgba(0, 0, 0, 0.26);
    transition: all 0.3s ease;
    backdrop-filter: blur(18px);
}

.player-card::before,
.option-panel::before,
.speaker-panel::before,
.winner-display::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(0, 213, 255, 0.7), transparent 34%, rgba(255, 230, 109, 0.45));
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

.player-card:hover {
    border-color: rgba(125, 211, 252, 0.6);
    transform: translateY(-4px);
    box-shadow: 0 28px 58px rgba(0, 0, 0, 0.34), var(--shadow-glow);
}

.player-avatar {
    font-size: 2.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 0 10px rgba(124, 58, 237, 0.3));
}

.player-avatar:hover {
    transform: scale(1.2) rotate(10deg);
}

.player-card input {
    width: 100%;
    background: rgba(2, 6, 23, 0.62);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    text-align: center;
    transition: all 0.3s ease;
}

.player-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.player-card input::placeholder {
    color: var(--text-muted);
}

.symbol-select {
    display: flex;
    gap: 8px;
}

.symbol-btn {
    width: 40px;
    height: 40px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.symbol-btn:hover {
    background: rgba(0, 213, 255, 0.14);
    transform: translateY(-3px) rotate(-2deg);
}

.symbol-btn.active {
    background: var(--gradient-main);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-glow);
}

.vs {
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 18px rgba(255, 47, 109, 0.75), 0 0 36px rgba(0, 213, 255, 0.34);
    white-space: nowrap;
}

.mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.mode-btn {
    width: 100%;
    padding: 8px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: var(--dark-3);
}

.mode-btn.active {
    background: var(--gradient-main);
    color: var(--text);
    box-shadow: var(--shadow-glow);
}

/* Difficulty Panel */
.difficulty-panel {
    display: none;
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.option-panel {
    position: relative;
    overflow: hidden;
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.option-panel h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-align: center;
}

.option-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.choice-btn {
    min-height: 42px;
    padding: 9px 8px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
}

.choice-btn:hover {
    color: var(--text);
    border-color: rgba(96, 165, 250, 0.5);
}

.choice-btn.active {
    color: var(--text);
    background: var(--gradient-main);
    box-shadow: var(--shadow-glow);
}

.difficulty-panel.show {
    display: block;
}

.difficulty-panel h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-align: center;
}

.diff-options {
    display: flex;
    gap: 8px;
}

.diff-btn {
    flex: 1;
    padding: 10px 5px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.diff-btn:hover {
    background: var(--dark-3);
    color: var(--text);
}

.diff-btn.active {
    background: var(--gradient-main);
    color: var(--text);
    border-color: var(--primary-light);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: 'Tajawal', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 58px;
    position: relative;
    overflow: hidden;
}

.action-btn.primary {
    background: var(--gradient-main);
    color: #031018;
    box-shadow: var(--shadow-glow);
}

.action-btn.primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
    transform: translateX(-120%);
    transition: transform 0.55s ease;
}

.action-btn.primary:hover::after {
    transform: translateX(120%);
}

.action-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 48px rgba(0, 213, 255, 0.45);
}

.action-btn.secondary {
    background: var(--glass-fill);
    color: var(--text);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.action-btn.secondary:hover {
    border-color: var(--primary);
}

.action-btn.danger {
    background: var(--dark-1);
    color: var(--danger);
    border: 2px solid var(--danger);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.match-info {
    display: flex;
    gap: 15px;
}

.round, .timer {
    background: var(--glass-fill);
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(148, 163, 184, 0.16);
    backdrop-filter: blur(16px);
}

.timer {
    font-family: monospace;
    color: var(--accent);
}

.menu-btn {
    width: 40px;
    height: 40px;
    background: var(--glass-fill);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-btn:hover {
    background: var(--danger);
    color: white;
}

/* Score Display */
.score-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.player-info {
    flex: 1;
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    backdrop-filter: blur(18px);
}

.player-info.active {
    background: linear-gradient(180deg, rgba(0, 213, 255, 0.22), rgba(64, 255, 191, 0.08));
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
    border-color: var(--primary-light);
}

.player-info .avatar {
    font-size: 2rem;
}

.player-info .name {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-info .score {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text);
}

.player-info .symbol-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-light);
}

.vs-divider {
    font-size: 1.5rem;
    color: var(--danger);
    font-weight: 900;
}

.live-indicator {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.75);
    animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.18); opacity: 1; }
}

.speaker-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(64, 255, 191, 0.13), rgba(0, 213, 255, 0.12));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    min-height: 72px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(18px);
}

.speaker-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.7);
    font-size: 1.7rem;
    flex: 0 0 auto;
}

.speaker-copy {
    min-width: 0;
}

.speaker-name {
    color: var(--primary-light);
    font-size: 0.82rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.speaker-text {
    color: var(--text);
    font-size: 0.98rem;
    line-height: 1.5;
}

/* Turn Banner */
.turn-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--glass-fill);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    backdrop-filter: blur(18px);
}

.turn-banner.player1 {
    border-color: var(--accent);
    color: var(--accent);
}

.turn-banner.player2 {
    border-color: var(--secondary);
    color: var(--secondary);
}

.turn-icon {
    font-size: 1.3rem;
}

/* Game Board */
.game-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 7px;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1;
    margin: 0 auto 20px;
    padding: 16px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.11), transparent 30%),
        radial-gradient(circle at 50% 50%, rgba(0, 213, 255, 0.12), transparent 58%),
        rgba(4, 9, 18, 0.86);
    border: 1px solid rgba(125, 211, 252, 0.52);
    border-radius: var(--radius);
    box-sizing: border-box;
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.42),
        0 0 55px rgba(0, 213, 255, 0.13),
        inset 0 0 28px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    isolation: isolate;
}

.game-board::before,
.game-board::after {
    content: "";
    position: absolute;
    inset: 16px;
    border-radius: var(--radius-sm);
    pointer-events: none;
    z-index: -1;
}

.game-board::before {
    background:
        linear-gradient(90deg, transparent calc(33.33% - 1px), rgba(125, 211, 252, 0.28) calc(33.33% - 1px) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
        linear-gradient(90deg, transparent calc(66.66% - 1px), rgba(255, 230, 109, 0.22) calc(66.66% - 1px) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
        linear-gradient(0deg, transparent calc(33.33% - 1px), rgba(125, 211, 252, 0.28) calc(33.33% - 1px) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
        linear-gradient(0deg, transparent calc(66.66% - 1px), rgba(255, 230, 109, 0.22) calc(66.66% - 1px) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.game-board::after {
    background: radial-gradient(circle, rgba(64, 255, 191, 0.18), transparent 62%);
    filter: blur(18px);
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(16, 26, 44, 0.95), rgba(2, 6, 23, 0.84));
    border: 1px solid rgba(148, 229, 255, 0.16);
    border-radius: var(--radius-sm);
    font-size: clamp(2.55rem, 14vw, 4rem);
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.025);
}

.cell:hover {
    border-color: var(--primary-light);
    background: rgba(0, 213, 255, 0.12);
    box-shadow: inset 0 0 28px rgba(0, 213, 255, 0.08), 0 0 20px rgba(0, 213, 255, 0.14);
}

.cell:hover:not(.player1):not(.player2) {
    background: rgba(42, 56, 78, 0.76);
    transform: scale(1.025);
}

.cell.player1 {
    background: linear-gradient(135deg, #e0fbff 0%, #00d5ff 50%, #40ffbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 24px rgba(0, 213, 255, 0.8);
}

.cell.player2 {
    background: linear-gradient(135deg, #fff3a3 0%, #ffb020 50%, #ff2f6d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 24px rgba(255, 122, 24, 0.8);
}

.cell.winner {
    animation: winPulse 0.5s ease infinite alternate;
    box-shadow: 0 0 34px rgba(64, 255, 191, 0.6), inset 0 0 26px rgba(64, 255, 191, 0.1);
    border-color: rgba(64, 255, 191, 0.82);
}

.game-board.replaying .cell {
    pointer-events: none;
}

.cell.replay-focus {
    animation: replayFocus 0.55s ease;
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.45);
}

@keyframes replayFocus {
    from { transform: scale(0.86); opacity: 0.35; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes winPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Win Line */
.win-line {
    position: absolute;
    display: none;
    background: var(--success);
    height: 4px;
    border-radius: 2px;
    animation: drawLine 0.3s ease;
}

@keyframes drawLine {
    from { width: 0; }
    to { width: 100%; }
}

/* Game Status */
.game-status {
    text-align: center;
    margin-bottom: 15px;
    min-height: 25px;
}

.status-text {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.quick-btn {
    padding: 10px 20px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(16px);
}

.quick-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Result Screen */
.result-banner {
    text-align: center;
    margin-bottom: 30px;
}

.result-icon {
    font-size: 5rem;
    animation: bounce 1s ease-in-out infinite;
}

#resultTitle {
    font-size: 2rem;
    color: var(--gold);
    margin-top: 10px;
}

.winner-display {
    position: relative;
    overflow: hidden;
    text-align: center;
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 25px;
    border: 1px solid rgba(251, 191, 36, 0.62);
    box-shadow: 0 0 46px rgba(251, 191, 36, 0.18);
    backdrop-filter: blur(18px);
}

.winner-avatar {
    font-size: 4rem;
}

.winner-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 10px 0;
}

.winner-score {
    font-size: 3rem;
    font-weight: 900;
    color: var(--gold);
}

.match-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-toast {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.achievement-unlocked {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius);
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.45);
    color: var(--gold);
}

/* Stats Screen */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.stats-header h2 {
    font-size: 1.5rem;
    color: var(--text);
}

.close-btn {
    width: 35px;
    height: 35px;
    background: var(--dark-1);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.close-btn:hover {
    background: var(--danger);
    color: white;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-card {
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.stat-card .stat-icon {
    font-size: 2rem;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-light);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.player-stats {
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 15px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.achievements-panel {
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 15px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.achievements-panel h3 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.achievement-list {
    display: grid;
    gap: 10px;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.52);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--text-muted);
}

.achievement-card span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-xs);
    background: var(--dark-2);
    color: var(--text);
}

.achievement-card.unlocked {
    color: var(--text);
    border-color: rgba(251, 191, 36, 0.42);
    background: rgba(251, 191, 36, 0.10);
}

#effectLayer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

#effectLayer span {
    position: absolute;
    left: var(--x);
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--gold);
    opacity: 0;
    animation-delay: var(--delay);
    transform: rotate(var(--rot));
}

#effectLayer.effect-burst span {
    animation: burstParticle 1.05s ease-out forwards;
}

#effectLayer.effect-shockwave::before,
#effectLayer.effect-shockwave::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    border: 3px solid rgba(96, 165, 250, 0.72);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: shockwave 1.1s ease-out forwards;
}

#effectLayer.effect-shockwave::after {
    animation-delay: 0.18s;
    border-color: rgba(251, 191, 36, 0.72);
}

#effectLayer.effect-shockwave span {
    animation: burstParticle 0.8s ease-out forwards;
}

#effectLayer.effect-sparks span {
    width: 4px;
    height: 24px;
    border-radius: 2px;
    background: linear-gradient(180deg, #ffffff, #f97316);
    animation: sparkFall 1.15s ease-out forwards;
}

@keyframes burstParticle {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + (50vw - var(--x)) * -0.45), calc(-50% - 44vh)) scale(1.4); }
}

@keyframes shockwave {
    0% { opacity: 0.9; width: 40px; height: 40px; }
    100% { opacity: 0; width: 110vmax; height: 110vmax; }
}

@keyframes sparkFall {
    0% { opacity: 0; transform: translateY(-42vh) rotate(var(--rot)); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(50vh) rotate(calc(var(--rot) + 90deg)); }
}

.player-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--dark-2);
}

.player-stat-row:last-child {
    border-bottom: none;
}

.empty-stats {
    color: var(--text-muted);
    text-align: center;
    padding: 16px 8px;
}

/* Responsive */
@media (max-width: 400px) {
    .app { padding: 10px; }
    
    .crown { font-size: 3rem; }
    .logo h1 { font-size: 2.2rem; }
    
    .player-setup { gap: 10px; }
    .player-card { padding: 12px; }
    .player-avatar { font-size: 2rem; }
    
    .diff-options { flex-wrap: wrap; }
    .diff-btn { min-width: 45%; }
    .option-row { grid-template-columns: 1fr; }
    
    .game-board {
        max-width: min(318px, calc(100vw - 24px));
        padding: 8px;
        gap: 5px;
    }
    
    .score-display { gap: 10px; }
    .player-info { padding: 12px; }
    .player-info .score { font-size: 1.5rem; }
    .speaker-panel { padding: 10px; }
    .speaker-avatar { width: 42px; height: 42px; }
    .speaker-text { font-size: 0.9rem; }
}

/* Animations */
@keyframes glow {
    0%, 100% { box-shadow: var(--shadow-glow); }
    50% { box-shadow: 0 0 40px rgba(124, 58, 237, 0.6); }
}

.action-btn.primary {
    animation: glow 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }
}

/* ===== Family Mode ===== */
.family-btn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 52px;
    background: linear-gradient(135deg, #38bdf8, #34d399);
    border: none;
    border-radius: 14px 0 0 14px;
    color: #031018;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35);
    transition: all 0.3s ease;
    animation: familyBtnGlow 2.5s ease-in-out infinite;
}

[dir="rtl"] .family-btn {
    right: auto;
    left: 0;
    border-radius: 0 14px 14px 0;
}

@keyframes familyBtnGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35); }
    50% { box-shadow: 0 4px 40px rgba(56, 189, 248, 0.65), 0 0 60px rgba(52, 211, 153, 0.25); }
}

.family-btn:hover {
    width: 58px;
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.6);
}

.family-btn .family-label {
    font-size: 0.55rem;
    font-weight: 800;
    line-height: 1;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

[dir="rtl"] .family-btn .family-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.family-btn span:first-child {
    transition: transform 0.3s ease;
}

.family-btn:hover span:first-child {
    transform: scale(1.2) rotate(-10deg);
}

.family-btn::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    pointer-events: none;
}

[dir="rtl"] .family-btn::after {
    border-radius: 0 12px 12px 0;
}

.family-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, rgba(5, 10, 20, 0.99), rgba(8, 13, 24, 0.99));
    border-left: 1px solid var(--glass-border);
    z-index: 20;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    backdrop-filter: blur(28px);
    padding: 20px 16px;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
}

[dir="rtl"] .family-panel {
    right: auto;
    left: -400px;
    border-left: none;
    border-right: 1px solid var(--glass-border);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.6);
    transition: left 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.family-panel.open {
    right: 0;
}

[dir="rtl"] .family-panel.open {
    right: auto;
    left: 0;
}

@media (max-width: 700px) {
    .family-btn {
        width: 56px;
        padding: 12px 4px;
        font-size: 1.5rem;
        border-radius: 14px 0 0 14px;
    }
    .family-btn .family-label {
        font-size: 0.5rem;
    }
    [dir="rtl"] .family-btn {
        border-radius: 0 14px 14px 0;
    }
    .family-btn:hover {
        width: 60px;
    }
    .family-btn::after {
        border-radius: 12px 0 0 12px;
    }
    [dir="rtl"] .family-btn::after {
        border-radius: 0 12px 12px 0;
    }
    .family-panel {
        width: 100vw;
        right: -100vw;
        transition: right 0.3s cubic-bezier(0.22, 1, 0.36, 1);
        padding: 14px 12px;
    }
    [dir="rtl"] .family-panel {
        left: -100vw;
        right: auto;
        transition: left 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .family-panel.open {
        right: 0;
    }
    [dir="rtl"] .family-panel.open {
        left: 0;
        right: auto;
    }
}

.family-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.family-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
}

.family-close {
    width: 36px;
    height: 36px;
    background: var(--dark-1);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.family-close:hover {
    background: var(--danger);
    color: white;
}

.family-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--glass-fill);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
}

.family-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    flex: 0 0 auto;
}

.family-dot.connected {
    background: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.family-dot.connecting {
    background: var(--secondary);
    animation: dotPulse 1s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.2); }
}

.family-connect {
    background: var(--glass-fill);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
}

.family-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.family-tab {
    flex: 1;
    padding: 12px 8px;
    min-height: 44px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}

.family-tab:active {
    transform: scale(0.96);
}

.family-tab.active {
    background: var(--gradient-main);
    color: #031018;
    border-color: transparent;
}

.family-tab-content {
    display: none;
}

.family-tab-content.active {
    display: block;
}

.family-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 14px;
    text-align: center;
    line-height: 1.6;
}

.family-action-btn {
    width: 100%;
    padding: 14px 12px;
    min-height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.family-action-btn.primary {
    background: var(--gradient-main);
    color: #031018;
    box-shadow: 0 2px 12px rgba(56, 189, 248, 0.25);
}

.family-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 24px rgba(56, 189, 248, 0.35);
}

.family-action-btn.primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.room-code-display {
    text-align: center;
    margin-top: 16px;
    padding: 20px 16px;
    background: rgba(251, 191, 36, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: var(--radius);
    animation: fadeIn 0.4s ease;
    position: relative;
    overflow: hidden;
}

.room-code-display::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(251, 191, 36, 0.06), transparent 70%);
    animation: pulseGold 2s ease-in-out infinite;
}

@keyframes pulseGold {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.room-code {
    display: block;
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 10px;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.35);
    margin: 8px 0;
    font-family: monospace;
    position: relative;
    z-index: 1;
}

.room-input-group {
    display: flex;
    gap: 10px;
}

.room-input {
    flex: 1;
    background: rgba(2, 6, 23, 0.7);
    border: 2px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    padding: 14px;
    min-height: 48px;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.room-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

.room-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 2px;
    font-size: 1rem;
}

.room-input-group .family-action-btn {
    flex: 0 0 auto;
    width: auto;
    padding: 14px 22px;
    min-height: 48px;
}

.family-players {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.family-players-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--glass-fill);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
}

.family-leave-btn {
    margin-right: auto;
    width: 34px;
    height: 34px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 50%;
    color: var(--danger);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

[dir="rtl"] .family-leave-btn {
    margin-right: 0;
    margin-left: auto;
}

.family-leave-btn:active {
    transform: scale(0.9);
}

.player-count {
    margin-right: auto;
    background: rgba(56, 189, 248, 0.15);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--primary);
}

[dir="rtl"] .player-count {
    margin-right: 0;
    margin-left: auto;
}

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

.player-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    min-height: 64px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    transition: all 0.3s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.player-item:active {
    transform: scale(0.98);
    background: rgba(56, 189, 248, 0.06);
}

.player-item:hover {
    border-color: var(--primary-light);
    background: rgba(56, 189, 248, 0.08);
    transform: translateX(4px);
}

[dir="rtl"] .player-item:hover {
    transform: translateX(-4px);
}

.player-item-avatar {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.6);
    border-radius: var(--radius-sm);
    flex: 0 0 auto;
}

.player-item-info {
    flex: 1;
    min-width: 0;
}

.player-item-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.player-item-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.player-item .invite-btn {
    padding: 10px 16px;
    margin-right: 4px;
    min-height: 40px;
    background: var(--gradient-main);
    border: none;
    border-radius: var(--radius-xs);
    color: #031018;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

[dir="rtl"] .player-item .invite-btn {
    margin-right: 0;
    margin-left: 4px;
}

.player-item .invite-btn:active {
    transform: scale(0.93);
}

.player-item .invite-btn:hover {
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.player-item .invite-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.no-players {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* Game Request Overlay */
.game-request-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease;
}

.game-request-card {
    background: linear-gradient(180deg, rgba(5, 10, 20, 0.99), rgba(8, 13, 24, 0.99));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 32px 28px;
    text-align: center;
    max-width: 340px;
    width: 88%;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
    animation: requestPop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}

.game-request-card::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.04), transparent 50%);
    animation: requestGlow 2s ease-in-out infinite;
}

@keyframes requestGlow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

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

.request-avatar {
    font-size: 4.5rem;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.2));
    animation: requestBounce 1.5s ease-in-out infinite;
}

@keyframes requestBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.request-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.game-request-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

.request-actions {
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.request-btn {
    flex: 1;
    padding: 14px 12px;
    min-height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.request-btn.accept {
    background: var(--gradient-main);
    color: #031018;
}

.request-btn.accept:hover {
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.3);
}

.request-btn.reject {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.request-btn.reject:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    backdrop-filter: blur(18px);
    text-align: center;
    pointer-events: auto;
    max-width: 360px;
}

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

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Scan animation */
.scanning-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    color: var(--primary);
    font-size: 0.9rem;
}

.scanning-indicator .scan-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: scanDot 1.2s ease-in-out infinite;
}

.scanning-indicator .scan-dot:nth-child(2) { animation-delay: 0.2s; }
.scanning-indicator .scan-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes scanDot {
    0%, 100% { opacity: 0.2; transform: scale(0.7); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* Family responsive */
@media (max-width: 500px) {
    .family-panel {
        padding: 14px 12px;
    }
    .family-header {
        margin-bottom: 12px;
    }
    .family-title {
        font-size: 1.1rem;
    }
    .family-connect {
        padding: 14px;
    }
    .family-tab {
        padding: 10px 6px;
        font-size: 0.8rem;
    }
    .room-code {
        font-size: 2.2rem;
        letter-spacing: 8px;
    }
    .room-input {
        font-size: 1.2rem;
        padding: 12px;
        letter-spacing: 6px;
    }
    .game-request-card {
        padding: 24px 20px;
        max-width: 300px;
    }
    .request-avatar {
        font-size: 3.5rem;
    }
    .player-item {
        padding: 12px;
        min-height: 58px;
    }
    .player-item-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.6rem;
    }
    .player-item .invite-btn {
        padding: 8px 12px;
        font-size: 0.78rem;
        min-height: 36px;
    }
}

@media (max-width: 380px) {
    .family-btn {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
    .family-panel {
        padding: 12px 10px;
    }
    .room-code {
        font-size: 1.8rem;
        letter-spacing: 6px;
    }
    .game-request-card {
        padding: 20px 16px;
    }
}
