:root {
    --ui-scale: 1.06;
    --base-font-size: clamp(16px, 0.35vw + 0.9rem, 20px);
}

#desktop {
    flex: 1;
    width: 100%;
    padding: 4.3rem 1rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-control-strip {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 0.25rem 0.45rem;
}

.taskbar-shell {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.15rem;
}

.taskbar-program-list {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.taskbar-program-btn {
    min-height: 1.8rem;
    max-width: min(14rem, 42vw);
    padding: 0.18rem 0.5rem 0.18rem 0.34rem;
    border: var(--control-border-width) solid var(--border-outer);
    background: var(--surface-control);
    color: var(--text-primary);
    box-shadow: var(--button-shadow);
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    cursor: pointer;
    overflow: hidden;
}

.taskbar-program-btn.is-active {
    box-shadow: var(--button-shadow-active);
    transform: translateY(1px);
}

.taskbar-program-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taskbar-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    image-rendering: pixelated;
}

.desktop-taskbar {
    display: none;
}

.ui-tool-window {
    position: fixed;
    z-index: 80;
    top: 6.2rem;
    left: 1rem;
    width: min(24rem, calc(100vw - 2rem));
    height: 14rem;
    min-width: 16.25rem;
    min-height: 10rem;
    resize: both;
    overflow: auto;
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
}

.ui-tool-title-bar {
    cursor: grab;
}

.ui-tool-window .title-bar-controls button {
    cursor: pointer;
}

.tool-copy {
    margin-bottom: 0.45rem;
}

.theme-option-list {
    display: grid;
    gap: 0.35rem;
}

.theme-option-btn,
.mode-toggle-btn {
    justify-content: flex-start;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
}

.theme-option-btn.is-selected {
    outline: var(--selected-outline);
    outline-offset: -0.28rem;
}

body.is-dragging-window {
    user-select: none;
}

body.is-dragging-window .ui-tool-title-bar {
    cursor: grabbing;
}

.config-window {
    width: min(78rem, 100%);
}

.intro-copy {
    margin-bottom: 0.7rem;
}

.room-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.config-layout {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1fr) 24rem;
}

.config-panel {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.number-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.number-with-unit .input-unit {
    min-width: 2rem;
    text-align: right;
}

.preview-content {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.preview-meta {
    display: flex;
    justify-content: space-between;
}

.preview-board {
    min-height: 13rem;
    padding: 0.6rem;
}

.preview-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preview-card {
    width: 3.15rem;
    height: 4.45rem;
    border-radius: 0.32rem;
    user-select: none;
    cursor: grab;
    transition: transform 170ms ease;
}

.preview-card .card-center-icon {
    font-size: 1.18rem;
}

.preview-card.dragging {
    opacity: 0.65;
}

.preview-card.wiggle {
    animation: wiggle 250ms linear infinite;
}

@keyframes wiggle {
    0% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
    100% { transform: rotate(-2deg); }
}

.preview-card-remove {
    position: absolute;
    top: -0.35rem;
    right: -0.35rem;
    width: 1rem;
    height: 1rem;
    opacity: 0;
    transition: opacity 120ms ease, transform 120ms ease;
    transform: scale(0.86);
    pointer-events: none;
}

.preview-card:hover .preview-card-remove,
.preview-card-remove:focus {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.preview-card.is-removing {
    animation: card-pop-out 190ms ease forwards;
}

@keyframes card-pop-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.58) rotate(-10deg); }
}

.card-editor {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-editor-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.35rem;
}

.deck-tools-row {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.icon-btn {
    width: 2.45rem;
    min-width: 2.45rem;
    height: 2.15rem;
    padding: 0.1rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.icon-btn img {
    width: 1.05rem;
    height: 1.05rem;
    image-rendering: pixelated;
}

.preset-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-modal-window {
    width: min(40rem, 92vw);
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 11rem;
    overflow-y: auto;
    margin-bottom: 0.5rem;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem;
}

.preset-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.preset-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

.import-pane {
    margin-top: 0.5rem;
}

.import-pane textarea {
    resize: vertical;
}

.actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

.room-desktop {
    align-items: stretch;
}

.room-grid {
    width: min(78rem, 100%);
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 2fr 1fr;
}

.room-main-window {
    min-height: 40rem;
}

.side-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.participants-window {
    min-height: 24rem;
}

.admin-window {
    min-height: 15rem;
}

.room-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.55rem;
}

.voting-board {
    min-height: 14rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem;
    align-content: flex-start;
}

.vote-card {
    width: 4.3rem;
    height: 6rem;
    border-radius: 0.4rem;
    cursor: pointer;
    overflow: visible;
    transition: transform 120ms ease;
}

.vote-card .card-center-icon {
    font-size: 1.65rem;
}

.vote-card:hover {
    transform: translateY(-0.2rem);
}

.vote-summary-window {
    margin-top: 0.7rem;
}

.vote-summary-content {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.summary-metrics {
    display: flex;
    justify-content: space-between;
}

.side-panel-content {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    height: 100%;
}

.participants-scroll {
    flex: 1;
    min-height: 13rem;
    overflow-y: auto;
}

.participants-footer {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem;
    align-items: center;
}

.participant-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem;
}

.side-controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.links-block {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.share-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem;
    align-items: center;
}

.share-admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

#share-link {
    min-width: 0;
}

#votes-counter,
#room-message {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.admin-controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.join-window {
    position: fixed;
    z-index: 60;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(27rem, 92vw);
}

.terminal-window {
    width: min(46rem, 94vw);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-window-content {
    padding: 0.55rem;
    display: flex;
    flex: 1;
    min-height: 0;
}

.terminal-log-output {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem;
    white-space: pre-wrap;
}

.skeleton-line,
.skeleton-board,
.skeleton-table,
.skeleton-list,
.skeleton-controls {
    height: 1.2rem;
}

.skeleton-board {
    height: 15rem;
}

.skeleton-table {
    height: 8rem;
}

.skeleton-list {
    height: 20rem;
    margin-bottom: 0.45rem;
}

.skeleton-controls {
    height: 9rem;
}

@media (min-width: 900px) {
    .mobile-control-strip {
        display: none;
    }

    .desktop-taskbar {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-height: 2.5rem;
        padding: 0.3rem 0.55rem;
    }

    .desktop-taskbar .taskbar-program-btn {
        min-width: 11.2rem;
        max-width: 15rem;
    }

    .ui-tool-window {
        top: 4.25rem;
        left: 1rem;
    }

    #desktop {
        padding: 1rem 1rem 3.4rem;
    }
}

@media (max-width: 960px) {
    .config-layout,
    .room-grid {
        grid-template-columns: 1fr;
    }

    .room-main-window,
    .participants-window,
    .admin-window {
        min-height: unset;
    }
}

@media (max-width: 720px) {
    #desktop {
        align-items: flex-start;
        padding-top: 3.65rem;
    }

    .taskbar-program-btn span {
        display: none;
    }

    .taskbar-program-btn {
        max-width: none;
        width: 2rem;
        justify-content: center;
        padding: 0.2rem;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .summary-metrics {
        flex-direction: column;
        gap: 0.25rem;
    }
}

@media (max-width: 899px) {
    .ui-tool-window {
        top: 2.85rem !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: calc(100dvh - 2.85rem) !important;
        min-width: 0;
        min-height: 0;
        max-width: 100vw;
        max-height: calc(100dvh - 2.85rem);
        resize: none;
        overflow: auto;
        transform: none !important;
    }

    .ui-tool-title-bar {
        cursor: default;
    }
}

@media (min-width: 2560px), (min-resolution: 2dppx) {
    :root {
        --ui-scale: 1.24;
    }
}
