/* Room Info */
.room-info {
    padding: 1.5rem;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.room-info h3 {
    color: var(--primary);
    font-size: 0.75rem;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    opacity: 0.8;
}

.room-code-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.room-actions {
    display: flex;
    gap: 5px;
}

#display-room-code {
    font-size: 1.4rem;
    color: var(--text-main);
    font-weight: bold;
    letter-spacing: 3px;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
    transition: filter 0.3s;
}

.code-hidden {
    filter: blur(6px);
    user-select: none;
}

#copy-code-btn, #toggle-code-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.4rem;
    font-size: 1rem;
    backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

#copy-code-btn:hover, #toggle-code-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: none;
    transform: none;
}

/* Lobby Controls */
#lobby-controls {
    padding: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: transparent;
}

.waiting-status {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    padding: 0 1rem;
    text-align: center;
    color: var(--primary);
    font-family: 'Orbitron', sans-serif !important;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 48px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: waitingPulse 2s infinite ease-in-out;
    white-space: nowrap;
}

.waiting-status span {
    font-family: 'Orbitron', sans-serif !important;
    background: transparent;
    border: none;
    box-shadow: none;
    animation: none;
    padding: 0;
    height: auto;
}

@keyframes waitingPulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 0 15px 0 rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.6); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.3); }
}

/* Players List */
.players-list {
    flex: 1;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    min-height: 150px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    background: transparent;
    border-bottom: none;
    border-radius: 4px;
    transition: background-color 0.2s;
    color: var(--text-main);
    position: relative;
}

.player-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.player-card:last-child {
    border-bottom: none;
}

.player-avatar, .player-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    object-fit: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    background: white;
}

.player-score {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: bold;
}

.is-drawing {
    background: rgba(236, 72, 153, 0.1);
    border-left: 3px solid var(--accent);
}

.leader-crown {
    color: #fbbf24;
    margin-right: 6px;
    font-size: 0.9rem;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
    animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-2px) rotate(5deg); }
}

.player-name {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
    overflow: hidden; /* Handle overflow at container level */
    text-overflow: ellipsis;
}

.name-text {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    /* Removed overflow hidden to prevent glow clipping */
    margin-right: 5px;
}

.drawing-icon {
    font-size: 0.8rem;
    animation: pencilWiggle 2s ease-in-out infinite;
}

@keyframes pencilWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.kick-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid transparent;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    opacity: 0;
    transition: all 0.2s;
}

.player-card:hover .kick-btn {
    opacity: 1;
}

.kick-btn:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

.switch-role-btn {
    opacity: 0;
    transition: all 0.2s;
}

.player-card:hover .switch-role-btn {
    opacity: 1;
}

/* Canvas */
.canvas-container {
    flex: 1;
    padding: 2rem;
    padding-bottom: calc(160px * var(--scale-factor));
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-sm);
    transform-origin: 0 0;
    transition: transform 0.05s linear;
}

canvas {
    background: white;
    border-radius: var(--radius-sm);
    cursor: crosshair;
    display: block;
}

#cursors-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.cursor {
    position: absolute;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transform: translate(-5px, -5px);
    z-index: 100;
    transition: top 0.05s linear, left 0.05s linear;
}

.cursor-pointer {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.cursor-name {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

/* Zoom Overlay */
.zoom-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 50;
}

.zoom-overlay.hidden {
    opacity: 0;
}

/* Game Top Bar */
.game-top-bar {
    position: absolute;
    top: calc(40px * var(--scale-factor));
    /* Center between sidebars: Left (560px) + Right (280px) = 840px occupied. 
       Center of free space = 560 + (100% - 840)/2 = 50% + 140px */
    left: calc(50% + (140px * var(--scale-factor)));
    transform: translateX(-50%);
    
    width: auto;
    min-width: 600px;
    height: auto;
    padding: 12px 30px;
    
    /* Toolbar Style Match */
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    z-index: 50;
    transition: all 0.3s ease;
}

.game-top-bar:hover {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.timer-display {
    position: absolute;
    left: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fbbf24; /* Amber/Gold */
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: 'Orbitron', sans-serif;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 100px;
    justify-content: center;
}

.word-display {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 3px;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
    white-space: pre;
    font-family: 'Orbitron', sans-serif;
    padding: 0 2rem;
    text-align: center;
}

.word-display::after {
    display: none; /* Remove the underline from previous style */
}

.round-info {
    position: absolute;
    right: 20px;
    color: var(--text-dim);
    font-size: 1rem;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: auto;
}

/* Custom Local Cursor */
.custom-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cursor-brush-preview {
    position: absolute;
    border: 1px solid rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
    box-sizing: border-box;
    /* Size will be set via JS */
}

.cursor-icon {
    position: absolute;
    bottom: -30px;
    right: -30px;
    width: 24px;
    height: 24px;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: background-color 0.2s;
}

.cursor-icon svg {
    width: 100%;
    height: 100%;
}

/* Avatar Tooltip */
.avatar-tooltip {
    position: fixed;
    z-index: 10000;
    width: 120px;
    height: 120px;
    border-radius: 20px;
    background: var(--bg-glass-strong);
    border: 2px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    pointer-events: none;
    backdrop-filter: blur(10px);
    transform: translate(10px, -50%);
}

.avatar-tooltip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 18px;
}

/* Sidebar Footer */
.sidebar-footer {
 padding: 1rem;
 border-top: 1px solid rgba(255, 255, 255, 0.05);
 background: rgba(0, 0, 0, 0.2);
 margin-top: auto; /* Ensure it stays at bottom if flex container allows */
}

.settings-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    padding: 0.8rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}.settings-btn:hover {
 background: rgba(255, 255, 255, 0.1);
 color: var(--text-main);
 border-color: var(--primary);
 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
 transform: translateY(-1px);
}


/* Players Header */
.players-header {
 padding: 1rem 1rem 0.5rem 1rem;
}

.players-header h3 {
 color: var(--text-dim);
 font-size: 0.8rem;
 text-transform: uppercase;
 letter-spacing: 1px;
 font-weight: 600;
 margin: 0;
}

/* Adjust Lobby Controls for Footer */
.sidebar-footer #lobby-controls {
    padding: 0;
    border-bottom: none;
    margin-bottom: 1rem;
    background: transparent;
}

#btn-open-settings {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 20px var(--primary-glow);
    animation: btnPulse 2s infinite;
    height: auto;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

#btn-open-settings:hover {
    background: var(--primary-hover);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 30px var(--primary-glow);
}



@keyframes btnPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* Forbidden Action Indicator */
.forbidden-icon {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    color: #ef4444;
    font-size: 24px;
    animation: fadeOutUp 0.8s forwards;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    border: 2px solid #ef4444;
}

@keyframes fadeOutUp {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
    50% { transform: translate(-50%, -80%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}
/* Player Guessed Indicator */
.has-guessed {
    background: rgba(34, 197, 94, 0.15) !important;
    border-left: 3px solid var(--success);
}

.has-guessed .player-name {
    color: var(--success);
    font-weight: bold;
}

.has-guessed .player-score {
    color: var(--success);
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

/* Hint Button */
.hint-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fbbf24; /* Amber-400 for lightbulb */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.2rem;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: visible;
    backdrop-filter: blur(5px);
}

.hint-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border-color: #fbbf24;
    color: #fff;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4), 
                0 4px 12px rgba(0, 0, 0, 0.2);
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}

.hint-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.95);
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
    box-shadow: none;
}

.hint-btn span {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    border: 2px solid var(--bg-dark);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: transform 0.2s;
    aspect-ratio: 1 / 1;
    line-height: 1;
}

.hint-btn:hover span {
    transform: scale(1.1);
}

.hint-btn.cooldown {
    animation: none;
    border-color: rgba(239, 68, 68, 0.5);
    color: #ef4444;
}

.hint-btn.cooldown::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #ef4444;
    border-right-color: #ef4444;
    animation: spin-cooldown 1s linear infinite;
}

@keyframes spin-cooldown {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Configuring Animation for Non-Leader Settings Button */
#btn-view-settings.is-configuring {
    animation: configuringPulse 2s infinite ease-in-out;
    border-color: var(--primary);
    color: white;
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

@keyframes configuringPulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 20px 0 rgba(99, 102, 241, 0.6); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); transform: scale(1); }
}



.player-card.spectating {
 border: 1px solid var(--primary);
 background: rgba(var(--primary-rgb), 0.1);
}


/* Color Sidebar Styles */
.color-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.color-sidebar-header h3 {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin: 0;
}

/* Override Color Popover for Sidebar */
.sidebar-col-2 .game-color-picker {
    position: static;
    width: 100%;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 1rem;
    display: flex !important; /* Force display */
    flex-direction: column;
    gap: 1.5rem;
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.sidebar-col-2 .color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.sidebar-col-2 .color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid #404040;
    transition: transform 0.2s, border-color 0.2s;
}

.sidebar-col-2 .color-swatch:hover {
    transform: scale(1.1);
    border-color: white;
    z-index: 2;
}

.sidebar-col-2 .color-swatch.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transform: scale(1.1);
    z-index: 2;
}

.sidebar-col-2 .custom-color-picker {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-col-2 .cp-saturation-area {
    width: 100%;
    height: 150px;
    background: linear-gradient(to bottom, transparent, #000), linear-gradient(to right, #fff, rgba(255,255,255,0));
    position: relative;
    border-radius: 6px;
    cursor: crosshair;
    border: 1px solid #404040;
}

.sidebar-col-2 .cp-hue-area {
    width: 100%;
    height: 20px;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
    position: relative;
    border-radius: 6px;
    cursor: crosshair;
    border: 1px solid #404040;
}

.sidebar-col-2 .cp-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sidebar-col-2 .cp-preview-color {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 1px solid #404040;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.sidebar-col-2 .cp-rgb-inputs {
    display: flex;
    gap: 5px;
    flex: 1;
}

.sidebar-col-2 .cp-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.sidebar-col-2 .cp-input-group label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.sidebar-col-2 .cp-input-group input {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 4px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
}

.sidebar-col-2 .cp-saturation-cursor {
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.sidebar-col-2 .cp-hue-cursor {
    width: 8px;
    height: 100%;
    border: 2px solid white;
    border-radius: 2px;
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
    background: transparent;
}


/* Adjustments for Double Sidebar Layout */

/* Column 1 Specifics */
.sidebar-col-1 .room-info {
 padding: 1rem;
}

.sidebar-col-1 .players-list {
 flex: 1;
 overflow-y: auto;
}

.sidebar-col-1 .sidebar-footer {
 margin-top: auto;
 padding: 1rem;
 background: rgba(0, 0, 0, 0.2);
}

/* Column 2 Specifics */
.sidebar-col-2 .color-panel {
 padding: 0;
 border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-col-2 .layers-panel {
 flex: 1;
 display: flex;
 flex-direction: column;
 overflow: hidden;
}

.sidebar-col-2 .layers-list {
 flex: 1;
 overflow-y: auto;
 padding: 0.5rem;
}



/* Self Player Highlight */
.player-card.is-me .name-text {
    color: #fbbf24;
    text-shadow: 0 0 5px rgba(251, 191, 36, 0.5);
}

.player-card.is-me {
 background: transparent;
 border: none;
}


/* Movable Toolbar Styles */
.drag-handle {
 display: flex;
 align-items: center;
 justify-content: center;
 padding: 0 10px;
 color: var(--text-dim);
 cursor: grab;
 border-right: 1px solid rgba(255, 255, 255, 0.1);
 margin-right: 10px;
 transition: color 0.2s;
}

.drag-handle:hover {
 color: var(--primary);
}

.drag-handle:active {
 cursor: grabbing;
}

.toolbar.dragging {
 cursor: grabbing;
 transition: none; /* Disable transition during drag for smoothness */
 box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
 border-color: var(--primary);
}

/* Ensure toolbar can be positioned freely */
.toolbar.custom-pos {
 transform: none; /* Remove centering transform */
 bottom: auto; /* Reset bottom if top is set */
}


/* Icon Button */
.icon-btn {
 background: transparent;
 border: none;
 color: var(--text-dim);
 cursor: pointer;
 padding: 4px 8px;
 border-radius: 4px;
 transition: all 0.2s;
}

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


/* Updated Drag Handle Style */
.drag-handle {
 border-right: none;
 margin-right: 0;
 padding: 0 15px;
 border-left: 1px solid rgba(255, 255, 255, 0.1);
 border-right: 1px solid rgba(255, 255, 255, 0.1);
}


/* Floating Window */
.floating-window {
 position: absolute;
 top: 100px;
 left: 100px;
 width: 400px;
 height: 500px;
 background: rgba(18, 18, 24, 0.95);
 border: 1px solid rgba(255, 255, 255, 0.1);
 border-radius: 8px;
 box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
 display: flex;
 flex-direction: column;
 z-index: 1000;
 backdrop-filter: blur(10px);
    overflow: hidden;
    resize: both;
}

.floating-window::-webkit-resizer {
    background-image: linear-gradient(135deg, transparent 60%, var(--primary) 60%);
    background-size: 15px 15px;
    background-repeat: no-repeat;
    background-position: bottom right;
}.floating-window.hidden {
 display: none;
}

.window-header {
 padding: 10px;
 background: rgba(255, 255, 255, 0.05);
 border-bottom: 1px solid rgba(255, 255, 255, 0.1);
 display: flex;
 justify-content: space-between;
 align-items: center;
 cursor: grab;
 user-select: none;
}

.window-header:active {
 cursor: grabbing;
}

.window-title {
 font-weight: bold;
 color: var(--text-main);
 display: flex;
 align-items: center;
 gap: 8px;
}

.window-controls {
 display: flex;
 gap: 5px;
}

.window-btn {
 background: transparent;
 border: none;
 color: var(--text-dim);
 cursor: pointer;
 padding: 4px;
 border-radius: 4px;
 transition: all 0.2s;
}

.window-btn:hover {
 color: white;
 background: rgba(255, 255, 255, 0.1);
}

.browser-toolbar {
 padding: 8px;
 display: flex;
 gap: 8px;
 border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#browser-url {
 flex: 1;
 background: rgba(0, 0, 0, 0.3);
 border: 1px solid rgba(255, 255, 255, 0.1);
 color: white;
 padding: 6px 10px;
 border-radius: 4px;
 font-size: 0.9rem;
}

#btn-browser-go {
 background: var(--primary);
 border: none;
 color: white;
 padding: 0 12px;
 border-radius: 4px;
 cursor: pointer;
}

.browser-content {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    display: flex;
    flex-direction: column;
}

#browser-frame {
 width: 100%;
 height: 100%;
 border: none;
 display: block;
}

.browser-status {
 padding: 4px 8px;
 font-size: 0.75rem;
 color: var(--text-dim);
 background: rgba(0, 0, 0, 0.2);
 text-align: center;
}


/* Mobile-like Floating Window */
.floating-window {
 width: 375px; /* iPhone width */
 height: 600px;
 border-radius: 20px; /* More rounded corners */
 border: 4px solid #333; /* Bezel look */
}

.browser-content {
 border-bottom-left-radius: 16px;
 border-bottom-right-radius: 16px;
 overflow: hidden;
}


.browser-nav-btn {
 background: transparent;
 border: none;
 color: var(--text-dim);
 cursor: pointer;
 padding: 0 8px;
 border-radius: 4px;
 transition: all 0.2s;
}

.browser-nav-btn:hover {
 color: white;
 background: rgba(255, 255, 255, 0.1);
}


/* Adjustments for Double Sidebar Layout */

/* Column 1 Specifics */
.sidebar-col-1 .room-info {
 padding: 1rem;
}

.sidebar-col-1 .players-list {
 flex: 1;
 overflow-y: auto;
}

.sidebar-col-1 .sidebar-footer {
 margin-top: auto;
 padding: 1rem;
 background: rgba(0, 0, 0, 0.2);
}

/* Column 2 Specifics */
.sidebar-col-2 .color-panel {
 padding: 0;
 border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-col-2 .layers-panel {
 flex: 1;
 display: flex;
 flex-direction: column;
 overflow: hidden;
}

.sidebar-col-2 .layers-list {
 flex: 1;
 overflow-y: auto;
 padding: 0.5rem;
}

/* Adjust Game Top Bar Position */
.game-top-bar {
    /* Center between sidebars: Left (560px) + Right (280px) = 840px occupied. 
       Center of free space = 560 + (100% - 840)/2 = 50% + 140px */
    left: calc(50% + (140px * var(--scale-factor)));
    transform: translateX(-50%);
}
/* Image Results Grid */
#image-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    height: 100%;
}

.image-result-item {
    height: 130px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
}

.image-result-item:hover {
    border-color: var(--primary);
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.image-result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Single Image View */
.single-image-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 10px;
    gap: 10px;
}

.single-image-container {
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 5px;
    display: block;
}

.single-image-container img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.back-to-grid-btn {
    align-self: flex-start;
    background: var(--primary);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.back-to-grid-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 2rem;
    font-style: italic;
    grid-column: 1 / -1;
}


#image-results-grid.single-view {
    display: block;
    padding: 0;
}


/* Adjustments for Double Sidebar Layout */

/* Column 1 Specifics */
.sidebar-col-1 .room-info {
 padding: 1rem;
}

.sidebar-col-1 .players-list {
 flex: 1;
 overflow-y: auto;
}

.sidebar-col-1 .sidebar-footer {
 margin-top: auto;
 padding: 1rem;
 background: rgba(0, 0, 0, 0.2);
}

/* Column 2 Specifics */
.sidebar-col-2 .color-panel {
 padding: 0;
 border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-col-2 .layers-panel {
 flex: 1;
 display: flex;
 flex-direction: column;
 overflow: hidden;
}

.sidebar-col-2 .layers-list {
 flex: 1;
 overflow-y: auto;
 padding: 0.5rem;
}

/* Adjust Game Top Bar Position */
.game-top-bar {
    /* Center between sidebars: Left (560px) + Right (280px) = 840px occupied. 
       Center of free space = 560 + (100% - 840)/2 = 50% + 140px */
    left: calc(50% + (140px * var(--scale-factor)));
    transform: translateX(-50%);
}


/* Pin Mode & Tracing */
.pin-controls {
    padding: 8px;
    background: rgba(0, 0, 0, 0.6);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.pin-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pin-controls input[type='range'] {
    flex: 1;
    height: 4px;
    accent-color: var(--primary);
}

.floating-window.pinned {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none;
    z-index: 1; /* Behind canvas wrapper */
    resize: none;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.floating-window.pinned .window-header,
.floating-window.pinned .browser-toolbar,
.floating-window.pinned .browser-status {
    display: none !important;
}

.floating-window.pinned .pin-controls {
    display: block !important;
    pointer-events: auto;
}

.floating-window.pinned .browser-content {
    background: transparent !important;
    opacity: var(--pin-opacity, 0.5);
    overflow: hidden;
}

.floating-window.pinned .image-result-item {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

/* Tracing Mode Global Styles */
body.tracing-mode .canvas-container {
    z-index: 5;
    position: relative;
}

body.tracing-mode canvas {
    background: transparent !important;
}

body.tracing-mode .canvas-wrapper {
    box-shadow: none !important;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}


/* Global Pin Controls */
.pin-controls-global {
    position: absolute;
    top: -60px; /* Above toolbar */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--primary);
    border-radius: 30px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 100;
    white-space: nowrap;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.pin-label {
    color: var(--primary);
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pin-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
}

.pin-slider-group input[type='range'] {
    width: 100px;
    height: 4px;
    accent-color: var(--primary);
}

.pin-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pin-action-btn:hover {
    background: var(--danger);
    transform: translateY(-1px);
}

/* Hide Back Button in Pinned Mode */
.floating-window.pinned .back-to-grid-btn {
    display: none !important;
}

/* Dummy Layer Style */
.layer-item.dummy {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.02);
    border-style: dashed;
    cursor: not-allowed !important;
}

.layer-item.dummy:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.02);
}

.layer-item.dummy .layer-name-display {
    font-style: italic;
    color: var(--text-dim);
}

/* White Background Fix for Tracing Mode */
/* We need a white background behind the pinned window (z-index 1) */
/* Canvas Container is z-index 5 */
/* Let's add a pseudo-element to main-area or canvas-container */

body.tracing-mode .canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white; /* Or paper color */
    z-index: 0; /* Behind window (z-index 1) */
    pointer-events: none;
}

/* Ensure window is above this background */
.floating-window.pinned {
    z-index: 1 !important;
}


/* Fix for Tracing Mode Background */
/* Remove the previous fix that caused white screen */
body.tracing-mode .canvas-container::before {
    display: none;
}

/* Ensure Canvas Wrapper has white background (it usually does, but let's be explicit) */
.canvas-wrapper {
    background: white;
}

/* In Tracing Mode, the pinned window is inside canvas-wrapper */
/* We want: Wrapper (White) -> Window (Image) -> Canvas (Drawing) */

/* Canvas is z-index 10 (default or set here) */
canvas {
    position: relative;
    z-index: 10;
}

/* Pinned Window inside wrapper should be lower */
.canvas-wrapper .floating-window.pinned {
    z-index: 1 !important;
    position: absolute !important; /* It is absolute relative to wrapper */
}

/* Ensure cursors are on top */
#cursors-layer {
    z-index: 20;
}


/* Tracing Image */
.tracing-image {
 position: absolute;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 object-fit: contain;
 z-index: 1;
 pointer-events: none;
}


/* Tracing Controls */
.tracing-controls {
    position: absolute;
    z-index: 15; /* Above canvas (10) */
    pointer-events: auto; /* Allow clicks for dragging */
    border: 1px dashed rgba(99, 102, 241, 0.5);
    box-sizing: border-box;
}

.resize-handle {
 position: absolute;
 width: 12px;
 height: 12px;
 background: white;
 border: 1px solid var(--primary);
 border-radius: 50%;
 pointer-events: auto; /* Catch clicks */
 z-index: 16;
 transition: transform 0.1s;
}

.resize-handle:hover {
 transform: scale(1.2);
 background: var(--primary);
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

/* Move handle (center) - Optional, maybe for later */
/*
.move-handle {
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
 width: 20px;
 height: 20px;
 background: rgba(255, 255, 255, 0.5);
 border-radius: 50%;
 cursor: move;
 pointer-events: auto;
}
*/


/* Move Handle */
.move-handle {
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
 width: 32px;
 height: 32px;
 background: rgba(255, 255, 255, 0.2);
 border: 1px solid var(--primary);
 border-radius: 50%;
 cursor: move;
 pointer-events: auto;
 display: flex;
 align-items: center;
 justify-content: center;
 color: white;
 backdrop-filter: blur(4px);
 transition: all 0.2s;
 z-index: 20;
}

.move-handle:hover {
 background: var(--primary);
 transform: translate(-50%, -50%) scale(1.1);
 box-shadow: 0 0 10px var(--primary-glow);
}

/* Layer Opacity Slider */
.layer-opacity-slider {
 width: 100%;
 height: 4px;
 -webkit-appearance: none;
 background: rgba(255, 255, 255, 0.1);
 border-radius: 2px;
 outline: none;
 margin-top: 4px;
}

.layer-opacity-slider::-webkit-slider-thumb {
 -webkit-appearance: none;
 width: 10px;
 height: 10px;
 border-radius: 50%;
 background: var(--primary);
 cursor: pointer;
 transition: transform 0.1s;
}

.layer-opacity-slider::-webkit-slider-thumb:hover {
 transform: scale(1.2);
}

/* Finalize Tracing Button */
.tracing-finalize-btn {
    position: fixed;
    bottom: 100px; /* Above toolbar */
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    animation: slideUp 0.3s ease-out;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Orbitron', sans-serif;
}

.tracing-finalize-btn:hover {
    background: #22c55e; /* Success hover */
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

@keyframes slideUp {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Canvas Transparency for Tracing */
canvas {
    background: transparent !important;
}

.canvas-wrapper {
    background: white;
}

/* Tracing Actions Cartridge */
.tracing-actions-cartridge {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 15px;
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 100;
    animation: slideUpFade 0.3s ease-out;
    white-space: nowrap;
}

.tracing-actions-cartridge button {
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: all 0.2s;
}

.tracing-btn-validate {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
}

.tracing-btn-validate:hover {
    background: rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}

.tracing-btn-cancel {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.tracing-btn-cancel:hover {
    background: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

@keyframes slideUpFade {
    from { transform: translate(-50%, 10px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}


/* Ensure canvas wrapper clips content only when validated */
.canvas-wrapper.clipped {
    overflow: hidden;
}

/* Use as Layer Button Style */
.use-as-layer-btn {
 align-self: flex-start;
 background: var(--success);
 border: none;
 color: white;
 padding: 8px 16px;
 border-radius: 4px;
 cursor: pointer;
 display: flex;
 align-items: center;
 gap: 8px;
 font-size: 0.9rem;
 font-weight: 600;
 box-shadow: 0 2px 5px rgba(0,0,0,0.2);
 transition: all 0.2s;
}

.use-as-layer-btn:hover {
 background: #22c55e; /* Success hover */
 transform: translateY(-1px);
 box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}


/* Disabled Slider Style */
.disabled-slider {
 opacity: 0.3;
 pointer-events: none;
 filter: grayscale(100%);
}

.disabled-slider input[type=range]::-webkit-slider-thumb {
 opacity: 0;
 visibility: hidden;
}

.disabled-slider input[type=range]::-moz-range-thumb {
 opacity: 0;
 visibility: hidden;
}


/* Player Actions Drawer */
.player-card {
 position: relative;
 overflow: hidden;
}

.player-actions-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    
    /* Glass Effect */
    background: rgba(20, 20, 30, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Shadow removed from here to prevent leak when closed */
    box-shadow: none;

    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.player-card:hover .player-actions-drawer {
 transform: translateX(0);
 box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
}

/* Reset button styles inside drawer */
.player-actions-drawer button {
 margin: 0 !important;
 opacity: 1 !important;
 transform: none !important;
 position: relative !important;
}

/* Ensure kick button is visible and styled correctly in drawer */
.kick-btn {
 opacity: 1;
 margin-left: 0;
 background: rgba(239, 68, 68, 0.2);
 width: 28px;
 height: 28px;
}

.kick-btn:hover {
 background: var(--danger);
}


/* Fix for disabled buttons in drawer */
.player-actions-drawer button[disabled] {
 opacity: 0.5 !important;
 cursor: not-allowed;
}


.word-display {
 min-height: 1.2em; /* Prevent collapse when empty */
 display: flex;
 align-items: center;
 justify-content: center;
}


.word-display {
 min-height: 1.2em; /* Prevent collapse when empty */
 display: flex;
 align-items: center;
 justify-content: center;
}


/* Choosing Word State */
.word-display.choosing-word {
 font-size: 1.2rem;
 color: white;
 text-shadow: none;
 font-weight: 600;
 letter-spacing: 1px;
}


.word-display {
 min-height: 1.2em; /* Prevent collapse when empty */
 display: flex;
 align-items: center;
 justify-content: center;
}


/* Fixed Height & Adaptive Width for Top Bar */
.game-top-bar {
 height: 80px;
 display: flex;
 justify-content: space-between;
 align-items: center;
 padding: 0 20px;
 gap: 20px;
 width: auto;
 min-width: 600px;
 max-width: 90vw; /* Prevent going off screen */
}

.timer-display {
 position: static;
 flex-shrink: 0;
 margin: 0;
 left: auto;
}

.round-info {
 position: static;
 flex-shrink: 0;
 margin: 0;
 right: auto;
}

.word-display {
 flex: 1;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
 padding: 0 10px;
 width: auto;
}


/* Scalable Top Bar */
.game-top-bar {
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(10px * var(--scale-factor));
    gap: calc(20px * var(--scale-factor));
    width: auto;
    min-width: calc(600px * var(--scale-factor));
    max-width: 90vw;
    
    /* Ensure font sizes scale too */
    font-size: calc(1rem * var(--scale-factor));
}.timer-display {
 font-size: calc(1.5rem * var(--scale-factor));
 padding: calc(6px * var(--scale-factor)) calc(16px * var(--scale-factor));
 border-radius: calc(12px * var(--scale-factor));
 width: calc(140px * var(--scale-factor));
 justify-content: center;
 gap: calc(0.8rem * var(--scale-factor));
}

.round-info {
 font-size: calc(1rem * var(--scale-factor));
 padding: calc(6px * var(--scale-factor)) calc(16px * var(--scale-factor));
 border-radius: calc(12px * var(--scale-factor));
 width: calc(140px * var(--scale-factor));
 justify-content: center;
}

.word-display {
 font-size: calc(2rem * var(--scale-factor));
 padding: 0 calc(10px * var(--scale-factor));
}

.word-display.choosing-word {
 font-size: calc(1.2rem * var(--scale-factor));
}

/* Drawer Name Display in Top Bar */
.drawer-name-display {
    position: absolute;
    top: calc(-25px * var(--scale-factor));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-dim);
    padding: calc(4px * var(--scale-factor)) calc(12px * var(--scale-factor));
    border-radius: calc(12px * var(--scale-factor)) calc(12px * var(--scale-factor)) 0 0;
    font-size: calc(0.8rem * var(--scale-factor));
    font-weight: 600;
    letter-spacing: 1px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    backdrop-filter: blur(4px);
    z-index: -1; /* Behind the bar */
}.drawer-name-display strong {
 color: var(--primary);
 margin-left: 5px;
}


/* Ensure drawing status overrides self highlight */
.player-card.is-me.is-drawing {
    background: rgba(236, 72, 153, 0.1);
    border-left: 3px solid var(--accent);
    border-top: 1px solid transparent;
    border-right: 1px solid transparent;
    border-bottom: 1px solid transparent;
}

/* Interaction Handle */
.interaction-handle {
    color: var(--text-dim);
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.2;
    margin-left: 8px;
    user-select: none;
    font-weight: bold;
    cursor: help;
}

.player-card:hover .interaction-handle {
    opacity: 0; /* Hide when drawer slides in */
}


/* Universal Hover Effect for Player Cards */
.player-card:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* Preserve and enhance Drawing Highlight on Hover */
.player-card.is-drawing:hover,
.player-card.is-me.is-drawing:hover {
    background: rgba(236, 72, 153, 0.2) !important;
}


/* Hide DOM Tracing Image (rendered on canvas instead) - REMOVED */
/* #tracing-image {
    opacity: 0 !important;
} */


/* Telephone Mode Styles */
.telephone-overlay {
 position: absolute;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 background: rgba(18, 18, 24, 0.95);
 z-index: 100;
 display: flex;
 align-items: center;
 justify-content: center;
 backdrop-filter: blur(10px);
}

.telephone-content {
 background: var(--bg-glass-strong);
 border: 1px solid var(--border-color);
 border-radius: var(--radius-lg);
 padding: 2rem;
 width: 90%;
 max-width: 600px;
 text-align: center;
 box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.telephone-prev-drawing-container {
 background: white;
 border-radius: 8px;
 overflow: hidden;
 margin: 1rem auto;
 max-width: 100%;
 box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#telephone-prev-drawing {
 width: 100%;
 height: auto;
 display: block;
}

.telephone-input-area {
 display: flex;
 flex-direction: column;
 gap: 1rem;
 margin-top: 1.5rem;
}

#telephone-input {
 width: 100%;
 padding: 1rem;
 background: rgba(0, 0, 0, 0.3);
 border: 1px solid var(--border-color);
 border-radius: var(--radius-md);
 color: white;
 font-size: 1.1rem;
 resize: none;
 height: 100px;
}

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

/* Recap Styles */
.telephone-chain {
 background: rgba(255, 255, 255, 0.03);
 border: 1px solid rgba(255, 255, 255, 0.05);
 border-radius: var(--radius-md);
 padding: 1.5rem;
}

.telephone-chain h3 {
 color: var(--primary);
 margin-bottom: 1rem;
 font-size: 1.1rem;
 border-bottom: 1px solid rgba(255, 255, 255, 0.1);
 padding-bottom: 0.5rem;
}

.chain-steps {
 display: flex;
 flex-wrap: wrap;
 gap: 1rem;
 align-items: center;
}

.chain-step {
 background: rgba(0, 0, 0, 0.2);
 border-radius: 8px;
 padding: 0.8rem;
 min-width: 150px;
 max-width: 200px;
 position: relative;
}

.step-author {
 display: block;
 font-size: 0.8rem;
 color: var(--text-dim);
 margin-bottom: 0.5rem;
 font-weight: bold;
}

.step-text {
 font-size: 1rem;
 color: white;
 font-style: italic;
}

.step-image {
 width: 100%;
 border-radius: 4px;
 border: 1px solid rgba(255, 255, 255, 0.1);
 background: white;
}

.step-arrow {
 color: var(--text-dim);
 font-size: 1.2rem;
}


/* Fix for Model Visibility */
.canvas-wrapper.has-model canvas {
    background: transparent !important;
}

.canvas-wrapper.has-model {
    background: white; /* Ensure background for the image */
}


/* Fix for Canvas Wrapper Shrinking */
.canvas-wrapper {
    flex-shrink: 0;
    min-width: min-content;
    min-height: min-content;
}

/* Always show player actions for spectators */
.player-card.is-spectator-view .player-actions-drawer {
    transform: translateX(0);
}
