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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f1e;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

#app {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.3s;
}

.screen.active {
    display: block;
}

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

/* Auth Screen */
.auth-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    margin: 0 auto;
}

.auth-container h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 20px;
    color: #333;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Menu Screen */
.menu-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.menu-container h1 {
    text-align: center;
    color: #667eea;
    font-size: 3em;
    margin-bottom: 20px;
}

.user-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.user-info p {
    font-size: 16px;
    color: #555;
}

.user-info span {
    font-weight: bold;
    color: #667eea;
}

.menu-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.menu-btn {
    background: white;
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.menu-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.menu-btn h3 {
    margin-bottom: 10px;
    font-size: 1.5em;
}

.menu-btn p {
    font-size: 0.9em;
    opacity: 0.8;
}

.menu-btn.secondary {
    border-color: #e0e0e0;
}

.menu-btn.secondary:hover {
    background: #f0f0f0;
    color: #333;
}

/* Game Screen */
.game-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.btn-back {
    padding: 10px 20px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

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

.game-header h2 {
    color: #667eea;
    flex: 1;
    text-align: center;
}

.game-layout {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    min-width: 150px;
    text-align: center;
}

.info-box h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.info-box p {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.game-board {
    position: relative;
}

#game-canvas {
    border: 3px solid #2a2a3e;
    border-radius: 4px;
    background: #1a1a2e;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#next-canvas {
    border: 2px solid #2a2a3e;
    border-radius: 4px;
    background: #1a1a2e;
    display: block;
    margin: 0 auto;
}

.opponent-board {
    text-align: center;
}

.opponent-board h3 {
    margin-bottom: 10px;
    color: #667eea;
}

#opponent-canvas {
    border: 3px solid #2a2a3e;
    border-radius: 4px;
    background: #1a1a2e;
    display: block;
    margin: 0 auto 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}

.game-controls {
    margin-top: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
}

.overlay-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.overlay-content p {
    margin: 10px 0;
    font-size: 18px;
}

.overlay-content button {
    margin: 10px 5px;
    padding: 12px 24px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Leaderboard */
.leaderboard-container, .stats-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-height: 500px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#leaderboard-table th {
    background: #667eea;
    color: white;
    padding: 15px;
    text-align: left;
    font-size: 16px;
}

#leaderboard-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

#leaderboard-table tr:hover {
    background: #f8f9fa;
}

#leaderboard-table tr:nth-child(1) td:first-child {
    color: #FFD700;
    font-weight: bold;
    font-size: 20px;
}

#leaderboard-table tr:nth-child(2) td:first-child {
    color: #C0C0C0;
    font-weight: bold;
    font-size: 18px;
}

#leaderboard-table tr:nth-child(3) td:first-child {
    color: #CD7F32;
    font-weight: bold;
    font-size: 18px;
}

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

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

.stat-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    opacity: 0.9;
}

.stat-card p {
    font-size: 36px;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-buttons {
        grid-template-columns: 1fr;
    }
    
    .game-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .user-info {
        grid-template-columns: 1fr;
    }
}

/* Error and Success Messages */
.form-group {
    margin-bottom: 15px;
}

.error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
    display: none;
}

.error-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

.success-message {
    color: #28a745;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
    display: none;
}

.success-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

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

/* Verification Section */
.verification-group {
    position: relative;
}

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

.verification-input-group input {
    flex: 1;
    margin-bottom: 0;
}

.btn-verify {
    padding: 12px 20px;
    border: none;
    background: #28a745;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.3s;
}

.btn-verify:hover {
    background: #218838;
}

.btn-verify:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: #17a2b8;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: bold;
    margin-bottom: 4px;
    color: #333;
}

.toast-message {
    font-size: 14px;
    color: #666;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

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

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

/* Ghost Piece (Preview of landing position) */
.ghost-piece {
    opacity: 0.3;
}
