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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.tagline {
    font-size: 1.2rem;
    opacity: 0.9;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.game-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

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

.game-card h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.game-card p {
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.game-info span {
    color: #888;
    font-size: 0.9rem;
}

footer {
    text-align: center;
    color: white;
    opacity: 0.9;
    padding: 1rem;
}

/* Game page styles */
.game-container {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    max-width: 800px;
    margin: 2rem auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
}

.back-btn {
    background: #888;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: #666;
}

.status {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: bold;
}

#find-match-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    margin: 2rem auto;
    display: block;
}

#find-match-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

#find-match-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

#play-ai-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    margin: 2rem auto;
    display: block;
}

#play-ai-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

#play-ai-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

#waiting-screen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

/* Tic-Tac-Toe specific */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 2rem auto;
}

.ttt-cell {
    aspect-ratio: 1;
    background: #f0f0f0;
    border: 3px solid #667eea;
    border-radius: 10px;
    font-size: 3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.ttt-cell:hover:not(.taken) {
    background: #e0e0ff;
    transform: scale(1.05);
}

.ttt-cell.taken {
    cursor: not-allowed;
}

/* Drawing canvas */
#drawing-canvas {
    border: 3px solid #667eea;
    border-radius: 10px;
    cursor: crosshair;
    display: block;
    margin: 1rem auto;
    background: white;
}

.canvas-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.canvas-controls button {
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.canvas-controls button:hover {
    background: #667eea;
    color: white;
}

.guess-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #667eea;
    border-radius: 10px;
    margin-top: 1rem;
}

.word-display {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    background: #f0f0ff;
    border-radius: 10px;
}

/* Snake game */
.snake-game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem auto;
    max-width: 100%;
    overflow: hidden;
}

#snake-canvas {
    border: 3px solid #667eea;
    border-radius: 10px;
    display: block;
    background: #f0f0f0;
    width: 600px;
    height: 600px;
    max-width: min(90vw, 600px);
    max-height: min(90vw, 600px);
}

.controls-info {
    text-align: center;
    margin: 1rem 0;
    color: #666;
    font-size: 0.9rem;
}

/* Mobile D-pad controls */
.mobile-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem auto 1rem;
    padding: 1rem;
}

.dpad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.dpad-middle {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dpad-center {
    width: 60px;
    height: 60px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.dpad-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8a 100%);
}

.dpad-btn:focus {
    outline: none;
}

.score-board {
    display: flex;
    justify-content: space-around;
    margin: 1rem auto;
    padding: 1rem;
    background: #f0f0ff;
    border-radius: 10px;
    max-width: 640px;
    width: 100%;
    box-sizing: border-box;
}

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

.score-item .label {
    font-size: 0.9rem;
    color: #888;
}

.score-item .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.controls-info {
    text-align: center;
    color: #888;
    margin: 1rem 0;
}

.message {
    text-align: center;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 10px;
    font-weight: bold;
}

.message.success {
    background: #d4edda;
    color: #155724;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
}

/* Profile Bar */
.profile-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 1.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-info:hover {
    transform: scale(1.05);
}

.avatar {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.username {
    font-weight: bold;
    color: #333;
    font-size: 1.2rem;
}

.stats-badge {
    background: #f0f0ff;
    color: #667eea;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

.sound-toggle {
    background: rgba(102, 126, 234, 0.2);
    border: 2px solid #667eea;
    color: #667eea;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle:hover {
    background: #667eea;
    transform: rotate(15deg) scale(1.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: slideDown 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #667eea;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    text-align: center;
}

.profile-edit {
    margin-bottom: 2rem;
}

.profile-edit label {
    display: block;
    color: #666;
    font-weight: bold;
    margin: 1rem 0 0.5rem;
}

.avatar-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.avatar-selector span {
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.2s ease;
    background: #f0f0f0;
}

.avatar-selector span:hover {
    background: #667eea;
    transform: scale(1.2);
}

.profile-edit input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.profile-edit input:focus {
    outline: none;
    border-color: #667eea;
}

.profile-edit button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.profile-edit button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.profile-stats {
    border-top: 2px solid #eee;
    padding-top: 1.5rem;
}

.profile-stats h3 {
    color: #667eea;
    margin-bottom: 1rem;
    text-align: center;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    margin: 0.3rem 0;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-row span:first-child {
    color: #666;
    font-weight: 500;
}

.stat-row span:last-child {
    color: #667eea;
    font-weight: bold;
}

/* Connect Four specific styles */
.cf-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    max-width: 560px;
    margin: 2rem auto;
    background: #2c3e50;
    padding: 1rem;
    border-radius: 15px;
}

.cf-cell {
    aspect-ratio: 1;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.cf-cell:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.cf-cell.red {
    background: #e74c3c;
}

.cf-cell.yellow {
    background: #f39c12;
}

/* Pong specific styles */
#pong-canvas {
    border: 3px solid #667eea;
    border-radius: 10px;
    display: block;
    margin: 1rem auto;
    background: #000;
}

/* Rock Paper Scissors specific styles */
.rps-choices {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.rps-choice {
    font-size: 4rem;
    cursor: pointer;
    padding: 1rem;
    border-radius: 20px;
    background: #f0f0f0;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.rps-choice:hover {
    background: #667eea;
    transform: scale(1.2) rotate(10deg);
    border-color: #764ba2;
}

.rps-result {
    text-align: center;
    font-size: 1.5rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f0f0ff;
    border-radius: 15px;
}

.rps-round-tracker {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.round-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ddd;
}

.round-dot.win {
    background: #51cf66;
}

.round-dot.lose {
    background: #ff6b6b;
}

.round-dot.draw {
    background: #ffd43b;
}

/* Lobby Section */
.lobby-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

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

.lobby-header h2 {
    color: #667eea;
    margin: 0;
    font-size: 1.5rem;
}

.toggle-lobby-btn {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid #667eea;
    color: #667eea;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-lobby-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.lobby-content {
    max-height: 400px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.online-users-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.online-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.online-user:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
}

.user-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.online-indicator {
    font-size: 0.8rem;
}

.invite-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.invite-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.no-users {
    text-align: center;
    color: #888;
    padding: 2rem;
    font-size: 1.1rem;
}

.loading {
    text-align: center;
    color: #667eea;
    padding: 2rem;
    font-size: 1.1rem;
}

/* Invite Modal */
.invite-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.game-choice {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.game-choice:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-5px);
    border-color: #764ba2;
}

.game-choice-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.game-choice-name {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Invite Notification */
.invite-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2000;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border: 3px solid #667eea;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.invite-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.invite-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: bold;
    color: #333;
}

.invite-header span:first-child {
    font-size: 2rem;
}

.invite-game {
    text-align: center;
    font-size: 1.3rem;
    color: #667eea;
    font-weight: bold;
    padding: 0.5rem;
    background: #f0f0ff;
    border-radius: 8px;
}

.invite-actions {
    display: flex;
    gap: 0.8rem;
}

.accept-btn, .decline-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.accept-btn {
    background: #51cf66;
    color: white;
}

.accept-btn:hover {
    background: #40c057;
    transform: scale(1.05);
}

.decline-btn {
    background: #ff6b6b;
    color: white;
}

.decline-btn:hover {
    background: #fa5252;
    transform: scale(1.05);
}

/* Lobby Message */
.lobby-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem 3rem;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1500;
    font-size: 1.2rem;
    font-weight: bold;
    animation: fadeIn 0.3s ease;
}

.lobby-message.info {
    border-left: 5px solid #667eea;
    color: #667eea;
}

.lobby-message.success {
    border-left: 5px solid #51cf66;
    color: #51cf66;
}

.lobby-message.error {
    border-left: 5px solid #ff6b6b;
    color: #ff6b6b;
}

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

/* Chess specific styles */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    max-width: 640px;
    max-height: 640px;
    margin: 2rem auto;
    border: 4px solid #769656;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.chess-square {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    position: relative;
}

.chess-square.light {
    background: #eeeed2;
}

.chess-square.dark {
    background: #769656;
}

.chess-square:hover {
    opacity: 0.85;
}

.chess-square.selected {
    background: #baca44 !important;
    box-shadow: inset 0 0 0 3px #829769;
}

.chess-square.last-move {
    background: #baca44 !important;
}

.chess-square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

.chess-square.valid-capture::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    box-sizing: border-box;
}

/* Chess piece styling for better visuals */
.chess-piece {
    font-size: 4rem;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
    cursor: pointer;
    transition: transform 0.1s ease;
}

.chess-piece:hover {
    transform: scale(1.1);
}

/* White pieces with better contrast */
.white-piece {
    color: #ffffff;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 3px rgba(0,0,0,0.5);
}

/* Black pieces */
.black-piece {
    color: #000000;
    text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}

.chess-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem auto;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
    max-width: 640px;
    width: 100%;
    box-sizing: border-box;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem;
    border-radius: 8px;
    flex: 0 1 auto;
}

.player-info.my-color {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.player-color {
    font-size: 3rem;
}

.white-piece {
    color: #fff;
    text-shadow: 0 0 3px #000, 0 0 5px #000;
}

.black-piece {
    color: #000;
}

.player-label {
    font-weight: bold;
    font-size: 1.1rem;
}

.game-status {
    flex: 1;
    text-align: center;
    padding: 0 1rem;
}

.turn-indicator {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.turn-indicator.my-turn {
    color: #51cf66;
    animation: pulse 1.5s infinite;
}

.turn-indicator.check {
    color: #ff6b6b;
    animation: shake 0.5s;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.captured-pieces {
    margin-top: 1rem;
}

.captured-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 0.3rem;
}

.captured-list {
    font-size: 1.5rem;
    min-height: 1.8rem;
    margin: 0.2rem 0;
}

#captured-white {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 3px #000;
}

#captured-black {
    color: #000;
}

/* Pawn Promotion Modal */
.promotion-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

.promotion-content {
    background-color: #312e2b;
    margin: 15% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    text-align: center;
}

.promotion-content h3 {
    color: #ffffff;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.promotion-pieces {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.promotion-piece {
    font-size: 4rem;
    padding: 1rem;
    background: #3d3d3d;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
}

.promotion-piece:hover {
    background: #4a4a4a;
    transform: scale(1.1);
    border-color: #769656;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablet and smaller (768px and below) */
@media screen and (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .game-container {
        padding: 1rem;
        margin: 0.5rem auto;
        max-width: 100%;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .tagline {
        font-size: 1rem;
    }

    /* Game grid - single column on mobile */
    .game-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .game-card {
        padding: 1.5rem;
    }

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

    .game-card h2 {
        font-size: 1.5rem;
    }

    /* Touch-friendly buttons - minimum 44px height */
    .play-btn,
    button,
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.8rem 2rem;
        font-size: 1rem;
    }

    /* Profile bar */
    .profile-bar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .profile-info {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .profile-controls {
        width: 100%;
        justify-content: center;
    }

    /* Lobby section */
    .lobby-section {
        padding: 1rem;
    }

    .lobby-header {
        font-size: 1rem;
    }

    .online-player {
        padding: 0.8rem;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }

    .profile-modal-content {
        width: 95%;
        max-width: 95%;
    }

    .avatar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.8rem;
    }

    .avatar-option {
        font-size: 2rem;
        padding: 0.5rem;
    }

    /* Game stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    /* Game screen adjustments */
    .game-screen {
        padding: 1rem;
    }

    .game-header {
        flex-direction: column;
        gap: 1rem;
    }

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

    /* Chess board - scale to fit mobile */
    .chess-board {
        width: min(90vw, 400px) !important;
        max-width: min(90vw, 400px) !important;
        margin: 0.5rem auto !important;
        border-width: 2px;
    }

    .chess-square {
        font-size: 2.5rem;
    }

    .chess-piece {
        font-size: 2.5rem !important;
    }

    .chess-info {
        flex-direction: row;
        gap: 0.3rem;
        margin: 0.5rem auto;
        padding: 0.5rem;
        max-width: min(90vw, 400px);
    }

    .player-info {
        min-width: 0;
        padding: 0.4rem;
        gap: 0.2rem;
    }

    .player-color {
        font-size: 1.8rem;
    }

    .player-label {
        font-size: 0.7rem;
    }

    .game-status {
        padding: 0 0.2rem;
    }

    .turn-indicator {
        font-size: 0.85rem;
        padding: 0.3rem 0.5rem;
    }

    .captured-pieces {
        font-size: 0.75rem;
        margin-top: 0.3rem;
    }

    .captured-label {
        font-size: 0.7rem;
    }

    .captured-list {
        font-size: 1rem;
        min-height: 1rem;
    }

    /* Score boards */
    .score-board {
        margin: 0.5rem auto;
        padding: 0.6rem;
        max-width: min(90vw, 400px);
    }

    .score-item .value {
        font-size: 1.3rem;
    }

    .score-item .label {
        font-size: 0.8rem;
    }

    /* Tic-tac-toe board */
    #tic-tac-toe-board {
        width: min(90vw, 400px);
        height: min(90vw, 400px);
    }

    .tic-tac-toe-cell {
        font-size: 2.5rem;
    }

    /* Connect Four board */
    #connect-four-board {
        width: min(90vw, 350px);
    }

    .connect-four-cell {
        width: calc(min(90vw, 350px) / 7);
        height: calc(min(90vw, 350px) / 7);
    }

    /* Drawing canvas */
    #drawing-canvas {
        width: min(90vw, 400px);
        height: min(90vw, 400px);
    }

    .color-palette {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .color-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Snake game */
    #snake-canvas {
        width: min(90vw, 400px) !important;
        height: min(90vw, 400px) !important;
        max-width: min(90vw, 400px) !important;
        max-height: min(90vw, 400px) !important;
    }

    .dpad-btn {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    .dpad-center {
        width: 70px;
        height: 70px;
    }

    /* Pong game */
    #pong-canvas {
        width: min(90vw, 400px);
        height: min(60vw, 300px);
    }

    /* Rock Paper Scissors */
    .rps-choices {
        flex-direction: column;
        gap: 1rem;
    }

    .rps-choice {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }

    .rps-result {
        flex-direction: column;
        gap: 1rem;
    }

    .choice-display {
        font-size: 3rem;
    }

    /* Status and messages */
    #status,
    #game-message {
        font-size: 1rem;
        padding: 0.8rem;
    }

    /* Scores */
    .score-display {
        font-size: 1.2rem;
    }

    /* Turn indicator */
    .turn-indicator {
        font-size: 1rem;
        padding: 0.8rem;
    }

    /* Promotion modal */
    .promotion-content {
        width: 95%;
        max-width: 95%;
        margin: 30% auto;
        padding: 1.5rem;
    }

    .promotion-pieces {
        gap: 0.5rem;
    }

    .promotion-piece {
        font-size: 3rem;
        padding: 0.8rem;
    }

    /* Invite modal */
    .invite-games {
        grid-template-columns: 1fr;
    }

    .invite-game-btn {
        padding: 1rem;
    }
}

/* Mobile phones (480px and below) */
@media screen and (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .container {
        padding: 0.25rem;
    }

    .game-container {
        padding: 0.5rem;
        margin: 0.25rem auto;
    }

    .game-card {
        padding: 1rem;
    }

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

    .game-card h2 {
        font-size: 1.3rem;
    }

    .game-card p {
        font-size: 0.9rem;
    }

    .play-btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Smaller boards on very small screens */
    .chess-board {
        width: min(95vw, 320px) !important;
        max-width: min(95vw, 320px) !important;
    }

    .chess-info {
        max-width: min(95vw, 320px);
        padding: 0.4rem;
    }

    .player-info {
        padding: 0.3rem;
    }

    .player-color {
        font-size: 1.5rem;
    }

    .player-label {
        font-size: 0.65rem;
    }

    .turn-indicator {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }

    .captured-pieces {
        font-size: 0.65rem;
    }

    .captured-label {
        font-size: 0.6rem;
    }

    .captured-list {
        font-size: 0.85rem;
    }

    .chess-piece {
        font-size: 2rem !important;
    }

    /* Score boards */
    .score-board {
        margin: 0.4rem auto;
        padding: 0.4rem;
        max-width: min(95vw, 320px);
    }

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

    .score-item .label {
        font-size: 0.7rem;
    }

    #tic-tac-toe-board,
    #drawing-canvas {
        width: min(95vw, 320px);
        height: min(95vw, 320px);
    }

    #snake-canvas {
        width: min(95vw, 320px) !important;
        height: min(95vw, 320px) !important;
        max-width: min(95vw, 320px) !important;
        max-height: min(95vw, 320px) !important;
    }

    .dpad-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .dpad-center {
        width: 60px;
        height: 60px;
    }

    #pong-canvas {
        width: min(95vw, 320px);
        height: min(60vw, 240px);
    }

    #connect-four-board {
        width: min(95vw, 280px);
    }

    .connect-four-cell {
        width: calc(min(95vw, 280px) / 7);
        height: calc(min(95vw, 280px) / 7);
    }

    .tic-tac-toe-cell {
        font-size: 2rem;
    }

    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .avatar-option {
        font-size: 1.5rem;
    }

    .rps-choice {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    .choice-display {
        font-size: 2.5rem;
    }

    .promotion-piece {
        font-size: 2.5rem;
        padding: 0.6rem;
    }

    .modal-content h2,
    .profile-modal-content h2,
    .promotion-content h3 {
        font-size: 1.3rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .game-card:hover {
        transform: none;
    }

    .play-btn:hover {
        transform: none;
    }

    /* Make all interactive elements more touch-friendly */
    button,
    .btn,
    .chess-square,
    .tic-tac-toe-cell,
    .connect-four-cell,
    .color-btn,
    .rps-choice,
    .avatar-option,
    .promotion-piece {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Active states instead of hover */
    .game-card:active {
        transform: scale(0.98);
    }

    .play-btn:active,
    button:active {
        transform: scale(0.95);
    }

    .chess-square:active,
    .tic-tac-toe-cell:active {
        background-color: rgba(102, 126, 234, 0.2);
    }
}

/* Landscape mode on mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 0.5rem;
    }

    header {
        margin-bottom: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 0.8rem;
    }

    .game-screen {
        padding: 0.5rem;
    }

    .modal-content,
    .profile-modal-content {
        margin: 2% auto;
        max-height: 95vh;
        overflow-y: auto;
    }
}

/* Achievement Notifications */
.achievement-notification {
    position: fixed;
    top: -200px;
    right: 2rem;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    min-width: 350px;
    transition: top 0.5s ease-in-out;
    border: 3px solid #FFD700;
}

.achievement-notification.show {
    top: 2rem;
}

.achievement-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.achievement-icon {
    font-size: 3rem;
    animation: bounce 0.6s ease-in-out;
}

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

.achievement-text {
    flex: 1;
}

.achievement-unlocked {
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.achievement-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.3rem;
}

.achievement-desc {
    font-size: 0.9rem;
    color: #fff;
    opacity: 0.9;
}

/* Profile Page Styles */
.profile-section {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.profile-section h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.profile-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-field label {
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
}

.profile-field input,
.profile-field select {
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.profile-field input:focus,
.profile-field select:focus {
    outline: none;
    border-color: #667eea;
}

.email-link-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 10px;
    margin-top: 1rem;
}

.email-link-section h3 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.email-link-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.email-link-status .icon {
    font-size: 1.5rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.achievement-card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
}

.achievement-card.unlocked {
    border-color: #FFD700;
    background: linear-gradient(135deg, #FFF8DC 0%, #FFE4B5 100%);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

.achievement-card-name {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.3rem;
    font-size: 1rem;
}

.achievement-card-desc {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.achievement-progress {
    margin-top: 1rem;
    text-align: center;
}

.progress-bar {
    background: #ddd;
    border-radius: 20px;
    height: 30px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    height: 100%;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.save-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.profile-avatar-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.avatar-option {
    font-size: 2.5rem;
    padding: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: #667eea;
}

.avatar-option.selected {
    border-color: #667eea;
    background: #f0f0f0;
}

/* Device Mode Selector */
.device-mode-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

.device-mode-modal.show {
    display: flex;
}

.device-mode-content {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    0% {
        transform: translateY(-50px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.device-mode-title {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.device-mode-subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 2rem;
}

.device-mode-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.device-mode-btn {
    background: white;
    border: 3px solid #ddd;
    border-radius: 15px;
    padding: 2rem;
    width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.device-mode-btn:hover {
    transform: translateY(-5px);
    border-color: #667eea;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.device-mode-btn.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.device-mode-icon {
    font-size: 4rem;
}

.device-mode-name {
    font-size: 1.5rem;
    font-weight: bold;
}

.device-mode-desc {
    font-size: 0.9rem;
    opacity: 0.8;
}

.device-mode-confirm {
    margin-top: 2rem;
}

.device-mode-skip {
    margin-top: 1rem;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    text-decoration: underline;
    font-size: 1rem;
}

.device-mode-skip:hover {
    color: #333;
}

@media (max-width: 768px) {
    .achievement-notification {
        right: 1rem;
        left: 1rem;
        min-width: auto;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .device-mode-content {
        margin: 1rem;
        padding: 2rem;
    }

    .device-mode-buttons {
        flex-direction: column;
        align-items: center;
    }

    .device-mode-btn {
        width: 100%;
        max-width: 300px;
    }
}
