/* ============================================================
   ScrollChess — Design System
   Dark, glassy, neon-accented. Pure CSS layer on top of Tailwind.
   ============================================================ */

:root {
    --bg-dark: #0b1326;
    --bg-darker: #060e20;
    --surface: #171f33;
    --surface-low: #131b2e;
    --surface-high: #222a3d;
    --text-main: #dae2fd;
    --text-muted: #cfc2d6;
    --primary: #ddb7ff;
    --primary-strong: #b76dff;
    --secondary: #4ae176;
    --accent: #ffb3ad;
    --danger: #ff5451;
    --glass-bg: rgba(23, 31, 51, 0.72);
    --glass-border: rgba(221, 183, 255, 0.14);
    --radius: 18px;
    --radius-sm: 10px;
    --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Inter', 'Outfit', sans-serif;
    background-color: var(--bg-darker);
    color: var(--text-main);
    line-height: 1.55;
    /* Deep cosmic gradient with a soft purple bloom at the top */
    background-image:
        radial-gradient(circle at 50% -10%, #2a1b4d 0%, transparent 55%),
        radial-gradient(circle at 12% 85%, rgba(74, 225, 118, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 88% 70%, rgba(183, 109, 255, 0.08) 0%, transparent 45%),
        linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
    background-attachment: fixed;
}

/* Subtle animated starfield overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 15%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 45% 60%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 80%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 10% 90%, rgba(255,255,255,0.3) 0%, transparent 100%);
    opacity: 0.5;
}

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

/* ============ Glassmorphism ============ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.55);
}

.glass-strong {
    background: rgba(11, 19, 38, 0.88);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(221, 183, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* ============ Typography ============ */
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; }
.highlight { color: var(--secondary); font-weight: 800; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 26px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    color: #1a0b2e;
}
.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(221, 183, 255, 0.4), 0 8px 24px -6px rgba(183, 109, 255, 0.5);
}
.btn-secondary {
    background: var(--surface-high);
    color: var(--text-main);
    border: 1px solid rgba(221, 183, 255, 0.18);
}
.btn-secondary:not(:disabled):hover {
    background: #2d3449;
    transform: translateY(-1px);
}
.btn-small {
    padding: 7px 16px;
    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: 14px 22px;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    margin-bottom: 24px;
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(221, 183, 255, 0.6));
}
.logo h1 {
    font-size: 1.3rem;
    margin: 0;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.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.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.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: linear-gradient(180deg, var(--surface), var(--bg-dark));
    border-radius: var(--radius);
    border: 1px solid rgba(221, 183, 255, 0.16);
    overflow: hidden;
    box-shadow: 0 14px 40px -10px rgba(0, 0, 0, 0.5);
    transition: var(--transition);
}
.game-card:hover {
    border-color: rgba(221, 183, 255, 0.3);
    box-shadow: 0 18px 50px -10px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(221, 183, 255, 0.08);
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(221, 183, 255, 0.12);
}
.game-meta { display: flex; align-items: center; gap: 12px; }
.badge.live {
    background: rgba(255, 84, 81, 0.16);
    color: var(--danger);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    animation: pulse 2s infinite;
    box-shadow: 0 0 0 1px rgba(255, 84, 81, 0.3);
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.55; }
    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(--secondary);
    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: #0a0f1e;
    border: 1px solid rgba(221, 183, 255, 0.12);
    border-radius: var(--radius-sm);
}
.board-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 14, 32, 0.6);
    backdrop-filter: blur(6px);
    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(--secondary) !important;
}

/* ============ Next Game Hint ============ */
.next-game-hint {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 0;
    color: var(--text-muted);
    opacity: 0.75;
}
.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(6, 14, 32, 0.7);
    backdrop-filter: blur(6px);
}
.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.6);
    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; transform: rotate(90deg); }
.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: 6px;
    transition: var(--transition);
}
.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    color: #1a0b2e;
}
.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 rgba(221, 183, 255, 0.16);
    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(183, 109, 255, 0.25);
}
.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 12px;
    text-align: center;
}

/* ============ Custom scrollbar ============ */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(221, 183, 255, 0.25);
    border-radius: 999px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

/* ============ Selection color ============ */
::selection {
    background: var(--primary);
    color: #1a0b2e;
}