/* ============================================
   IMPORTS & RESET
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

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

body {
    font-family: 'Inter', sans-serif;
    background: #0f0f1a;
    color: #fff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   LOGIN OVERLAY
   ============================================ */
#loginOverlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 25, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#loginCard {
    background: linear-gradient(145deg, #1c1c32, #252540);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    width: 320px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
    animation: fadeInScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

#loginCard h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#loginCard p {
    color: rgba(255,255,255,0.5);
    font-size: 0.88rem;
    margin-bottom: 28px;
}

#usernameInput {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    margin-bottom: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#usernameInput:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}

#usernameInput::placeholder {
    color: rgba(255,255,255,0.3);
}

#joinBtn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

#joinBtn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

#joinBtn:active {
    transform: translateY(0px);
}

/* ============================================
   GAME WRAPPER
   ============================================ */
#gameWrapper {
    display: none;
    flex-direction: column;
    height: 100vh;
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    flex-wrap: wrap;
}

#myNameTag {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

#myNameDisplay {
    color: #a78bfa;
}

.toolbar-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    flex-shrink: 0;
}

/* Tool buttons */
.tool-group {
    display: flex;
    gap: 4px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 7px;
}

.tool-btn svg {
    width: 100%;
    height: 100%;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.tool-btn.active {
    background: rgba(167, 139, 250, 0.2);
    border-color: #a78bfa;
    color: #a78bfa;
}

/* Color area */
.color-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#colorPicker {
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    padding: 2px;
    background: none;
    transition: border-color 0.2s, transform 0.15s;
    flex-shrink: 0;
}

#colorPicker:hover {
    border-color: rgba(255,255,255,0.5);
    transform: scale(1.08);
}

/* Color palette swatches */
.palette {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.swatch {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.swatch:hover {
    transform: scale(1.2);
}

.swatch.selected {
    border-color: #fff;
    transform: scale(1.15);
}

/* Eyedropper active cursor */
body.tool-pick #canvasScroller {
    cursor: crosshair;
}

body.tool-draw #canvasScroller {
    cursor: crosshair;
}

body.tool-erase #canvasScroller {
    cursor: cell;
}

/* ============================================
   CANVAS SCROLLER & WRAPPER
   ============================================ */
#canvasScroller {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px;
}

#canvasWrapper {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    flex-shrink: 0;
}

#gameCanvas {
    display: block;
    background: #fff;
    image-rendering: pixelated; /* prevent blurring if browser scales it */
}

/* ============================================
   REMOTE CURSORS
   ============================================ */
.remote-cursor {
    position: absolute;
    pointer-events: none;
    top: 0;
    left: 0;
    transform: translate(0px, 0px);
    transition: transform 0.06s linear;
    z-index: 50;
}

.remote-cursor svg {
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

.cursor-nametag {
    position: absolute;
    top: 4px;
    left: 18px;
    padding: 2px 8px;
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    pointer-events: none;
}

@keyframes cursorFadeOut {
    0%   { opacity: 1; }
    70%  { opacity: 0.5; }
    100% { opacity: 0; }
}

.remote-cursor.fading {
    animation: cursorFadeOut 4s ease-out forwards;
}
