* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: linear-gradient(135deg, #1b1c25 0%, #1a0d19 100%);
    --card-bg: rgba(39, 38, 38, 0.95);
    --accent-color: #667eea;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --border-radius: 16px;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--primary-bg);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(16px, 4vw, 32px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: clamp(40px, 8vw, 80px);
    width: 100%;
}

.header h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: clamp(12px, 2vw, 20px);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.header p {
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    opacity: 0.9;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Menu Options */
.menu-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: clamp(24px, 4vw, 40px);
    width: 100%;
    max-width: 900px;
}

.option-card {
    background: var(--card-bg);
    padding: clamp(30px, 4vw, 50px) clamp(24px, 3vw, 40px);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.option-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.6s;
}

.option-card:hover::before {
    left: 100%;
}

.option-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 30px 60px rgba(0,0,0,0.4);
    border-color: rgba(102, 126, 234, 0.3);
}

.option-icon {
    font-size: clamp(3rem, 8vw, 5rem);
    margin-bottom: clamp(20px, 3vw, 30px);
    display: block;
}

.option-card h3 {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    margin-bottom: clamp(12px, 2vw, 20px);
    color: var(--text-primary);
    font-weight: 600;
}

.option-card p {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.1rem);
    line-height: 1.5;
}

/* Waiting Room & Join Room */
.waiting-room, .join-room {
    background: var(--card-bg);
    padding: clamp(30px, 5vw, 60px) clamp(24px, 4vw, 50px);
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.room-code {
    margin: clamp(24px, 4vw, 40px) 0;
}

.code-display {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 800;
    color: #1a1a1a;
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: clamp(20px, 3vw, 30px);
    border-radius: 12px;
    margin: clamp(16px, 3vw, 24px) 0;
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.instruction {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.2rem);
}

.waiting-animation {
    margin: clamp(30px, 5vw, 50px) 0;
}

.spinner {
    width: clamp(50px, 10vw, 80px);
    height: clamp(50px, 10vw, 80px);
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto clamp(16px, 3vw, 24px);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.player-count {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    margin: clamp(20px, 3vw, 30px) 0;
    color: var(--text-secondary);
}

/* Forms */
.join-form {
    max-width: 400px;
    margin: 0 auto clamp(24px, 4vw, 40px);
    width: 100%;
}

.form-group {
    margin-bottom: clamp(20px, 3vw, 30px);
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: clamp(1rem, 2vw, 1.1rem);
}

.form-group input {
    width: 100%;
    padding: clamp(14px, 2vw, 18px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: clamp(1rem, 2vw, 1.1rem);
    text-align: center;
    letter-spacing: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: clamp(14px, 2vw, 18px);
    border-radius: 12px;
    margin: clamp(16px, 3vw, 24px) 0;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Buttons */
.btn {
    padding: clamp(14px, 2vw, 18px) clamp(28px, 4vw, 36px);
    border: none;
    border-radius: 12px;
    font-size: clamp(1rem, 2vw, 1.1rem);
    cursor: pointer;
    transition: var(--transition);
    margin: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-color), #764ba2);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Game Styles */
.game-header {
    text-align: center;
    margin-bottom: clamp(24px, 4vw, 40px);
    width: 100%;
}

.game-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.room-info {
    font-size: clamp(1rem, 2vw, 1.2rem);
    opacity: 0.9;
    color: var(--text-secondary);
}

.game-status {
    text-align: center;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    font-weight: 700;
    margin: clamp(16px, 3vw, 24px) 0;
    padding: clamp(14px, 2vw, 18px);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.game-status.my-turn {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 2px solid rgba(16, 185, 129, 0.3);
}

.game-status.opponent-turn {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.game-status.win {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-size: clamp(1.4rem, 4vw, 2rem);
    border: 2px solid rgba(16, 185, 129, 0.3);
}

.game-status.lose {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: clamp(1.4rem, 4vw, 2rem);
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.game-status.draw {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: clamp(1.4rem, 4vw, 2rem);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.game-board {
    display: inline-block;
    background: var(--card-bg);
    padding: clamp(16px, 3vw, 24px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin: clamp(16px, 3vw, 24px) 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.board-row {
    display: flex;
}

.cell {
    width: clamp(60px, 15vw, 100px);
    height: clamp(60px, 15vw, 100px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 800;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.05);
}

.cell.x {
    color: #ef4444;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.cell.o {
    color: #3b82f6;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* Remove outer borders */
.board-row:first-child .cell {
    border-top: none;
}

.board-row:last-child .cell {
    border-bottom: none;
}

.cell:first-child {
    border-left: none;
}

.cell:last-child {
    border-right: none;
}

.player-info {
    text-align: center;
    margin: clamp(16px, 3vw, 24px) 0;
    width: 100%;
}

.symbol-info {
    background: rgba(255, 255, 255, 0.1);
    padding: clamp(12px, 2vw, 16px) clamp(20px, 3vw, 30px);
    border-radius: 12px;
    display: inline-block;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: clamp(1rem, 2vw, 1.2rem);
}

/* Music Controls */
.music-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.music-btn {
    background: rgba(39, 38, 38, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.music-btn:hover {
    background: rgba(102, 126, 234, 0.8);
    transform: scale(1.1);
}

/* Ultra Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .menu-options {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .option-card {
        padding: 30px 20px;
    }
    
    .waiting-room, .join-room {
        padding: 30px 20px;
        margin: 20px auto;
    }
    
    .code-display {
        font-size: 2rem;
        padding: 20px;
    }
    
    .game-board {
        padding: 16px;
    }
    
    .cell {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
    
    .music-controls {
        top: 10px;
        right: 10px;
    }
    
    .music-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .option-card {
        padding: 24px 16px;
    }
    
    .option-icon {
        font-size: 3rem;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 0.9rem;
        margin: 6px;
    }
    
    .cell {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .code-display {
        font-size: 1.8rem;
        padding: 16px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .option-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .cell:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --card-bg: #1a1a1a;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
    
    .option-card, .waiting-room, .join-room, .game-board {
        border: 2px solid #ffffff;
    }
}