html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 10%, rgba(45, 255, 241, 0.16), transparent 25%),
        radial-gradient(circle at 86% 24%, rgba(255, 214, 44, 0.13), transparent 23%),
        linear-gradient(150deg, #111115 0%, #242018 48%, #102c29 100%);
    color: #f5f7fb;
    font-family: "Segoe UI", "Avenir Next", Arial, sans-serif;
    touch-action: none;
}

body {
    position: relative;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 64px 64px;
    opacity: 0.34;
}

.controllerShell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    height: 100%;
    padding: 12px;
    box-sizing: border-box;
}

.topBar,
.controlsPanel {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(9, 10, 13, 0.56);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(12px);
}

.topBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.eyebrow {
    margin-bottom: 4px;
    color: #36fff3;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1;
    font-weight: 750;
}

#commsInfoDiv {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.78);
    font-size: 11px;
    white-space: nowrap;
}

#commsInfo {
    color: inherit;
    text-decoration: none;
}

.statusDot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffdf2e;
    box-shadow: 0 0 14px rgba(255, 223, 46, 0.86);
}

body.connected .statusDot {
    background: #36fff3;
    box-shadow: 0 0 14px rgba(54, 255, 243, 0.9);
}

#padFrame {
    position: relative;
    align-self: center;
    justify-self: center;
    box-sizing: border-box;
    margin: 0 auto;
    max-width: 980px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background:
        radial-gradient(circle at 24% 22%, rgba(54, 255, 243, 0.13), transparent 26%),
        radial-gradient(circle at 78% 72%, rgba(255, 45, 149, 0.14), transparent 30%),
        linear-gradient(160deg, rgba(33, 30, 31, 0.9), rgba(15, 32, 30, 0.92));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        inset 0 -34px 70px rgba(0, 0, 0, 0.26),
        0 26px 62px rgba(0, 0, 0, 0.28);
}

#touchPad {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#padHint {
    position: absolute;
    left: 14px;
    top: 12px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(8, 9, 12, 0.42);
    color: rgba(255, 255, 255, 0.74);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
}

body.drawing #padHint {
    opacity: 0;
}

.controlsPanel {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.swatchRow {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
}

.swatch {
    position: relative;
    height: 38px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
    cursor: pointer;
}

.swatch[aria-pressed="true"] {
    border-color: #ffffff;
    box-shadow:
        0 0 0 2px rgba(54, 255, 243, 0.28),
        0 0 22px var(--swatch-color),
        inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

button {
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

button:active,
.swatch:active {
    transform: translateY(1px);
}

#status {
    margin: 0;
    min-height: 36px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

@media (max-width: 620px) {
    .controllerShell {
        gap: 10px;
        padding: 10px;
    }

    .topBar {
        padding: 10px;
    }

    h1 {
        font-size: 21px;
    }

    #commsInfoDiv {
        max-width: 128px;
        overflow: hidden;
    }

    .swatchRow {
        grid-template-columns: repeat(8, minmax(0, 1fr));
        gap: 6px;
    }

    .swatch {
        height: 30px;
    }
}

@media (max-width: 380px) {
    .swatchRow {
        gap: 5px;
    }

    .swatch {
        height: 26px;
    }
}
