/* ============================================================
   WWBingo — Global Styles
   ============================================================ */

:root {
    --bg:            #0d0d1a;
    --bg2:           #12122b;
    --glass:         rgba(255, 255, 255, 0.07);
    --glass-border:  rgba(255, 255, 255, 0.14);
    --purple:        #7c3aed;
    --purple-light:  #a78bfa;
    --purple-dark:   #5b21b6;
    --pink:          #c026d3;
    --gold:          #f59e0b;
    --gold-light:    #fcd34d;
    --text:          #f1f5f9;
    --text-dim:      #94a3b8;
    --radius:        14px;
    --radius-sm:     8px;
    --shadow:        0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-sm:     0 4px 20px rgba(0, 0, 0, 0.3);
}

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

html, body {
    min-height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* ── Background orbs ─────────────────────────────────────── */
.bg-orbs {
    position: fixed; inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: drift 18s ease-in-out infinite alternate;
}
.orb-1 { width: 500px; height: 500px; background: #7c3aed; top: -150px; left: -150px; animation-duration: 20s; }
.orb-2 { width: 400px; height: 400px; background: #c026d3; bottom: -100px; right: -100px; animation-duration: 25s; animation-delay: -8s; }
.orb-3 { width: 300px; height: 300px; background: #2563eb; top: 40%; left: 50%; animation-duration: 15s; animation-delay: -4s; }

@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, 30px) scale(1.08); }
}

/* ── Lobby ───────────────────────────────────────────────── */
.lobby {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 16px;
}

.lobby-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 520px;
    padding: 40px 36px;
    animation: slide-up 0.5s ease both;
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Logo */
.logo-section {
    text-align: center;
    margin-bottom: 36px;
}
.logo-icon svg {
    width: 64px; height: 64px;
    filter: drop-shadow(0 6px 18px rgba(124, 58, 237, 0.5));
}
.logo-title {
    font-size: 2.2rem; font-weight: 800;
    letter-spacing: -0.5px;
    margin: 12px 0 6px;
    color: var(--text);
}
.logo-title span { color: var(--purple-light); }
.logo-subtitle {
    color: var(--text-dim);
    font-size: 0.95rem;
}

/* Lobby body */
.lobby-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.lobby-section { padding: 8px 0 20px; }
.lobby-section h2 {
    font-size: 1.1rem; font-weight: 700;
    margin-bottom: 6px;
}
.section-desc {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Divider */
.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-dim); font-size: 0.85rem;
    padding: 4px 0 20px;
}
.divider::before, .divider::after {
    content: ''; flex: 1;
    height: 1px;
    background: var(--glass-border);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    user-select: none;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: #fff;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    width: 100%;
    justify-content: center;
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 28px rgba(124, 58, 237, 0.6); transform: translateY(-1px); }

.btn-secondary {
    background: rgba(124, 58, 237, 0.2);
    color: var(--purple-light);
    border: 1px solid rgba(124, 58, 237, 0.4);
    flex-shrink: 0;
}
.btn-secondary:hover:not(:disabled) { background: rgba(124, 58, 237, 0.35); }

.btn-gold {
    background: linear-gradient(135deg, #d97706, var(--gold));
    color: #1a0a00;
    font-weight: 700;
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.4);
    width: 100%;
    justify-content: center;
    margin-top: 12px;
}
.btn-gold:hover:not(:disabled) { box-shadow: 0 6px 26px rgba(245, 158, 11, 0.6); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: var(--glass); color: var(--text); }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

/* Icon button */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.08);
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.16); color: var(--text); }
.icon-btn.copied { background: rgba(34, 197, 94, 0.2); color: #4ade80; border-color: #4ade80; }

/* Created result */
.created-result {
    margin-top: 20px;
    padding: 20px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 12px;
    animation: pop-in 0.3s ease both;
}
@keyframes pop-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.small-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}
.id-badge {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
}
.id-value {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--purple-light);
}

/* Join row */
.join-row {
    display: flex; gap: 10px; align-items: stretch;
}
.id-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.id-input::placeholder { color: rgba(255,255,255,0.2); letter-spacing: 0.1em; font-size: 1rem; }
.id-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}

/* Error message */
.error-msg {
    color: #f87171;
    font-size: 0.85rem;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(248, 113, 113, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ── Game page ───────────────────────────────────────────── */
.game-page {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(13, 13, 26, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky; top: 0; z-index: 10;
    gap: 12px;
}
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.session-info-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    font-size: 0.9rem;
}
.badge-label { color: var(--text-dim); }
.badge-id {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--purple-light);
}

/* Game main */
.game-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* Loading / error */
.loading-state, .error-state {
    text-align: center;
    color: var(--text-dim);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(124,58,237,0.2);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state a { color: var(--purple-light); }

/* Game area */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: slide-up 0.4s ease both;
}
.hint-text {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-align: center;
}

/* Bingo board */
.bingo-board {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 580px;
}

.bingo-letters {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}
.bingo-letters span {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--purple-light);
    padding: 6px 0;
    text-shadow: 0 0 12px rgba(167, 139, 250, 0.4);
}

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

/* Cells */
.bingo-cell {
    height: clamp(64px, 15vw, 96px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.bingo-cell:hover:not(.free-cell) {
    background: rgba(124, 58, 237, 0.18);
    border-color: rgba(124, 58, 237, 0.4);
}
.bingo-cell.marked {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.6), rgba(192, 38, 211, 0.5));
    border-color: rgba(167, 139, 250, 0.6);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.35);
}
.bingo-cell.free-cell {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.5), rgba(245, 158, 11, 0.4));
    border-color: rgba(245, 158, 11, 0.6);
    cursor: default;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}
.bingo-cell.bingo-line {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.7), rgba(245, 158, 11, 0.6));
    border-color: var(--gold-light);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.55);
    animation: bingo-pulse 1s ease infinite;
}

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

.cell-text {
    font-size: clamp(9px, 1.9vw, 12px);
    font-weight: 600;
    text-align: center;
    line-height: 1.25;
    color: var(--text);
    pointer-events: none;
}
.bingo-cell.marked .cell-text,
.bingo-cell.free-cell .cell-text {
    color: #fff;
}
.bingo-cell.free-cell .cell-text {
    font-size: clamp(11px, 2.2vw, 14px);
    font-weight: 800;
    letter-spacing: 0.05em;
}

/* Mark animation */
.pop-anim { animation: cell-pop 0.25s ease; }
@keyframes cell-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ── Bingo overlay ───────────────────────────────────────── */
.bingo-overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: fade-in 0.3s ease;
}
.bingo-overlay.hidden { display: none; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.bingo-modal {
    background: linear-gradient(145deg, #1e1040, #2d1060);
    border: 1px solid rgba(167, 139, 250, 0.4);
    border-radius: 24px;
    padding: 48px 56px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    animation: modal-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}
.bingo-banner {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, var(--gold-light), var(--gold), #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 1.5s linear infinite;
    background-size: 200%;
}
@keyframes shimmer {
    from { background-position: 0% 50%; }
    to   { background-position: 200% 50%; }
}
.bingo-sub {
    color: var(--text-dim);
    margin: 12px 0 0;
    font-size: 1rem;
}
.bingo-modal .btn-gold {
    width: auto;
    margin-top: 24px;
    padding: 12px 36px;
}

/* ── Confetti ────────────────────────────────────────────── */
.confetti-piece {
    position: fixed;
    top: -20px;
    pointer-events: none;
    z-index: 200;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .lobby-card { padding: 28px 20px; }
    .logo-title { font-size: 1.8rem; }
    .game-header { padding: 12px 16px; }
    .bingo-board { padding: 10px; border-radius: 14px; }
    .bingo-letters span { font-size: 1rem; }
    .bingo-modal { padding: 36px 28px; }
}