/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

:root {
    --primary: #6366f1;
    --primary-rgb: 99, 102, 241;
    --secondary: #ec4899;
    --secondary-rgb: 236, 72, 153;
    --accent: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg-primary: #030712;
    --bg-secondary: #0f172a;
    --bg-card: rgba(15, 23, 42, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.1);
    
    --glow: 0 0 60px rgba(99, 102, 241, 0.15);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(var(--primary-rgb), 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(var(--secondary-rgb), 0.1), transparent);
    pointer-events: none;
    z-index: -1;
}

/* Prevent zoom on input focus for iOS */
input, select, textarea {
    font-size: 16px !important;
}

/* Container */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(3, 7, 18, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 16px;
}

.logo {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo::before {
    content: '🎮';
}

nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-right: -16px;
    padding-right: 16px;
}

nav::-webkit-scrollbar { display: none; }

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.2s ease;
}

nav a:hover, nav a:active {
    color: var(--text-primary);
    background: var(--bg-glass);
}

nav a.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--glow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    font-size: 16px !important;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    padding: 0 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    user-select: none;
}

.btn:hover, .btn:active {
    transform: translateY(-1px);
    box-shadow: 0 10px 40px -10px rgba(var(--primary-rgb), 0.5);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-glass);
    border-color: var(--border-hover);
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
}

.btn-block { width: 100%; }
.btn-sm { height: 44px; padding: 0 16px; font-size: 0.875rem; }
.btn-lg { height: 56px; font-size: 1rem; }

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    font-size: 1.5rem;
    justify-content: center;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Main */
main {
    padding: 24px 0 48px;
}

.page-title {
    text-align: center;
    margin-bottom: 32px;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 16px;
}

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

@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
    .grid { gap: 20px; }
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat {
    text-align: center;
    padding: 16px 8px;
    background: var(--bg-glass);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Game Container */
.game-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.game-header {
    text-align: center;
    margin-bottom: 24px;
}

.game-code {
    display: inline-block;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.game-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 100px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.game-status {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-top: 16px;
}

.game-status strong {
    color: var(--text-primary);
}

/* Players */
.players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.player {
    padding: 16px;
    text-align: center;
    background: var(--bg-glass);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.3s ease;
}

.player.active {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.15);
}

.player-symbol {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.player.x .player-symbol { color: var(--primary); }
.player.o .player-symbol { color: var(--secondary); }

.player-name {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-you {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    aspect-ratio: 1;
    touch-action: manipulation;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 2.5rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    aspect-ratio: 1;
}

.cell:not(.taken):hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
}

.cell:not(.taken):active {
    transform: scale(0.95);
}

.cell.taken { cursor: default; }
.cell.x { color: var(--primary); }
.cell.o { color: var(--secondary); }

.cell.win {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
    to { transform: scale(1.03); }
}

/* Timer */
.timer-box {
    text-align: center;
    padding: 14px;
    margin-top: 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius);
}

.timer-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--warning);
    font-variant-numeric: tabular-nums;
}

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

.timer-box.urgent .timer-value {
    color: var(--danger);
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    50% { opacity: 0.5; }
}

/* Game Actions */
.game-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.game-actions .btn {
    flex: 1;
}

/* Active Games */
.active-games {
    max-width: 480px;
    margin: 0 auto 32px;
}

.active-game {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: var(--bg-glass);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.active-game:last-child { margin-bottom: 0; }

.active-game-info { flex: 1; min-width: 0; }

.active-game-code {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 2px;
}

.active-game-vs {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.active-game-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.active-game-timer { color: var(--warning); }

/* Join Section */
.join-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.join-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.join-form {
    display: flex;
    gap: 10px;
}

.join-form input {
    flex: 1;
    height: 52px;
    padding: 0 16px;
    font-size: 16px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    -webkit-appearance: none;
}

.join-form input:focus {
    border-color: var(--primary);
}

/* Waiting */
.waiting {
    text-align: center;
    padding: 24px;
}

.waiting-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.waiting-text {
    color: var(--text-secondary);
}

/* History */
.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-left: 3px solid var(--border);
}

.history-item.win { border-left-color: var(--success); }
.history-item.loss { border-left-color: var(--danger); }
.history-item.draw { border-left-color: var(--warning); }

.history-vs {
    font-weight: 500;
    color: var(--text-primary);
}

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

.history-result {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
}

.history-result.win { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.history-result.loss { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.history-result.draw { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* Leaderboard */
.leaderboard-wrapper {
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px;
    -webkit-overflow-scrolling: touch;
}

.leaderboard {
    width: 100%;
    min-width: 450px;
    border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
    padding: 12px;
    text-align: left;
}

.leaderboard th {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.leaderboard tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.leaderboard tbody tr:hover {
    background: var(--bg-glass);
}

.leaderboard tbody tr.me {
    background: rgba(var(--primary-rgb), 0.1);
}

.leaderboard .rank { font-weight: 700; width: 50px; }
.leaderboard .rank-1 { color: #ffd700; }
.leaderboard .rank-2 { color: #c0c0c0; }
.leaderboard .rank-3 { color: #cd7f32; }

.leaderboard .score { font-weight: 700; color: var(--primary); }
.leaderboard .w { color: var(--success); }
.leaderboard .l { color: var(--danger); }
.leaderboard .d { color: var(--warning); }

/* User Card */
.user-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    text-align: center;
    color: white;
    max-width: 400px;
    margin: 0 auto 24px;
    border: none;
}

.user-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 16px;
}

.user-card .stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 8px;
}

.user-card .stat {
    background: none;
    border: none;
}

.user-card .stat-value {
    background: white;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-card .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Profile */
.profile-info p {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.profile-info p:last-child { border-bottom: none; }
.profile-info strong { color: var(--text-primary); }

.win-rate {
    text-align: center;
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--secondary-rgb), 0.1));
    border-radius: var(--radius);
}

.win-rate-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.win-rate-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Danger Zone */
.danger-zone {
    margin-top: 24px;
    padding: 20px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius);
}

.danger-zone h3 {
    font-size: 0.9375rem;
    color: var(--danger);
    margin-bottom: 8px;
}

.danger-zone p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 340px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-backdrop.open .modal {
    transform: scale(1);
}

.modal h2 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

.modal p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Points Info */
.points-info {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-glass);
    border-radius: var(--radius);
}

.points-info h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.points-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.points-row span:first-child {
    font-weight: 700;
    min-width: 70px;
}

.points-row.positive span:first-child { color: var(--success); }
.points-row.neutral span:first-child { color: var(--warning); }
.points-row.negative span:first-child { color: var(--danger); }

/* Guide */
.guide-wrapper {
    max-width: 700px;
    margin: 0 auto;
}

.guide-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    padding: 20px;
    background: var(--bg-glass);
    border-radius: var(--radius);
    margin-bottom: 32px;
}

.guide-nav a {
    display: block;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.guide-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.guide-section {
    margin-bottom: 40px;
}

.guide-section h2 {
    font-size: 1.125rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.guide-section h3 {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 24px 0 12px;
}

.guide-section p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.7;
}

.guide-section ul, .guide-section ol {
    color: var(--text-secondary);
    margin-left: 20px;
    margin-bottom: 16px;
}

.guide-section li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.guide-box {
    padding: 20px;
    background: var(--bg-glass);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    margin: 16px 0;
}

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

.guide-box h4 {
    font-size: 0.9375rem;
    margin-bottom: 10px;
}

.guide-box p:last-child,
.guide-box ul:last-child {
    margin-bottom: 0;
}

/* Demo Board */
.demo-board {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    gap: 6px;
    margin: 20px auto;
    width: fit-content;
}

.demo-cell {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    font-weight: 800;
}

.demo-cell.x { color: var(--primary); }
.demo-cell.o { color: var(--secondary); }
.demo-cell.win {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
}

/* Score Table */
.score-table {
    width: 100%;
    margin: 16px 0;
}

.score-table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.score-table tr:last-child td {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    
    header .container { 
        height: auto; 
        flex-wrap: wrap; 
        padding: 12px; 
        gap: 8px;
    }
    
    .logo { 
        width: 100%; 
        justify-content: center; 
    }
    
    nav { 
        width: 100%; 
        justify-content: center;
        margin-right: 0;
        padding-right: 0;
    }
    
    nav a { 
        padding: 8px 10px; 
        font-size: 0.75rem; 
    }
    
    .card { padding: 20px; }
    
    .stats { gap: 8px; }
    .stat { padding: 12px 6px; }
    .stat-value { font-size: 1.25rem; }
    
    .cell { font-size: 2rem; }
    .player-symbol { font-size: 1.5rem; }
    
    .btn { height: 48px; }
    .btn-lg { height: 52px; }
    
    .game-actions { flex-direction: column; }
    .join-form { flex-direction: column; }
    .modal-actions { grid-template-columns: 1fr; }
    
    .leaderboard-wrapper { margin: 0 -20px; padding: 0 20px; }
}

/* Safe areas */
@supports (padding: env(safe-area-inset-top)) {
    header {
        padding-top: env(safe-area-inset-top);
    }
    
    main {
        padding-bottom: calc(48px + env(safe-area-inset-bottom));
    }
}
