:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #334155;
    --secondary-hover: #475569;
    --accent: #f59e0b;
    --danger: #ef4444;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-darker);
    color: var(--text-main);
    line-height: 1.5;
    /* Subtle gradient background */
    background-image: radial-gradient(circle at 50% 0%, #1e1b4b 0%, var(--bg-darker) 70%);
    background-attachment: fixed;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.glass-strong {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Typography */
h1, h2, h3 { font-weight: 800; }
.highlight { color: var(--accent); font-weight: 800; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:not(:disabled):hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.btn-secondary {
    background: var(--secondary);
    color: white;
}
.btn-secondary:not(:disabled):hover {
    background: var(--secondary-hover);
}
.btn-small {
    padding: 6px 14px;
    font-size: 0.875rem;
}
.full-width { width: 100%; }

/* Top Nav */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    margin-bottom: 24px;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.5rem; }
.logo h1 { font-size: 1.25rem; margin: 0; }
.user-status { display: flex; align-items: center; gap: 16px; }
.stats { display: flex; gap: 16px; }
.stat-item { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-weight: 800; font-size: 1.125rem; }

/* Feed & Game Card */
.feed-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px 32px;
}
.feed-wrapper {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.game-card {
    background: var(--bg-dark);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
}
.game-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
}
.game-meta { display: flex; align-items: center; gap: 12px; }
.badge.live {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}
.game-id { color: var(--text-muted); font-weight: 600; font-size: 0.875rem; }
.timer-container {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.timer-container.danger { color: var(--danger); }

/* Board Area */
.board-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    background: #111;
}
.board-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 24px;
}
.overlay-content {
    text-align: center;
    padding: 24px;
    border-radius: var(--radius);
    max-width: 80%;
}
.overlay-content h3 { margin-bottom: 8px; }
.overlay-content p { color: var(--text-muted); font-size: 0.875rem; }
.hidden { display: none !important; }

/* Actions */
.game-actions {
    display: flex;
    gap: 12px;
    padding: 16px;
}
.action-btn { flex: 1; }

.square-highlight {
    box-shadow: inset 0 0 0 4px var(--accent) !important;
}

/* Next Game Hint */
.next-game-hint {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 0;
    color: var(--text-muted);
    opacity: 0.7;
}
.hint-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: bounce 2s infinite;
}
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    padding: 32px;
    z-index: 1001;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}
.modal-close:hover { color: white; }
.modal-header { text-align: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.75rem; margin-bottom: 8px; }
.modal-header p { color: var(--text-muted); }

.tabs {
    display: flex;
    background: var(--bg-darker);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.tab-btn.active {
    background: var(--secondary);
    color: white;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
}
.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-darker);
    border: 1px solid var(--glass-border);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 12px;
    text-align: center;
}
