body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(0, 153, 255, 0.2), transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(0, 212, 170, 0.16), transparent 28%),
        linear-gradient(160deg, #121212 0%, #1d1d1d 48%, #111111 100%);
    color: #f4efe7;
    font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
    touch-action: none;
}

body {
    display: flex;
    flex-direction: column;
    position: relative;
}

body::before,
body::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

body::before {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 72px),
        linear-gradient(rgba(255, 255, 255, 0.018) 0, rgba(255, 255, 255, 0.018) 1px, transparent 1px, transparent 72px);
    opacity: 0.35;
}

body::after {
    background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.32) 100%);
}

.controlApp {
    min-height: 100%;
}

.appShell {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
    gap: 16px;
}

#header {
    background:
        linear-gradient(135deg, rgba(30, 30, 30, 0.94), rgba(18, 18, 18, 0.9)),
        linear-gradient(90deg, rgba(0, 153, 255, 0.12), rgba(0, 212, 170, 0.12));
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px;
    box-sizing: border-box;
    gap: 18px;
    flex-wrap: wrap;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
}

.headerCopy {
    max-width: 520px;
}

.eyebrow {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #47b3ff;
    margin-bottom: 8px;
}

.headerCopy h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 0.95;
    letter-spacing: 0.02em;
}

.headerCopy p {
    margin: 10px 0 0;
    max-width: 38ch;
    color: rgba(244, 239, 231, 0.76);
    font-size: 15px;
    line-height: 1.45;
}

.headerActions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
    align-content: center;
}

#commsInfoDiv {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    font-size: 11px;
    margin-left: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.84);
    min-height: 40px;
}

#commsInfo {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    letter-spacing: 0.04em;
}

.statusDot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #47b3ff;
    box-shadow: 0 0 16px rgba(71, 179, 255, 0.8);
}

#drawContainer {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.stageFrame {
    position: relative;
    width: min(100%, 920px);
    height: min(100%, 920px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 32px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        rgba(14, 14, 14, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 35px 70px rgba(0, 0, 0, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
}

#drawSurface {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.06), transparent 30%),
        radial-gradient(circle at 80% 80%, rgba(71, 179, 255, 0.08), transparent 28%),
        linear-gradient(160deg, #1a1a1a, #111111 46%, #0a0a0a 100%);
    position: relative;
    user-select: none;
    touch-action: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    border-radius: 0;
    overflow: hidden;
    margin: 18px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -24px 45px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(0, 0, 0, 0.5);
}

#drawSurface::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.02), transparent 24%, transparent 75%, rgba(255, 255, 255, 0.025)),
        radial-gradient(circle at center, transparent 0, transparent 42%, rgba(0, 0, 0, 0.18) 100%);
    pointer-events: none;
}

.surfaceLabel {
    position: absolute;
    left: 22px;
    top: 18px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 15, 15, 0.44);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 245, 232, 0.8);
    z-index: 1;
    pointer-events: none;
}

.windowIndicator {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid rgba(71, 179, 255, 0.9);
    border-radius: 4px;
    background:
        repeating-linear-gradient(
            45deg,
            rgba(71, 179, 255, 0.15),
            rgba(71, 179, 255, 0.15) 3px,
            rgba(255, 255, 255, 0.05) 3px,
            rgba(255, 255, 255, 0.05) 6px
        );
    box-shadow:
        0 0 20px rgba(71, 179, 255, 0.3),
        inset 0 0 8px rgba(71, 179, 255, 0.2);
    pointer-events: none;
    z-index: 2;
    transition: box-shadow 150ms ease;
}

.windowIndicator.active {
    border-color: rgba(0, 212, 170, 0.9);
    box-shadow:
        0 0 30px rgba(0, 212, 170, 0.5),
        inset 0 0 12px rgba(0, 212, 170, 0.3);
}

.bottomInfo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 80px;
    min-height: 80px;
    gap: 10px;
    padding: 2px 8px 0;
    box-sizing: border-box;
}

#status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 22px;
    min-height: 52px;
    border-radius: 22px;
    background: rgba(12, 12, 12, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 245, 232, 0.88);
    pointer-events: none;
    text-align: center;
    width: min(85%, 320px);
    line-height: 1.4;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-wrap: balance;
    box-sizing: border-box;
}

.colorBar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 0;
    flex-shrink: 0;
}

.colorButton {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.colorButton:hover {
    transform: scale(1.1);
}

.colorButton:active {
    transform: scale(0.95);
}

.colorButton.colorButtonActive {
    border-color: rgba(71, 179, 255, 0.9);
    box-shadow:
        0 0 0 2px rgba(71, 179, 255, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 760px) {
    .appShell {
        padding: 12px;
        gap: 12px;
    }

    #header {
        padding: 16px;
        border-radius: 20px;
    }

    .headerActions {
        justify-content: flex-start;
        margin-left: 0;
    }

    .stageFrame {
        padding: 0;
        border-radius: 24px;
    }

    #drawSurface {
        border-radius: 0;
        margin: 12px;
    }

    .bottomInfo {
        flex-basis: 100px;
        min-height: 100px;
    }
}
