/* ═══════════════════════════════════════════════════════════════
   OomfTopia — Stylesheet
   Dark glassmorphic theme with premium micro-animations.
   ═══════════════════════════════════════════════════════════════ */

/* ===== Design Tokens ===== */
:root {
    /* Backgrounds */
    --bg-primary:      #0a0e1a;
    --bg-secondary:    #111827;
    --bg-glass:        rgba(17, 24, 39, 0.72);
    --bg-glass-hover:  rgba(17, 24, 39, 0.88);
    --border-glass:    rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary:    #f1f5f9;
    --text-secondary:  #94a3b8;
    --text-muted:      #64748b;

    /* Accent */
    --accent-primary:   #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow:      rgba(99, 102, 241, 0.30);

    /* Semantic */
    --success: #22c55e;
    --error:   #ef4444;
    --warning: #f59e0b;

    /* Radii */
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    /* Shadows */
    --shadow-sm:  0 2px  8px rgba(0,0,0,0.30);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.40);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.50);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow:   400ms ease;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ===== Screen Management ===== */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* ══════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════ */

#login-screen {
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1040 50%, #0a0e1a 100%);
}

/* Ambient glow blobs */
#login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(99,102,241,0.08) 0%, transparent 50%);
    animation: loginPulse 8s ease-in-out infinite alternate;
}

@keyframes loginPulse {
    0%   { opacity: 0.6; transform: scale(1); }
    100% { opacity: 1;   transform: scale(1.02); }
}

/* ── Login Card ── */
.login-card {
    position: relative;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), 0 0 80px rgba(99,102,241,0.08);
    animation: cardAppear 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
}

/* ── Header ── */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #a78bfa, #6366f1);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.04em;
}

/* ── Tabs ── */
.login-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab-btn.active {
    background: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── Form ── */
#auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-fast);
}

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

.form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255,255,255,0.07);
}

/* ── Buttons ── */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.10);
    color: var(--text-primary);
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-small:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: var(--error);
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

/* ── Divider ── */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-glass);
}

/* ── Error Message ── */
.error-msg {
    color: var(--error);
    font-size: 0.85rem;
    text-align: center;
    min-height: 20px;
    margin-top: 4px;
}

/* ══════════════════════════════════════════════
   GAME SCREEN
   ══════════════════════════════════════════════ */

#game-screen {
    background: var(--bg-primary);
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

/* ══════════════════════════════════════════════
   HUD OVERLAY
   ══════════════════════════════════════════════ */

#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* Re-enable pointer events on HUD children */
#hud > * {
    pointer-events: all;
}

.hud-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    animation: hudSlideIn 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes hudSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ── Player Info Bar ── */
#player-info {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    animation-delay: 100ms;
}

#player-name {
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

/* ── Chat Panel ── */
#chat-panel {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 340px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation-delay: 200ms;
}

#chat-panel.collapsed #chat-messages,
#chat-panel.collapsed #chat-input-container {
    display: none;
}

#chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
}

#chat-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#chat-messages {
    height: 200px;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 4px;
}
#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

.chat-message {
    font-size: 0.85rem;
    line-height: 1.4;
    animation: chatFadeIn 200ms ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-message .sender {
    font-weight: 600;
    color: var(--accent-secondary);
}

.chat-message .text {
    color: var(--text-secondary);
}

.chat-message.system {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

#chat-input-container {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-glass);
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

#chat-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

/* ── Item Toolbar ── */
#item-toolbar {
    position: absolute;
    bottom: 16px;
    right: 16px;
    padding: 8px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation-delay: 300ms;
}

.btn-tool {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-tool:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.35);
    color: var(--text-primary);
    transform: translateX(-2px);
    box-shadow: 4px 0 16px rgba(99,102,241,0.10);
}

.btn-tool:active {
    transform: translateX(0);
}

.tool-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════ */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.60);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    transition: opacity var(--transition-normal);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: modalAppear 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-content input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    outline: none;
    margin-bottom: 20px;
    transition: border-color var(--transition-fast);
}

.modal-content input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ══════════════════════════════════════════════
   UTILITY
   ══════════════════════════════════════════════ */

.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }

    .login-header h1 {
        font-size: 2rem;
    }

    #chat-panel {
        width: calc(100vw - 32px);
        bottom: 8px;
        left: 8px;
    }

    #item-toolbar {
        right: 8px;
        bottom: 8px;
        flex-direction: row;
    }

    .tool-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px;
        border-radius: var(--radius-lg);
    }

    #player-info {
        top: 8px;
        left: 8px;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    #chat-messages {
        height: 140px;
    }
}
