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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    height: 100vh;
    background: #f5f5f5;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Room Control Card */
.room-control-card {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
    overflow: hidden;
    width: 280px;
}

.room-control-card.expanded {
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

.toolbox-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.room-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.room-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.room-name-large {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-member-count-small {
    font-size: 13px;
    font-weight: 400;
    color: #999;
}

.room-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-divider {
    color: #999;
    font-size: 13px;
    line-height: 1;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 400;
}

.connection-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.connection-status-indicator.connected {
    background: #28a745;
}

.connection-status-indicator.disconnected {
    background: #dc3545;
}

.connection-status-indicator.reconnecting {
    background: #ffc107;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.connection-status-text {
    color: #666;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.expanded-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 0;
    border-top: 1px solid transparent;
    border-top-width: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding-top 0.3s ease, margin-top 0.3s ease;
    pointer-events: none;
    margin-top: 0;
}

.room-control-card.expanded .expanded-actions {
    max-height: 500px;
    opacity: 1;
    pointer-events: auto;
    padding-top: 8px;
    margin-top: 8px;
}

.btn-add {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: #007bff;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.btn-add:hover {
    background: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    transform: translateY(-1px);
}

.btn-add:active {
    transform: translateY(0);
}

.btn-zoom {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    background: #f0f0f0;
    color: #333;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-zoom:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.btn-zoom:active {
    transform: scale(0.95);
}

.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px;
    background: #f8f8f8;
    border-radius: 8px;
    width: 100%;
}

#zoom-level,
#zoom-level-expanded {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.btn-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #f0f0f0;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-toggle:hover {
    background: #e0e0e0;
    color: #333;
    transform: scale(1.1);
}

.icon-expand {
    display: block;
}

.icon-collapse {
    display: none;
}

.room-control-card.expanded .icon-expand {
    display: none;
}

.room-control-card.expanded .icon-collapse {
    display: block;
}


.btn-action {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: #f8f8f8;
    color: #333;
    transition: all 0.2s ease;
    text-align: left;
}

.btn-action:hover {
    background: #e8e8e8;
    transform: translateX(2px);
}

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

.canvas-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    background-attachment: fixed;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.1);
    cursor: grab;
    touch-action: none;
    width: 100%;
    height: 100vh;
}

.canvas-container.panning {
    cursor: grabbing;
}

.canvas-container.dragging-letter {
    cursor: default;
}

.canvas-container.zooming-wheel .canvas {
    transition: none;
}

.canvas {
    position: absolute;
    width: 5000px;
    height: 5000px;
    transform-origin: 0 0;
    will-change: transform;
    transition: transform 0.2s ease-out;
}

.canvas-container.panning .canvas,
.canvas-container.dragging-letter .canvas {
    transition: none;
}

.letter {
    position: absolute;
    cursor: move;
    user-select: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
    touch-action: none;
}

.letter.dragging {
    z-index: 1000;
    opacity: 0.8;
    cursor: grabbing;
    transition: none; /* Disable transition when user is dragging */
}

.letter.moving-remote {
    transition: left 0.3s ease-out, top 0.3s ease-out;
    z-index: 500; /* Higher z-index than normal but lower than dragging */
}

.letter.letter-drop {
    animation: letterDropAnimation 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes letterDropAnimation {
    0% {
        transform: translateY(-180px) scale(3) rotate(var(--letter-rotation, 0deg));
        filter: blur(8px);
        opacity: 0.4;
    }
    85% {
        transform: translateY(10px) scale(1) rotate(0deg);
        filter: blur(0);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        filter: blur(0);
        opacity: 1;
    }
}

/* Custom Modals (New Room, Share) */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.custom-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.custom-modal .modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 24px;
    max-width: 480px;
    width: 90%;
    z-index: 2001;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
}

.modal-body {
    margin-bottom: 24px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.modal-body input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.modal-body input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.modal-body input[readonly] {
    background: #f8f8f8;
    cursor: text;
}

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

.btn-modal-ok {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: #007bff;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.btn-modal-ok:hover {
    background: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    transform: translateY(-1px);
}

.btn-modal-ok:active {
    transform: translateY(0);
}

.btn-modal-cancel {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: #f0f0f0;
    color: #333;
    transition: all 0.2s ease;
}

.btn-modal-cancel:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.btn-modal-cancel:active {
    transform: translateY(0);
}

/* Letter Selection Modal */
.letter-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.letter-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.letter-modal .modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    z-index: 2001;
    max-height: 80vh;
    overflow-y: auto;
}

.letter-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.letter-modal .modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
}

.modal-letters {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.modal-letter {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #007bff;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-letter:hover {
    background: #007bff;
    color: white;
    transform: scale(1.05);
}

/* Hide UI for projection displays */
body.ui-hidden .room-control-card,
body.ui-hidden .custom-modal,
body.ui-hidden .letter-modal {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .room-control-card {
        top: 10px;
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
        transition: box-shadow 0.3s ease;
    }

    .card-collapsed,
    .card-expanded {
        min-width: auto;
    }

    .room-name-large {
        font-size: 18px;
    }

    /* Collapsed state on mobile - show title, connection status, users online, and toggle button */
    .room-control-card:not(.expanded) .room-info .room-status-row {
        display: flex;
    }

    .room-control-card:not(.expanded) .controls {
        display: none;
    }

    /* Ensure consistent padding, gap, and prevent layout shifts */
    .toolbox-content {
        padding: 16px;
        gap: 12px;
    }

    .modal-content {
        padding: 20px;
        max-width: 95%;
    }

    .modal-letters {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .modal-letter {
        font-size: 16px;
    }
}

/* Letter classes from theme.css need to be applied */
.letter-magnet {
    position: absolute;
}

.letter-magnet.letter-a { width: 96px; height: 103px; background-image: url(/images/letters/kushion/letters/a.png); }
.letter-magnet.letter-b { width: 87px; height: 105px; background-image: url(/images/letters/kushion/letters/b.png); }
.letter-magnet.letter-c { width: 100px; height: 108px; background-image: url(/images/letters/kushion/letters/c.png); }
.letter-magnet.letter-d { width: 100px; height: 107px; background-image: url(/images/letters/kushion/letters/d.png); }
.letter-magnet.letter-e { width: 78px; height: 104px; background-image: url(/images/letters/kushion/letters/e.png); }
.letter-magnet.letter-f { width: 74px; height: 101px; background-image: url(/images/letters/kushion/letters/f.png); }
.letter-magnet.letter-g { width: 90px; height: 103px; background-image: url(/images/letters/kushion/letters/g.png); }
.letter-magnet.letter-h { width: 97px; height: 103px; background-image: url(/images/letters/kushion/letters/h.png); }
.letter-magnet.letter-i { width: 53px; height: 106px; background-image: url(/images/letters/kushion/letters/i.png); }
.letter-magnet.letter-j { width: 84px; height: 106px; background-image: url(/images/letters/kushion/letters/j.png); }
.letter-magnet.letter-k { width: 96px; height: 109px; background-image: url(/images/letters/kushion/letters/k.png); }
.letter-magnet.letter-l { width: 78px; height: 106px; background-image: url(/images/letters/kushion/letters/l.png); }
.letter-magnet.letter-m { width: 115px; height: 104px; background-image: url(/images/letters/kushion/letters/m.png); }
.letter-magnet.letter-n { width: 91px; height: 103px; background-image: url(/images/letters/kushion/letters/n.png); }
.letter-magnet.letter-o { width: 98px; height: 103px; background-image: url(/images/letters/kushion/letters/o.png); }
.letter-magnet.letter-p { width: 88px; height: 106px; background-image: url(/images/letters/kushion/letters/p.png); }
.letter-magnet.letter-q { width: 113px; height: 103px; background-image: url(/images/letters/kushion/letters/q.png); }
.letter-magnet.letter-r { width: 89px; height: 107px; background-image: url(/images/letters/kushion/letters/r.png); }
.letter-magnet.letter-s { width: 80px; height: 107px; background-image: url(/images/letters/kushion/letters/s.png); }
.letter-magnet.letter-t { width: 91px; height: 102px; background-image: url(/images/letters/kushion/letters/t.png); }
.letter-magnet.letter-u { width: 84px; height: 103px; background-image: url(/images/letters/kushion/letters/u.png); }
.letter-magnet.letter-v { width: 97px; height: 104px; background-image: url(/images/letters/kushion/letters/v.png); }
.letter-magnet.letter-w { width: 124px; height: 103px; background-image: url(/images/letters/kushion/letters/w.png); }
.letter-magnet.letter-x { width: 103px; height: 106px; background-image: url(/images/letters/kushion/letters/x.png); }
.letter-magnet.letter-y { width: 89px; height: 106px; background-image: url(/images/letters/kushion/letters/y.png); }
.letter-magnet.letter-z { width: 96px; height: 102px; background-image: url(/images/letters/kushion/letters/z.png); }

