/**
 * Scrambled Up Test Client - Styles
 * 
 * Color Palette:
 * - Primary: #6366f1 (Indigo)
 * - Secondary: #22c55e (Green)
 * - Accent: #f59e0b (Amber)
 * - Background: #0f172a (Slate 900)
 * - Surface: #1e293b (Slate 800)
 * - Text: #f8fafc (Slate 50)
 */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #22c55e;
    --secondary-dark: #16a34a;
    --accent: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-surface: #1e293b;
    --bg-elevated: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #475569;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

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

body {
    font-family: var(--font-display);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Mobile-first sizing */
    max-width: 430px;
    margin: 0 auto;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 50%, var(--bg-dark) 100%);
}

/* Banner Image */
.banner {
    text-align: center;
    margin-bottom: 1rem;
    width: 100%;
}

.banner-image {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo-image {
    width: 200px;
    height: auto;
    margin-bottom: 0.5rem;
    animation: pulse-glow 3s infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.4)); }
    50% { filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.8)); }
}

/* Header Logo */
.header-logo {
    height: 40px;
    width: auto;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.login-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

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

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-display);
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

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

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.error-message.hidden {
    display: none;
}

.debug-toggle {
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.debug-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-buzz {
    background: linear-gradient(135deg, var(--accent), #ea580c);
    color: white;
    font-size: 1.25rem;
    padding: 1rem 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-small {
    font-size: 1.5rem;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-stats {
    display: flex;
    gap: 1rem;
}

.stat {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

#user-display-name {
    font-weight: 600;
}

/* Game Nav */
.game-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.nav-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Views */
.view {
    display: none;
    padding: 2rem;
}

.view.active {
    display: block;
}

/* Lobby View */
.lobby-status {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.status-card {
    flex: 1;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.status-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

.status-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.game-modes h2 {
    margin-bottom: 1.5rem;
}

/* Mode Card Buttons */
.mode-card-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: var(--font-display);
}

.mode-card-btn:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
    transform: scale(1.02);
}

.mode-card-btn:active {
    transform: scale(0.98);
}

.mode-card-btn[data-mode="solo"]:hover {
    border-color: var(--secondary);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.mode-card-btn[data-mode="group"]:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.mode-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.mode-info {
    flex: 1;
}

.mode-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.mode-info p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.mode-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: transform 0.2s, color 0.2s;
}

.mode-card-btn:hover .mode-arrow {
    transform: translateX(5px);
    color: var(--primary);
}

/* Game View */
.game-area {
    max-width: 800px;
    margin: 0 auto;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.game-info span {
    font-family: var(--font-mono);
}

.puzzle-container {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
}

.timer-bar {
    height: 8px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--accent));
    width: 100%;
    transition: width 0.1s linear;
}

.time-remaining {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 2rem;
}

.scrambled-word-container {
    margin-bottom: 2rem;
}

.scrambled-word {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    color: var(--primary-light);
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
    margin-bottom: 0.5rem;
}

.word-length {
    color: var(--text-muted);
}

.clues-section {
    margin-bottom: 2rem;
}

.clues-display {
    margin-top: 1rem;
    text-align: left;
}

.clue-item {
    background: var(--bg-dark);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    border-left: 3px solid var(--accent);
}

.answer-section {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.answer-section input {
    flex: 1;
    min-width: 200px;
    text-align: center;
    font-size: 1.25rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.feedback {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
}

.feedback.correct {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid var(--success);
    color: var(--success);
}

.feedback.wrong {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid var(--error);
    color: var(--error);
}

.feedback.hidden {
    display: none;
}

.game-controls {
    margin-top: 2rem;
    text-align: center;
}

/* Group Matchmaking Section */
.group-matchmaking {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    margin: 2rem;
}

.group-matchmaking.hidden {
    display: none;
}

.group-matchmaking h2 {
    margin-bottom: 0.5rem;
}

.matchmaking-desc {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-large {
    padding: 1.25rem 3rem;
    font-size: 1.25rem;
    width: 100%;
    margin-bottom: 1rem;
}

.game-waiting, .game-over {
    text-align: center;
    padding: 4rem 2rem;
}

.game-waiting.hidden, .game-over.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-elevated);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.final-score {
    margin: 2rem 0;
}

.final-score .label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.final-score .value {
    font-size: 4rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--secondary);
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.game-stats .stat .label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.game-stats .stat .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Leaderboard View */
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.period-tabs {
    display: flex;
    gap: 0.5rem;
}

.period-tab {
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    cursor: pointer;
    transition: all 0.2s;
}

.period-tab:hover {
    border-color: var(--primary);
}

.period-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.my-rank-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.rank-label {
    display: block;
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
}

.rank-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

.leaderboard-list {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-entry.top-3 {
    background: rgba(245, 158, 11, 0.1);
}

.entry-rank {
    width: 2.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1.25rem;
}

.entry-rank.gold { color: #fbbf24; }
.entry-rank.silver { color: #94a3b8; }
.entry-rank.bronze { color: #d97706; }

.entry-name {
    flex: 1;
    font-weight: 600;
}

.entry-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--secondary);
}

.entry-winrate {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Profile View */
.profile-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.profile-avatar {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.profile-card h2 {
    margin-bottom: 0.25rem;
}

.profile-card p {
    color: var(--text-secondary);
}

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

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.stat-card .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--primary-light);
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.profile-actions {
    text-align: center;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 400px;
    max-height: 50vh;
    background: var(--bg-surface);
    border-top-left-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.debug-panel.hidden {
    display: none;
}

.debug-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-top-left-radius: var(--radius-lg);
}

.debug-header h3 {
    flex: 1;
    font-size: 0.875rem;
}

.debug-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.debug-entry {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
}

.debug-entry.request { border-left-color: var(--primary); }
.debug-entry.response { border-left-color: var(--secondary); }
.debug-entry.error { border-left-color: var(--error); }

.debug-entry .timestamp {
    color: var(--text-muted);
    font-size: 0.625rem;
}

.debug-entry .method {
    color: var(--accent);
    font-weight: 700;
}

.debug-entry pre {
    margin-top: 0.25rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-surface);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--primary); }

/* Invites Section */
.invites-section {
    margin-top: 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.invites-section.hidden {
    display: none;
}

.invite-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    margin-top: 0.75rem;
}

.invite-info {
    flex: 1;
}

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

.invite-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-nav {
        flex-wrap: wrap;
    }
    
    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .scrambled-word {
        font-size: 2rem;
        letter-spacing: 0.25rem;
    }
    
    .answer-section {
        flex-direction: column;
    }
    
    .debug-panel {
        width: 100%;
        border-radius: 0;
    }
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

