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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #4ade80;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --bg-dark: #0f172a;
    --bg-light: #1e293b;
    --text-light: #f1f5f9;
    --text-gray: #94a3b8;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-light);
    overflow-x: hidden;
}

/* Home Page Styles */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease;
}

.main-title {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #f0f9ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    text-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
}

.subtitle {
    font-size: 1.3rem;
    color: var(--text-gray);
    font-weight: 300;
}

/* Games Grid */
.games-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease;
}

.game-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    max-width: 400px;
    width: 100%;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card:hover::before {
    opacity: 1;
}

.game-card.active:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 255, 255, 0.3);
}

.game-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.game-card.locked {
    position: relative;
    opacity: 1;
}

.game-card.locked .game-icon.blur {
    filter: blur(8px) grayscale(0.5);
    animation: none;
}

.lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    animation: lockPulse 2s infinite;
}

.lock-icon {
    width: 80px;
    height: 80px;
    color: #fff;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
}

@keyframes lockPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 1;
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.8));
    }
}

.game-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.dots-boxes-icon {
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dots-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 20px;
}

.dot {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
    animation: dotPulse 2s infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.1s; }
.dot:nth-child(3) { animation-delay: 0.2s; }
.dot:nth-child(4) { animation-delay: 0.3s; }
.dot:nth-child(5) { animation-delay: 0.4s; }
.dot:nth-child(6) { animation-delay: 0.5s; }
.dot:nth-child(7) { animation-delay: 0.6s; }
.dot:nth-child(8) { animation-delay: 0.7s; }
.dot:nth-child(9) { animation-delay: 0.8s; }

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

.game-card.active .game-icon {
    animation: bounce 2s infinite;
}

.game-card.disabled .game-icon {
    animation: none;
    filter: grayscale(1);
}

.game-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    margin-top: 5rem;
}

.game-description {
    color: var(--text-gray);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.play-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.play-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.play-button:disabled {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    cursor: not-allowed;
    box-shadow: none;
}

.button-icon {
    font-size: 1.2rem;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem;
    color: var(--text-gray);
    animation: fadeIn 1s ease;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-dark) 100%);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-subtitle {
    text-align: center;
    color: var(--text-gray);
    margin-bottom: 2rem;
}

/* Mode Selection */
.mode-buttons {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-button {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.mode-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.mode-button h3 {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
    color: var(--text-light);
}

.mode-button p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

/* Form Styles */
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    color: var(--text-light);
}

.input-group input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.8rem;
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
}

.input-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    direction: rtl;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
}

.input-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#gridSizeValue,
#onlineGridSizeValue {
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Buttons */
.primary-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.back-button {
    background: transparent;
    color: var(--text-gray);
    border: none;
    padding: 0.8rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.back-button:hover {
    color: var(--text-light);
}

/* Online Options */
.online-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-button {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
}

.option-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.option-icon {
    font-size: 2rem;
}

/* Waiting Room */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

.waiting-text {
    text-align: center;
    color: var(--text-gray);
    margin-top: 1rem;
}

/* Game Page */
.game-page {
    background: var(--bg-dark);
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    margin-bottom: 1rem;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.dot-header {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.icon-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Players Info */
.players-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.player-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    min-width: 0; /* برای جلوگیری از overflow */
    flex: 1;
    max-width: 280px; /* عرض بیشتر */
    justify-content: space-between; /* فضای بین المان‌ها */
}

.player-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    animation: pulse 2s infinite;
}

#player2Card.active {
    border-color: #f5576c;
    box-shadow: 0 0 20px rgba(245, 87, 108, 0.5);
    animation: pulseRed 2s infinite;
}

.player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.player-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.player-details h3 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-score {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    white-space: nowrap;
}

.score-label {
    color: var(--text-gray);
    font-size: 0.85rem;
}

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

.turn-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.player-card.active .turn-indicator {
    background: var(--success-color);
    border-color: var(--success-color);
    box-shadow: 0 0 15px var(--success-color);
    animation: blink 1.5s infinite;
}

.vs-divider {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    padding: 0 0.5rem;
    text-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
}

/* Game Board */
.game-board-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    min-height: 400px;
}

#gameCanvas {
    cursor: pointer;
    border-radius: 10px;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.control-button {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.control-button span:first-child {
    font-size: 1.5rem;
}

/* Reaction Picker - پاپ‌آپ مرکزی برای دسکتاپ */
.reaction-picker {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
    z-index: 999;
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0.6rem;
    justify-items: center;
    align-items: center;
    opacity: 0;
    max-width: 500px;
    width: auto;
}

.reaction-picker.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* اسکرول بار سفارشی */
.reaction-picker::-webkit-scrollbar {
    width: 8px;
}

.reaction-picker::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.reaction-picker::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.reaction-picker::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 2rem;
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reaction-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.4);
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: slideInDown 0.2s ease, slideOutUp 0.2s ease 1.3s;
    border-left: 3px solid var(--primary-color);
    max-width: 300px;
    font-size: 0.9rem;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

/* Win Modal */
.win-modal .modal-content {
    max-width: 600px;
    text-align: center;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confettiFall 3s linear;
}

.win-title {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.winner-info {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-gray);
}

.winner-name {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 2.5rem;
    display: inline-block;
    margin: 1rem 0;
    padding: 1rem 2rem;
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    animation: pulse 2s infinite, scaleIn 0.5s ease-out;
}

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

.result-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-light);
}

.result-scores {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.player-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    min-width: 150px;
    position: relative;
    transition: all 0.3s ease;
}

.player-result.winner {
    background: rgba(102, 126, 234, 0.2);
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
    transform: scale(1.1);
}

.player-result.loser {
    opacity: 0.6;
    transform: scale(0.95);
}

.player-result-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-light);
}

.player-result-score {
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 0 0 10px currentColor;
}

.result-vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-gray);
}

.badge-winner {
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 2rem;
    animation: spin 3s linear infinite;
}

.win-buttons,
.menu-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    }
}

@keyframes pulseRed {
    0%, 100% {
        box-shadow: 0 0 20px rgba(245, 87, 108, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(245, 87, 108, 0.8);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

@keyframes slideInDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes popScore {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 900px) {
    .main-title {
        font-size: 2.5rem;
    }

    .games-grid {
        gap: 1.5rem;
    }

    .players-info {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .player-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .vs-divider {
        font-size: 1.3rem;
    }

    .game-board-container {
        padding: 1rem;
        overflow: auto;
        max-height: calc(100vh - 380px);
    }

    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .main-title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .game-card {
        max-width: 100%;
    }

    .game-icon {
        font-size: 4rem;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }

    .online-options {
        grid-template-columns: 1fr;
    }

    .players-info {
        gap: 0.5rem;
    }

    .player-card {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .player-avatar {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }

    .player-details h3 {
        font-size: 0.9rem;
    }

    .score-label {
        font-size: 0.75rem;
    }

    .score-value {
        font-size: 1.1rem;
    }

    .vs-divider {
        font-size: 1.2rem;
        padding: 0 0.3rem;
    }

    .game-controls {
        flex-direction: column;
    }

    .control-button {
        flex-direction: row;
        justify-content: center;
    }

    .reaction-picker {
        top: auto;
        left: 0;
        right: 0;
        bottom: -100%;
        transform: translateY(0);
        border-radius: 20px 20px 0 0;
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 0.4rem;
        padding: 0.5rem;
        max-width: 100%;
        width: 100%;
        transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
    }
    
    .reaction-picker.active {
        bottom: 0;
        transform: translateY(0);
        opacity: 1;
    }

    .win-title {
        font-size: 1.8rem;
    }

    .winner-name {
        font-size: 2rem;
        padding: 1rem 2rem;
        border-radius: 15px;
    }
    
    .result-icon {
        font-size: 4rem;
        margin-bottom: 0.5rem;
    }
    
    .result-title {
        font-size: 1.5rem;
        margin-bottom: 0.8rem;
    }
    
    .result-scores {
        gap: 0.5rem;
        margin-top: 1.5rem;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    .player-result {
        padding: 0.5rem 0.8rem;
        min-width: 80px;
        width: auto;
        max-width: 120px;
    }
    
    .player-result-name {
        font-size: 0.75rem;
    }
    
    .player-result-score {
        font-size: 1.3rem;
    }
    
    .result-vs {
        font-size: 1rem;
        transform: none;
    }
    
    .badge-winner {
        font-size: 1.5rem;
        top: -5px;
        right: -5px;
    }
    
    .winner-info {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    .play-button,
    .primary-button,
    .secondary-button,
    .mode-button,
    .option-button,
    .control-button {
        -webkit-tap-highlight-color: transparent;
    }

    .emoji-btn,
    .reaction-btn {
        padding: 0.4rem;
        font-size: 1.2rem;
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}
