@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Outfit:wght@300;400;500;600&display=swap');

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

:root {
    --gold: #c9a84c;
    --gold-light: #e8cc7a;
    --gold-dark: #8b6914;
    --cream: #f5f0e8;
    --dark: #0a0a0f;
    --dark-2: #111118;
    --dark-3: #18181f;
    --dark-4: #22222c;
    --border: rgba(201, 168, 76, 0.2);
    --border-bright: rgba(201, 168, 76, 0.5);
    --text-muted: rgba(245, 240, 232, 0.45);
    --text-mid: rgba(245, 240, 232, 0.75);
    --white: #f5f0e8;
    --error: #d64f4f;
    --success: #4caf7d;
    --glow: 0 0 40px rgba(201, 168, 76, 0.15);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--dark);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

/* ─── CANVAS ─── */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ─── BOARD PATTERN OVERLAY ─── */
.board-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(201,168,76,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201,168,76,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 40%, transparent 100%);
}

/* ─── VIGNETTE ─── */
.vignette {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse 90% 90% at 50% 50%, transparent 30%, rgba(10,10,15,0.8) 100%);
}

/* ─── CONNECTION STATUS ─── */
.connection-status {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    z-index: 100;
    font-family: 'Outfit', sans-serif;
    border: 1px solid transparent;
}
.connection-online { background: rgba(76,175,125,0.15); color: #4caf7d; border-color: rgba(76,175,125,0.3); }
.connection-offline { background: rgba(214,79,79,0.15); color: #d64f4f; border-color: rgba(214,79,79,0.3); }
.connection-checking { background: rgba(201,168,76,0.1); color: var(--gold); border-color: var(--border); }

/* ─── MAIN LAYOUT ─── */
.scene {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}
.scene::-webkit-scrollbar { display: none; }

/* ─── LOGO ─── */
.logo-area {
    text-align: center;
    margin-bottom: 32px;
    animation: fadeDown 0.8s ease both;
}

.crown-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.crown-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(201,168,76,0.3) 0%, transparent 70%);
    animation: pulseGlow 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.5; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.crown-icon {
    font-size: 52px;
    display: block;
    animation: floatKing 4s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(201,168,76,0.6));
}

@keyframes floatKing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.brand-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 36px;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--cream);
    text-transform: uppercase;
}
.brand-name span {
    color: var(--gold);
    font-weight: 600;
}

.brand-tagline {
    font-size: 11px;
    letter-spacing: 0.3em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ─── CARD ─── */
.auth-card {
    width: 100%;
    background: linear-gradient(145deg, rgba(24,24,31,0.95), rgba(17,17,24,0.98));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px 32px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--glow), 0 40px 80px rgba(0,0,0,0.6);
    animation: fadeUp 0.8s ease 0.2s both;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
    opacity: 0.6;
}

.auth-card::after {
    content: '';
    position: absolute;
    top: -80px; right: -80px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(201,168,76,0.06) 0%, transparent 70%);
    pointer-events: none;
}

/* ─── FORM HEADER ─── */
.form-header {
    margin-bottom: 28px;
}

.form-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 26px;
    font-weight: 400;
    color: var(--cream);
    letter-spacing: 0.05em;
}

.form-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.02em;
}

/* ─── GOOGLE BUTTON ─── */
.google-btn {
    width: 100%;
    padding: 13px 20px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: var(--cream);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    letter-spacing: 0.02em;
}
.google-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}
.google-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ─── DIVIDER ─── */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* ─── FORM FIELDS ─── */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.form-group input {
    width: 100%;
    padding: 13px 44px 13px 42px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    color: var(--cream);
    transition: all 0.3s ease;
    outline: none;
    letter-spacing: 0.02em;
}
.form-group input::placeholder { color: var(--text-muted); opacity: 0.7; }
.form-group input:focus {
    border-color: var(--border-bright);
    background: rgba(201,168,76,0.04);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.08), inset 0 0 20px rgba(201,168,76,0.02);
}
.form-group input:focus + .input-icon,
.form-group:focus-within .input-icon {
    opacity: 0.9;
}
.form-group input.error { border-color: rgba(214,79,79,0.5); }

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 15px;
    opacity: 0.4;
    transition: opacity 0.2s;
    user-select: none;
    z-index: 2;
}
.password-toggle:hover { opacity: 0.8; }

/* ─── PASSWORD STRENGTH ─── */
.password-strength { margin-top: 8px; }
.strength-bar {
    height: 2px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}
.strength-fill { height: 100%; border-radius: 2px; transition: all 0.4s ease; }
.strength-weak { background: var(--error); width: 25%; }
.strength-fair { background: #e8a94c; width: 50%; }
.strength-good { background: #a4c44c; width: 75%; }
.strength-strong { background: var(--success); width: 100%; }
#strengthText { font-size: 11px; color: var(--text-muted); letter-spacing: 0.05em; }

/* ─── PRIMARY BUTTON ─── */
.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
    background-size: 200% 200%;
    background-position: 0% 50%;
    border: none;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    margin-top: 8px;
}
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}
.btn-primary:hover:not(:disabled)::before { left: 100%; }
.btn-primary:hover:not(:disabled) {
    background-position: 100% 50%;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(201,168,76,0.35);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── MESSAGES ─── */
.error-message, .success-message {
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
    animation: fadeIn 0.3s ease;
    letter-spacing: 0.02em;
}
.error-message {
    background: rgba(214,79,79,0.1);
    color: #f08080;
    border: 1px solid rgba(214,79,79,0.25);
}
.success-message {
    background: rgba(76,175,125,0.1);
    color: #7dcfa5;
    border: 1px solid rgba(76,175,125,0.25);
}

/* ─── FORM FOOTER ─── */
.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.8;
}
.form-link {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
    padding: 0;
}
.form-link:hover { color: var(--gold-light); text-decoration: underline; }

/* ─── DECORATIVE CHESS RANK ─── */
.chess-rank {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 24px;
    opacity: 0.18;
    font-size: 20px;
    letter-spacing: 2px;
    user-select: none;
    pointer-events: none;
}

/* ─── FORM TRANSITIONS ─── */
.form-slide { display: block; }
.form-slide.hidden { display: none; }

/* ─── DEBUG ─── */
.debug-info {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-muted);
    max-height: 150px;
    overflow-y: auto;
    display: none;
    white-space: pre-wrap;
}
.debug-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    margin-top: 12px;
    letter-spacing: 0.05em;
    transition: color 0.2s;
    font-family: 'Outfit', sans-serif;
}
.debug-toggle:hover { color: var(--gold); }

/* ─── LOADING ─── */
.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(10,10,15,0.3);
    border-top-color: var(--dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* ─── RETRY BUTTON ─── */
.retry-btn {
    background: rgba(214,79,79,0.15);
    color: #f08080;
    border: 1px solid rgba(214,79,79,0.3);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    transition: all 0.2s;
    margin-top: 12px;
}
.retry-btn:hover { background: rgba(214,79,79,0.25); transform: translateY(-1px); }

.btn-secondary {
    width: 100%;
    padding: 11px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-mid);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.btn-secondary:hover { border-color: var(--border-bright); color: var(--cream); }

.connection-error { text-align: center; padding: 10px 0; }
.connection-error h3 { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: #f08080; margin-bottom: 10px; }
.connection-error h4 { font-size: 14px; font-weight: 500; color: var(--text-mid); margin: 16px 0 8px; }
.connection-error ul { text-align: left; margin-left: 16px; color: var(--text-muted); font-size: 13px; line-height: 2; }

/* ─── KEYFRAMES ─── */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 520px) {
    .scene { padding: 16px; }
    .auth-card { padding: 28px 20px; border-radius: 16px; }
    .brand-name { font-size: 28px; }
    .crown-icon { font-size: 40px; }
    .logo-area { margin-bottom: 20px; }
    .connection-status { top: 12px; right: 12px; font-size: 10px; }
}

/* ─── REVIEW STYLES (kept for compatibility) ─── */
.review-content { font-family: 'Courier New', monospace; }
#reviewGameBtn { background: linear-gradient(45deg, #9b59b6, #8e44ad) !important; }