:root {
    color-scheme: dark;
    --bg: #080a0f;
    --ink: #f6f1dc;
    --muted: #9ba8b8;
    --panel: #121722;
    --panel-2: #191f2d;
    --line: #324053;
    --cyan: #8fd1ca;
    --green: #77f27e;
    --red: #ff4c62;
    --blue: #4aa3ff;
    --yellow: #ffd84e;
    --magenta: #f06cff;
    --orange: #ff8a2a;
    --pink: #ff3fb4;
    --cabinet: #202941;
    --cabinet-deep: #080912;
    --glass: rgba(143, 209, 202, 0.18);
    --coin: #ffe98b;
    --shadow: rgba(0, 0, 0, 0.48);
    --cell: clamp(20px, min(4.4vw, 4.6vh), 30px);
    --gap: 4px;
    font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    background:
        repeating-linear-gradient(90deg, rgba(255, 216, 78, 0.05) 0 2px, transparent 2px 72px),
        repeating-linear-gradient(0deg, rgba(143, 209, 202, 0.05) 0 2px, transparent 2px 72px),
        repeating-linear-gradient(135deg, rgba(255, 63, 180, 0.055) 0 8px, transparent 8px 34px),
        linear-gradient(135deg, #070812 0%, #12151f 45%, #090b12 100%);
    background-size: auto;
    color: var(--ink);
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    color: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.hidden {
    display: none !important;
}

.crt-layer {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 10;
    background:
        radial-gradient(ellipse at center, transparent 0 54%, rgba(0, 0, 0, 0.32) 100%),
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.025) 0,
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px,
            transparent 4px
        );
    mix-blend-mode: screen;
    opacity: 0.38;
}

.app-shell {
    width: min(1500px, 100%);
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) clamp(12px, 2vw, 28px) calc(92px + env(safe-area-inset-bottom));
    position: relative;
    overflow-x: hidden;
}

.app-shell::before,
.app-shell::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    width: 12px;
    z-index: -1;
    background:
        repeating-linear-gradient(0deg, var(--pink) 0 18px, var(--yellow) 18px 30px, var(--cyan) 30px 48px),
        var(--cabinet);
    box-shadow: 0 0 22px rgba(255, 63, 180, 0.4);
}

.app-shell::before {
    left: 0;
}

.app-shell::after {
    right: 0;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: clamp(12px, 2vh, 24px);
    padding: 10px;
    border: 3px solid #05070a;
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255, 63, 180, 0.24), transparent 22% 78%, rgba(143, 209, 202, 0.2)),
        linear-gradient(180deg, #22283d 0%, #0d101a 52%, #05070a 100%);
    box-shadow:
        0 0 0 3px var(--cyan),
        0 10px 0 #05070a,
        0 0 34px rgba(143, 209, 202, 0.18);
}

.brand {
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand img {
    image-rendering: pixelated;
    filter:
        drop-shadow(4px 0 0 var(--pink))
        drop-shadow(-4px 0 0 var(--cyan))
        drop-shadow(0 0 12px rgba(255, 216, 78, 0.42));
    flex: 0 0 auto;
}

.brand strong {
    display: block;
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: clamp(1.45rem, 3vw, 2.3rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--coin);
    text-shadow:
        3px 0 0 #05070a,
        -3px 0 0 #05070a,
        0 3px 0 #05070a,
        3px 3px 0 var(--pink),
        -3px -3px 0 var(--cyan),
        0 0 18px rgba(255, 232, 139, 0.5);
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
    margin-top: 4px;
}

.account-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.user-badge,
.icon-button,
.primary-button,
.secondary-button {
    min-height: 42px;
    border: 3px solid #05070a;
    background: #0e131c;
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.user-badge {
    display: inline-flex;
    align-items: center;
    max-width: 180px;
    padding: 0 12px;
    color: var(--green);
    background:
        linear-gradient(180deg, #18251c, #071009);
    border-color: var(--green);
    text-shadow: 0 0 8px rgba(119, 242, 126, 0.55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button,
.primary-button,
.secondary-button {
    padding: 0 16px;
    text-transform: uppercase;
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.98rem;
    font-weight: 900;
    letter-spacing: 0;
    border-radius: 6px;
    text-shadow:
        1px 0 0 rgba(0, 0, 0, 0.48),
        0 1px 0 rgba(0, 0, 0, 0.48);
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.segmented button:hover,
.touch-controls button:hover {
    border-color: var(--cyan);
    transform: translateY(-1px);
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.segmented button:active,
.touch-controls button:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #05070a;
}

.accent,
.primary-button {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.75) 0 10%, transparent 10% 32%),
        linear-gradient(180deg, #dff6ef 0%, #9ccfc6 50%, #679f97 100%);
    border-color: #edfdf6;
    color: #10201d;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.secondary-button {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
        #151b28;
}

.sound-button {
    min-width: 116px;
    justify-content: center;
    color: #081218;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.sound-button[data-sound="on"] {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0 10%, transparent 10% 34%),
        linear-gradient(180deg, #ffe07c 0%, #ffad4c 48%, #ff7842 100%);
    border-color: #fff2aa;
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(255, 255, 255, 0.14),
        0 0 18px rgba(255, 184, 75, 0.35);
}

.sound-button[data-sound="off"] {
    color: #ffe6f7;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
        linear-gradient(180deg, #291125 0%, #1d1120 50%, #120a16 100%);
    border-color: rgba(255, 95, 187, 0.9);
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(255, 255, 255, 0.05),
        0 0 16px rgba(255, 63, 180, 0.24);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(360px, 1fr) minmax(210px, 280px);
    gap: clamp(12px, 2vw, 22px);
    align-items: start;
    min-width: 0;
}

.panel {
    position: relative;
    border: 3px solid #05070a;
    background:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 6px),
        linear-gradient(90deg, rgba(255, 63, 180, 0.1), transparent 20% 80%, rgba(143, 209, 202, 0.08)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 38%),
        var(--panel);
    box-shadow:
        0 0 0 2px var(--line),
        0 12px 0 var(--shadow),
        0 0 26px rgba(143, 209, 202, 0.11),
        inset 0 0 0 2px rgba(255, 255, 255, 0.035);
    padding: 14px;
    border-radius: 8px;
    min-width: 0;
}

.panel::before {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    top: -7px;
    height: 10px;
    background:
        repeating-linear-gradient(90deg, var(--red) 0 18px, var(--yellow) 18px 36px, var(--blue) 36px 54px);
    border: 2px solid #05070a;
    box-shadow: 0 0 12px rgba(255, 216, 78, 0.22);
}

.panel-title {
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    color: var(--coin);
    text-transform: uppercase;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 10px;
    text-shadow:
        2px 0 0 #05070a,
        0 2px 0 #05070a,
        0 0 10px rgba(255, 216, 78, 0.45);
}

.control-group {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.control-group label,
.stat-label {
    color: var(--muted);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.9rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.control-group output {
    color: var(--yellow);
    font-family: "Courier New", monospace;
    font-weight: 700;
}

.segmented {
    display: flex;
    gap: 6px;
    min-width: 0;
}

.segmented button {
    flex: 1 1 0;
    min-height: 40px;
    min-width: 0;
    padding-inline: 6px;
    border: 3px solid #05070a;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 36%),
        #0d121b;
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(143, 209, 202, 0.12);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 1rem;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow:
        1px 0 0 rgba(0, 0, 0, 0.45),
        0 1px 0 rgba(0, 0, 0, 0.45);
}

.segmented button.selected {
    border-color: var(--yellow);
    color: #161105;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0 12%, transparent 12% 32%),
        linear-gradient(180deg, var(--yellow), #ff9b2f);
    box-shadow:
        0 5px 0 #5f2f07,
        0 0 18px rgba(255, 216, 78, 0.38);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--cyan);
    filter: drop-shadow(0 0 7px rgba(73, 220, 230, 0.35));
}

.button-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
}

.micro-panel {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed rgba(255, 255, 255, 0.13);
    display: grid;
    gap: 4px;
}

.micro-panel strong {
    min-height: 26px;
    color: var(--green);
    font-family: "Courier New", monospace;
    text-shadow: 0 0 10px rgba(119, 242, 126, 0.5);
}

.controls-panel {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed rgba(255, 255, 255, 0.13);
}

.controls-grid {
    display: grid;
    gap: 6px;
}

.controls-grid.is-single-player [data-control-player="1"] {
    display: none;
}

.controls-subtitle {
    margin-top: 4px;
    color: var(--coin);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.control-bind-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(74px, auto);
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.control-bind-row span {
    min-width: 0;
    color: var(--muted);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.control-bind-button {
    min-height: 30px;
    min-width: 74px;
    padding: 0 8px;
    border: 2px solid #05070a;
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 38%),
        #101723;
    color: var(--yellow);
    box-shadow:
        0 3px 0 #05070a,
        inset 0 0 0 1px rgba(143, 209, 202, 0.16);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    font-weight: 900;
}

.control-bind-button.is-listening {
    border-color: var(--yellow);
    color: #161105;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 34%),
        var(--yellow);
}

.room-panel {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed rgba(255, 255, 255, 0.13);
}

.room-code {
    min-height: 38px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    padding: 6px 8px;
    border: 3px solid #05070a;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 6px, transparent 6px 12px),
        #0a0f17;
    color: var(--coin);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 1.08rem;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow:
        2px 0 0 #05070a,
        0 2px 0 #05070a,
        0 0 10px rgba(255, 216, 78, 0.4);
    box-shadow: inset 0 0 0 2px rgba(143, 209, 202, 0.12);
}

.room-actions {
    display: grid;
    gap: 9px;
}

.room-private-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.room-private-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--yellow);
}

.room-password-input {
    width: 100%;
}

.join-room-form {
    display: grid;
    grid-template-columns: minmax(68px, 0.8fr) minmax(68px, 1fr) auto;
    gap: 8px;
}

.join-room-form input,
.room-password-input {
    min-width: 0;
    min-height: 42px;
    padding: 0 10px;
    border: 3px solid #05070a;
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 36%),
        #0b111a;
    color: var(--ink);
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(143, 209, 202, 0.1);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.96rem;
    font-weight: 900;
    text-transform: uppercase;
}

.join-room-form input::placeholder,
.room-password-input::placeholder {
    color: rgba(246, 241, 220, 0.42);
}

.room-browser {
    margin-top: 12px;
    display: grid;
    gap: 7px;
}

.room-browser-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--coin);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.tiny-button {
    min-height: 28px;
    padding: 3px 8px;
    border: 2px solid #05070a;
    border-radius: 5px;
    background: var(--panel-2);
    color: var(--cyan);
    box-shadow: 0 3px 0 #05070a;
    font-family: "Courier New", monospace;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
}

.room-list {
    display: grid;
    gap: 6px;
    max-height: 178px;
    overflow: auto;
}

.room-list-item,
.room-list-empty {
    width: 100%;
    min-width: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background:
        linear-gradient(90deg, rgba(119, 242, 126, 0.1), rgba(143, 209, 202, 0.08)),
        rgba(5, 7, 10, 0.48);
    color: var(--ink);
    text-align: left;
    box-shadow: inset 0 0 0 2px rgba(143, 209, 202, 0.06);
}

.room-list-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    align-items: center;
    padding: 7px 8px;
}

.room-list-item:hover,
.room-list-item:focus-visible {
    border-color: var(--green);
}

.room-list-item strong {
    color: var(--green);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.86rem;
}

.room-list-item span {
    color: var(--coin);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    justify-self: end;
}

.room-list-item small {
    grid-column: 1 / -1;
    min-width: 0;
    color: var(--muted);
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-list-empty {
    padding: 9px 8px;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.room-hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.opponent-hud {
    position: fixed;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 12;
    width: min(330px, calc(100vw - 36px));
    max-height: min(360px, 48vh);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border: 3px solid #05070a;
    border-radius: 8px;
    background:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.028) 0 2px, transparent 2px 6px),
        linear-gradient(90deg, rgba(255, 63, 180, 0.13), rgba(143, 209, 202, 0.11)),
        rgba(11, 15, 24, 0.94);
    box-shadow:
        0 0 0 2px var(--line),
        0 8px 0 rgba(0, 0, 0, 0.55),
        0 0 24px rgba(143, 209, 202, 0.12);
    overflow: hidden;
}

.opponent-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    color: var(--coin);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 2px 0 0 #05070a, 0 2px 0 #05070a;
}

.opponent-title b {
    color: var(--green);
    font-family: "Courier New", monospace;
}

.opponent-list {
    display: grid;
    gap: 8px;
    padding: 10px;
    overflow: auto;
}

.opponent-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.opponent-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 45%),
        rgba(5, 7, 10, 0.46);
    box-shadow: inset 0 0 0 2px rgba(143, 209, 202, 0.06);
}

.opponent-card.is-self {
    border-color: var(--yellow);
}

.opponent-board {
    --opponent-cell: 6px;
    display: grid;
    grid-template-columns: repeat(8, var(--opponent-cell));
    grid-template-rows: repeat(16, var(--opponent-cell));
    gap: 1px;
    padding: 3px;
    border: 2px solid rgba(143, 209, 202, 0.32);
    background:
        linear-gradient(90deg, rgba(143, 209, 202, 0.07) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        #080c13;
    box-shadow: inset 0 0 0 1px rgba(5, 7, 10, 0.82);
}

.opponent-board.is-empty {
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 6px),
        #080c13;
}

.opponent-board-cell {
    width: var(--opponent-cell);
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.035);
}

.opponent-board-cell.red {
    --piece: var(--red);
    --piece-dark: #8f1c30;
}

.opponent-board-cell.blue {
    --piece: var(--blue);
    --piece-dark: #174d9a;
}

.opponent-board-cell.yellow {
    --piece: var(--yellow);
    --piece-dark: #9b6c10;
}

.opponent-board-cell.pill,
.opponent-board-cell.active,
.opponent-board-cell.virus {
    background: var(--piece);
    box-shadow: inset -2px -2px 0 var(--piece-dark), inset 1px 1px 0 rgba(255, 255, 255, 0.34);
}

.opponent-board-cell.active {
    filter: brightness(1.22);
}

.opponent-board-cell.virus {
    border-radius: 50%;
    box-shadow: inset -1px -1px 0 var(--piece-dark), 0 0 4px color-mix(in srgb, var(--piece), transparent 45%);
}

.opponent-meta {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.opponent-name {
    min-width: 0;
    color: var(--ink);
    font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
    font-size: 0.9rem;
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opponent-status {
    color: var(--green);
    font-family: "Courier New", monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.opponent-meter {
    height: 7px;
    border: 1px solid #05070a;
    background: #090d14;
    overflow: hidden;
}

.opponent-meter span {
    display: block;
    width: var(--progress, 0%);
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--yellow));
}

.opponent-stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-family: "Courier New", monospace;
    font-size: 0.76rem;
}

.stage {
    min-width: 0;
}

.stage-action {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(18px, 4vw, 58px);
    min-width: 0;
}

.boards {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(14px, 2vw, 24px);
    flex-wrap: wrap;
    min-width: 0;
}

.board-shell {
    --cell-local: var(--cell);
    width: calc((var(--cell-local) * 8) + (var(--gap) * 7) + 32px);
    max-width: 100%;
    min-width: 0;
}

.game-layout.versus .board-shell {
    --cell-local: clamp(18px, min(3.2vw, 4.4vh), 30px);
}

.player-strip {
    display: grid;
    grid-template-columns: auto 1fr 1fr auto;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    margin-bottom: 8px;
    font-size: clamp(0.72rem, 1.5vw, 0.9rem);
    color: var(--muted);
    padding: 7px 8px;
    border: 3px solid #05070a;
    border-radius: 7px;
    background:
        linear-gradient(90deg, rgba(255, 63, 180, 0.16), rgba(143, 209, 202, 0.12)),
        #111621;
    box-shadow: 0 5px 0 #05070a;
}

.player-strip strong {
    color: var(--coin);
    font-family: "Courier New", monospace;
    font-size: 1rem;
    text-shadow: 0 0 10px rgba(255, 216, 78, 0.45);
}

.player-strip b {
    color: var(--green);
    font-family: "Courier New", monospace;
    font-weight: 700;
    text-shadow: 0 0 9px rgba(119, 242, 126, 0.45);
}

.bottle {
    position: relative;
    padding: 30px 14px 14px;
    border: 5px solid var(--cyan);
    border-top: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 7px, transparent 7px calc(100% - 7px), rgba(255, 255, 255, 0.12) calc(100% - 7px)),
        linear-gradient(90deg, var(--glass) 0 2px, transparent 2px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.17)),
        #090d14;
    box-shadow:
        0 14px 0 #020407,
        0 0 0 4px #05070a,
        0 0 30px rgba(143, 209, 202, 0.22),
        inset 0 0 24px rgba(143, 209, 202, 0.1);
    border-radius: 0 0 8px 8px;
}

.bottle::before,
.bottle::after {
    content: "";
    position: absolute;
    top: 34px;
    bottom: 18px;
    width: 5px;
    background: linear-gradient(180deg, var(--yellow), var(--pink), var(--cyan));
    opacity: 0.55;
}

.bottle::before {
    left: 5px;
}

.bottle::after {
    right: 5px;
}

.bottle-neck {
    position: absolute;
    left: 50%;
    top: -22px;
    width: calc(var(--cell-local) * 2.4);
    height: 24px;
    transform: translateX(-50%);
    border: 5px solid var(--cyan);
    border-bottom: 0;
    background: #090d14;
    box-shadow:
        0 0 0 4px #05070a,
        0 0 18px rgba(143, 209, 202, 0.26),
        inset 0 0 14px rgba(143, 209, 202, 0.08);
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, var(--cell-local));
    grid-template-rows: repeat(16, var(--cell-local));
    gap: var(--gap);
    position: relative;
    padding: 4px;
    margin: -4px;
    background:
        linear-gradient(90deg, rgba(143, 209, 202, 0.07) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: calc(var(--cell-local) + var(--gap)) calc(var(--cell-local) + var(--gap));
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.cell,
.preview-cell {
    width: var(--cell-local);
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.09);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 42%),
        rgba(255, 255, 255, 0.025);
    position: relative;
    overflow: hidden;
    image-rendering: pixelated;
}

.cell::before,
.cell::after,
.preview-cell::before,
.preview-cell::after {
    content: "";
    position: absolute;
}

.cell.red,
.preview-cell.red {
    --piece: var(--red);
    --piece-dark: #8f1c30;
}

.cell.blue,
.preview-cell.blue {
    --piece: var(--blue);
    --piece-dark: #174d9a;
}

.cell.yellow,
.preview-cell.yellow {
    --piece: var(--yellow);
    --piece-dark: #9b6c10;
}

.cell.pill,
.preview-cell {
    background:
        radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.92) 0 10%, transparent 11%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.64) 0 18%, transparent 18% 48%, rgba(0, 0, 0, 0.2) 48% 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 45%),
        var(--piece);
    border: 2px solid rgba(255, 255, 255, 0.56);
    border-radius: 999px;
    overflow: visible;
    z-index: 1;
    box-shadow:
        0 0 10px rgba(255, 255, 255, 0.16),
        inset -5px -5px 0 var(--piece-dark),
        inset 3px 3px 0 rgba(255, 255, 255, 0.36);
    box-shadow:
        0 0 10px color-mix(in srgb, var(--piece), transparent 35%),
        inset -5px -5px 0 var(--piece-dark),
        inset 3px 3px 0 rgba(255, 255, 255, 0.36);
}

.cell.pill::before,
.preview-cell::before {
    inset: 5px auto auto 6px;
    width: 30%;
    height: 16%;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    pointer-events: none;
    z-index: 2;
}

.cell.pill::after,
.preview-cell::after {
    display: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 48%),
        var(--piece);
    pointer-events: none;
    z-index: 0;
}

.cell.pill.link-right,
.preview-cell.link-right {
    border-radius: 999px 7px 7px 999px;
}

.cell.pill.link-left,
.preview-cell.link-left {
    border-radius: 7px 999px 999px 7px;
}

.cell.pill.link-down,
.preview-cell.link-down {
    border-radius: 999px 999px 7px 7px;
}

.cell.pill.link-up,
.preview-cell.link-up {
    border-radius: 7px 7px 999px 999px;
}

.cell.pill.link-right::after,
.preview-cell.link-right::after {
    display: block;
    top: 18%;
    right: calc((var(--gap) + 4px) * -1);
    width: calc(var(--gap) + 8px);
    height: 64%;
}

.cell.pill.link-left::after,
.preview-cell.link-left::after {
    display: block;
    top: 18%;
    left: calc((var(--gap) + 4px) * -1);
    width: calc(var(--gap) + 8px);
    height: 64%;
}

.cell.pill.link-down::after,
.preview-cell.link-down::after {
    display: block;
    left: 18%;
    bottom: calc((var(--gap) + 4px) * -1);
    width: 64%;
    height: calc(var(--gap) + 8px);
}

.cell.pill.link-up::after,
.preview-cell.link-up::after {
    display: block;
    left: 18%;
    top: calc((var(--gap) + 4px) * -1);
    width: 64%;
    height: calc(var(--gap) + 8px);
}

.cell.virus {
    --virus-y: 0%;
    background-color: transparent;
    background-image: url("../assets/virus-sprites.png");
    background-repeat: no-repeat;
    background-size: 400% 300%;
    background-position: 0% var(--virus-y);
    border-color: transparent;
    box-shadow:
        0 0 12px rgba(255, 255, 255, 0.14);
    box-shadow:
        0 0 12px color-mix(in srgb, var(--piece), transparent 30%);
    transform-origin: 50% 70%;
    animation: virus-dance 720ms linear infinite;
}

.cell.virus.red {
    --virus-y: 0%;
}

.cell.virus.blue {
    --virus-y: 50%;
}

.cell.virus.yellow {
    --virus-y: 100%;
}

.cell.virus::before,
.cell.virus::after {
    display: none;
}

.cell.active {
    filter: brightness(1.14);
    box-shadow:
        0 0 16px rgba(255, 255, 255, 0.22),
        0 0 26px rgba(255, 255, 255, 0.16),
        inset -5px -5px 0 var(--piece-dark),
        inset 3px 3px 0 rgba(255, 255, 255, 0.36);
    box-shadow:
        0 0 16px color-mix(in srgb, var(--piece), white 18%),
        0 0 26px rgba(255, 255, 255, 0.16),
        inset -5px -5px 0 var(--piece-dark),
        inset 3px 3px 0 rgba(255, 255, 255, 0.36);
}

.cell.clearing {
    animation: clear-pop 140ms steps(2) infinite;
}

@keyframes clear-pop {
    50% {
        filter: brightness(2);
        transform: scale(0.9);
    }
}

@keyframes virus-dance {
    0%,
    24.99% {
        background-position: 0% var(--virus-y);
        transform: translateY(0);
    }

    25%,
    49.99% {
        background-position: 33.333333% var(--virus-y);
        transform: translateY(-1px);
    }

    50%,
    74.99% {
        background-position: 66.666667% var(--virus-y);
        transform: translateY(0);
    }

    75%,
    100% {
        background-position: 100% var(--virus-y);
        transform: translateY(-1px);
    }
}

.board-message {
    position: absolute;
    inset: 45% 12px auto;
    min-height: 36px;
    display: grid;
    place-items: center;
    padding: 6px 8px;
    border: 3px solid var(--yellow);
    background:
        repeating-linear-gradient(90deg, rgba(255, 216, 78, 0.1) 0 8px, transparent 8px 16px),
        rgba(8, 10, 15, 0.94);
    color: var(--yellow);
    font-family: "Courier New", monospace;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
    box-shadow:
        0 0 0 3px #05070a,
        0 0 22px rgba(255, 216, 78, 0.38);
    text-shadow: 0 0 10px rgba(255, 216, 78, 0.5);
}

.board-message:empty {
    display: none;
}

.next-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.game-layout.versus .next-row {
    grid-template-columns: 1fr 1fr;
}

.preview {
    --cell-local: 30px;
    min-height: 42px;
    display: grid;
    grid-template-columns: repeat(2, var(--cell-local));
    gap: var(--gap);
    align-items: center;
    width: max-content;
    padding: 8px;
    border: 3px solid #05070a;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 40%),
        #070a12;
    box-shadow:
        0 0 0 2px var(--line),
        inset 0 0 14px rgba(73, 220, 230, 0.1);
}

.doctor-card {
    position: relative;
    margin: 18px 0;
    min-height: 132px;
    border-block: 2px dashed rgba(255, 255, 255, 0.13);
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 16px 0;
    background:
        repeating-linear-gradient(90deg, transparent 0 12px, rgba(255, 255, 255, 0.035) 12px 14px);
}

.stage-doctor {
    align-self: flex-start;
    width: clamp(150px, 16vw, 210px);
    margin-top: 112px;
    padding: 18px 12px;
    border: 3px solid #05070a;
    border-radius: 8px;
    box-shadow:
        0 0 0 3px rgba(143, 209, 202, 0.75),
        0 10px 0 #05070a,
        inset 0 0 24px rgba(73, 220, 230, 0.08);
}

.stage-doctor::before {
    content: "";
    position: absolute;
    left: -56px;
    top: 52%;
    width: 52px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--yellow));
    opacity: 0.5;
    box-shadow: 0 0 12px rgba(73, 220, 230, 0.35);
}

.doctor-thrown-pill {
    position: absolute;
    left: 58px;
    top: 48px;
    --pill-half: 22px;
    --pill-gap: 0px;
    display: grid;
    grid-template-columns: repeat(2, var(--pill-half));
    gap: var(--pill-gap);
    align-items: center;
    padding: 0;
    image-rendering: pixelated;
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
    pointer-events: none;
    filter: drop-shadow(0 0 2px var(--cyan)) drop-shadow(0 0 10px rgba(255, 216, 78, 0.55));
    z-index: 2;
}

.doctor-thrown-pill-half {
    --cell-local: var(--pill-half);
    --gap: var(--pill-gap);
    width: var(--pill-half);
    aspect-ratio: 1;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.56);
    background:
        radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.92) 0 10%, transparent 11%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.64) 0 18%, transparent 18% 48%, rgba(0, 0, 0, 0.2) 48% 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 45%),
        var(--piece);
    box-shadow:
        0 0 10px color-mix(in srgb, var(--piece), transparent 35%),
        inset -4px -4px 0 var(--piece-dark),
        inset 3px 3px 0 rgba(255, 255, 255, 0.36);
    overflow: visible;
}

.doctor-thrown-pill-half::before,
.doctor-thrown-pill-half::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.doctor-thrown-pill-half::before {
    inset: 4px auto auto 5px;
    width: 30%;
    height: 16%;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    z-index: 2;
}

.doctor-thrown-pill-half::after {
    display: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 48%),
        var(--piece);
    z-index: -1;
}

.doctor-thrown-pill-half.red {
    --piece: var(--red);
    --piece-dark: #8f1c30;
}

.doctor-thrown-pill-half.blue {
    --piece: var(--blue);
    --piece-dark: #174d9a;
}

.doctor-thrown-pill-half.yellow {
    --piece: var(--yellow);
    --piece-dark: #9b6c10;
}

.doctor-thrown-pill-half.link-right {
    border-radius: 999px 7px 7px 999px;
}

.doctor-thrown-pill-half.link-left {
    border-radius: 7px 999px 999px 7px;
}

.doctor-thrown-pill-half.link-right::after {
    display: block;
    top: 18%;
    right: -4px;
    width: 8px;
    height: 64%;
}

.doctor-thrown-pill-half.link-left::after {
    display: block;
    top: 18%;
    left: -4px;
    width: 8px;
    height: 64%;
}

.stage-doctor.is-throwing .doctor-thrown-pill {
    animation: doctor-pill-throw 520ms steps(5) 1;
}

.doctor-pixel {
    position: relative;
    width: 96px;
    height: 96px;
    background-image: url("../assets/dr-medico-sprites.png");
    background-repeat: no-repeat;
    background-size: 576px 576px;
    background-position: 0 0;
    border: 4px solid #05070a;
    box-shadow:
        0 0 0 4px var(--cyan),
        8px 0 0 rgba(255, 63, 180, 0.75),
        -8px 0 0 rgba(73, 220, 230, 0.75),
        0 10px 0 #05070a;
    image-rendering: pixelated;
    animation: doctor-idle 900ms steps(6) infinite;
}

.doctor-pixel span {
    display: none;
}

.doctor-pixel.is-walk {
    animation: doctor-walk 600ms steps(6) infinite;
}

.doctor-pixel.is-throw {
    animation: doctor-throw 500ms steps(6) 1;
}

.doctor-pixel.is-rotate {
    animation: doctor-rotate 640ms steps(6) infinite;
}

.doctor-pixel.is-victory {
    animation: doctor-victory 680ms steps(6) infinite;
}

.doctor-pixel.is-lose {
    animation: doctor-lose 900ms steps(6) infinite;
}

.pulse-line {
    width: min(160px, 100%);
    height: 22px;
    background:
        linear-gradient(90deg, transparent 0 8%, var(--green) 8% 12%, transparent 12% 20%, var(--green) 20% 24%, transparent 24% 35%, var(--green) 35% 47%, transparent 47% 100%);
    opacity: 0.85;
    animation: pulse-scan 900ms steps(4) infinite;
}

@keyframes doctor-idle {
    from { background-position: 0 0; }
    to { background-position: -576px 0; }
}

@keyframes doctor-walk {
    from { background-position: 0 -96px; }
    to { background-position: -576px -96px; }
}

@keyframes doctor-throw {
    from { background-position: 0 -192px; }
    to { background-position: -576px -192px; }
}

@keyframes doctor-pill-throw {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(0deg);
    }
    20% {
        opacity: 1;
        transform: translate(-16px, -7px) rotate(-18deg);
    }
    82% {
        opacity: 1;
        transform: translate(-176px, -54px) rotate(-90deg);
    }
    100% {
        opacity: 0;
        transform: translate(-214px, -70px) rotate(-90deg);
    }
}

@keyframes doctor-rotate {
    from { background-position: 0 -288px; }
    to { background-position: -576px -288px; }
}

@keyframes doctor-victory {
    from { background-position: 0 -384px; }
    to { background-position: -576px -384px; }
}

@keyframes doctor-lose {
    from { background-position: 0 -480px; }
    to { background-position: -576px -480px; }
}

@keyframes pulse-scan {
    50% {
        filter: brightness(1.6);
    }
}

.leaderboard ol {
    margin: 0;
    padding-left: 22px;
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.leaderboard li::marker {
    color: var(--cyan);
    font-family: "Courier New", monospace;
}

.leaderboard strong {
    color: var(--coin);
    text-shadow: 0 0 8px rgba(255, 216, 78, 0.35);
}

.touch-controls {
    position: fixed;
    left: 50%;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 11;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(6, minmax(42px, 58px));
    gap: 8px;
    padding: 8px;
    border: 3px solid #05070a;
    background:
        linear-gradient(90deg, rgba(255, 63, 180, 0.22), rgba(73, 220, 230, 0.18)),
        rgba(8, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    display: none;
    box-shadow:
        0 0 0 2px var(--line),
        0 8px 0 rgba(0, 0, 0, 0.5);
    touch-action: none;
    user-select: none;
}

.touch-controls button {
    min-height: 46px;
    border: 3px solid #05070a;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 38%),
        #101620;
    box-shadow:
        0 5px 0 #05070a,
        inset 0 0 0 2px rgba(255, 255, 255, 0.04);
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.touch-controls span {
    position: absolute;
    inset: 0;
}

.touch-controls b {
    display: none;
}

[data-touch="left"] span::before,
[data-touch="right"] span::before,
[data-touch="down"] span::before,
[data-touch="drop"] span::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-right: 14px solid var(--cyan);
    transform: translate(-50%, -50%);
}

[data-touch="right"] span::before {
    border-right: 0;
    border-left: 14px solid var(--cyan);
}

[data-touch="down"] span::before,
[data-touch="drop"] span::before {
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 14px solid var(--cyan);
    border-bottom: 0;
}

[data-touch="drop"] span::after {
    content: "";
    position: absolute;
    left: 32%;
    right: 32%;
    bottom: 12px;
    height: 4px;
    background: var(--yellow);
}

[data-touch="rotate-left"] span::before,
[data-touch="rotate-right"] span::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    border: 4px solid var(--magenta);
    border-left-color: transparent;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

[data-touch="rotate-left"] span::before {
    border-left-color: var(--magenta);
    border-right-color: transparent;
}

.blast-screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        repeating-linear-gradient(90deg, rgba(73, 220, 230, 0.12) 0 6px, transparent 6px 28px),
        repeating-linear-gradient(0deg, rgba(255, 216, 78, 0.08) 0 4px, transparent 4px 24px),
        rgba(3, 5, 10, 0.84);
    overflow: hidden;
}

.blast-screen::before {
    content: "";
    position: absolute;
    inset: -20vmax;
    background:
        conic-gradient(
            from 0deg,
            rgba(255, 216, 78, 0.95) 0 10deg,
            transparent 10deg 23deg,
            rgba(255, 63, 180, 0.82) 23deg 34deg,
            transparent 34deg 47deg,
            rgba(73, 220, 230, 0.9) 47deg 59deg,
            transparent 59deg 72deg
        );
    opacity: 0.55;
    animation: blast-spin 980ms steps(12) infinite;
}

.blast-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 6px);
    pointer-events: none;
}

.blast-rays {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.blast-rays span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 86px;
    border: 3px solid #05070a;
    background: var(--coin);
    box-shadow: 0 0 18px rgba(255, 216, 78, 0.55);
    transform-origin: 50% 170px;
    animation: blast-pop 520ms steps(3) infinite;
}

.blast-rays span:nth-child(1) { transform: translate(-50%, -170px) rotate(0deg); background: var(--yellow); }
.blast-rays span:nth-child(2) { transform: translate(-50%, -170px) rotate(45deg); background: var(--cyan); }
.blast-rays span:nth-child(3) { transform: translate(-50%, -170px) rotate(90deg); background: var(--red); }
.blast-rays span:nth-child(4) { transform: translate(-50%, -170px) rotate(135deg); background: var(--blue); }
.blast-rays span:nth-child(5) { transform: translate(-50%, -170px) rotate(180deg); background: var(--magenta); }
.blast-rays span:nth-child(6) { transform: translate(-50%, -170px) rotate(225deg); background: var(--green); }
.blast-rays span:nth-child(7) { transform: translate(-50%, -170px) rotate(270deg); background: var(--orange); }
.blast-rays span:nth-child(8) { transform: translate(-50%, -170px) rotate(315deg); background: var(--cyan); }

.blast-card {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    border: 5px solid #05070a;
    border-radius: 8px;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 4px, transparent 4px 12px),
        linear-gradient(135deg, rgba(255, 63, 180, 0.2), transparent 28% 72%, rgba(73, 220, 230, 0.22)),
        #121722;
    box-shadow:
        0 0 0 4px var(--yellow),
        0 0 0 8px var(--cyan),
        0 18px 0 #05070a,
        0 0 48px rgba(255, 216, 78, 0.34);
    padding: 24px;
    display: grid;
    justify-items: center;
    gap: 12px;
    text-align: center;
    animation: blast-card-in 260ms steps(4) both;
}

.blast-kicker {
    padding: 5px 12px;
    border: 3px solid #05070a;
    background: var(--green);
    color: #061108;
    font-family: "Courier New", monospace;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #05070a;
}

.blast-card h2 {
    margin: 0;
    color: var(--coin);
    font-family: "Courier New", monospace;
    font-size: 3rem;
    line-height: 0.95;
    text-transform: uppercase;
    text-shadow:
        4px 0 0 #05070a,
        -4px 0 0 #05070a,
        0 4px 0 #05070a,
        5px 5px 0 var(--pink),
        -5px -5px 0 var(--cyan),
        0 0 22px rgba(255, 232, 139, 0.64);
}

.blast-doctor {
    width: 128px;
    height: 128px;
    background-image: url("../assets/dr-medico-sprites.png");
    background-repeat: no-repeat;
    background-size: 768px 768px;
    image-rendering: pixelated;
    animation: blast-doctor-victory 620ms steps(6) infinite;
}

.blast-screen.is-lose .blast-doctor {
    animation-name: blast-doctor-lose;
}

.blast-card p {
    margin: 0;
    color: var(--ink);
    font-family: "Courier New", monospace;
    font-weight: 700;
    text-transform: uppercase;
}

.blast-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.blast-stats span {
    min-width: 0;
    border: 3px solid #05070a;
    background: #090d14;
    box-shadow: inset 0 0 0 2px rgba(73, 220, 230, 0.12), 0 5px 0 #05070a;
    padding: 8px 6px;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.blast-stats b {
    display: block;
    margin-top: 4px;
    color: var(--green);
    font-family: "Courier New", monospace;
    font-size: 1.05rem;
    text-shadow: 0 0 10px rgba(119, 242, 126, 0.48);
}

.blast-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 4px;
}

.blast-screen.is-auto .blast-actions {
    display: none;
}

.blast-screen.is-lose .blast-kicker {
    background: var(--red);
    color: var(--ink);
}

.blast-screen.is-lose .blast-card {
    box-shadow:
        0 0 0 4px var(--red),
        0 0 0 8px var(--magenta),
        0 18px 0 #05070a,
        0 0 48px rgba(255, 76, 98, 0.28);
}

@keyframes blast-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes blast-pop {
    50% {
        height: 118px;
        filter: brightness(1.35);
    }
}

@keyframes blast-card-in {
    from {
        transform: scale(0.82) translateY(18px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes blast-doctor-victory {
    from { background-position: 0 -512px; }
    to { background-position: -768px -512px; }
}

@keyframes blast-doctor-lose {
    from { background-position: 0 -640px; }
    to { background-position: -768px -640px; }
}

.auth-dialog {
    width: min(420px, calc(100vw - 28px));
    border: 3px solid var(--cyan);
    background:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 6px),
        var(--panel);
    color: var(--ink);
    box-shadow: 0 20px 0 rgba(0, 0, 0, 0.52);
    border-radius: 8px;
    padding: 0;
}

.auth-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
}

.dialog-shell,
.auth-form {
    padding: 18px;
}

.dialog-shell {
    margin: 0;
    display: grid;
    gap: 14px;
    position: relative;
}

.dialog-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: "Courier New", monospace;
    text-transform: uppercase;
}

.close-button {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 34px;
    height: 34px;
    border: 2px solid var(--line);
    background: #0e131c;
}

.close-button::before,
.close-button::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: 14px;
    height: 3px;
    background: var(--ink);
    transform: rotate(45deg);
}

.close-button::after {
    transform: rotate(-45deg);
}

.auth-form {
    display: grid;
    gap: 12px;
    padding-top: 0;
}

.auth-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    text-transform: uppercase;
}

.auth-form input {
    min-height: 42px;
    border: 3px solid var(--line);
    background: #090d14;
    color: var(--ink);
    padding: 0 10px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--cyan);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(88px + env(safe-area-inset-bottom));
    z-index: 20;
    transform: translateX(-50%) translateY(12px);
    width: min(520px, calc(100vw - 28px));
    min-height: 40px;
    display: grid;
    place-items: center;
    padding: 10px 14px;
    border: 3px solid var(--yellow);
    background:
        repeating-linear-gradient(90deg, rgba(255, 216, 78, 0.1) 0 8px, transparent 8px 16px),
        rgba(8, 10, 15, 0.94);
    color: var(--yellow);
    font-family: "Courier New", monospace;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .command-panel {
        order: 1;
    }

    .stage {
        order: 2;
    }

    .telemetry-panel {
        order: 3;
    }

    .panel {
        padding: 12px;
    }

    .stage-action {
        align-items: center;
        gap: 16px;
    }

    .stage-doctor {
        width: 142px;
        margin-top: 104px;
        padding-inline: 8px;
    }

    .stage-doctor::after {
        display: none;
    }

    .command-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        align-items: end;
    }

    .command-panel .panel-title,
    .command-panel .micro-panel {
        grid-column: 1 / -1;
    }

    .button-stack {
        margin-top: 0;
    }
}

@media (max-width: 620px) {
    :root {
        --cell: clamp(19px, 8.05vw, 27px);
        --gap: 3px;
    }

    .app-shell {
        padding: max(6px, env(safe-area-inset-top)) 6px calc(164px + env(safe-area-inset-bottom));
    }

    .app-shell::before,
    .app-shell::after {
        width: 6px;
    }

    .topbar {
        min-height: 0;
        align-items: center;
        flex-direction: row;
        gap: 6px;
        margin-bottom: 5px;
        padding: 4px 5px;
        border-width: 2px;
        box-shadow:
            0 0 0 2px var(--cyan),
            0 4px 0 #05070a;
    }

    .account-bar {
        justify-content: flex-end;
        gap: 5px;
    }

    .brand {
        gap: 7px;
    }

    .brand img {
        width: 28px;
        height: 28px;
    }

    .brand strong {
        font-size: clamp(1rem, 5.5vw, 1.45rem);
    }

    .brand small {
        display: none;
    }

    .account-bar .text-button,
    .account-bar .user-badge {
        display: none;
    }

    .sound-button {
        min-height: 30px;
        padding-inline: 7px;
        font-size: 0.66rem;
    }

    .player-strip {
        grid-template-columns: auto 1fr 1fr auto;
        gap: 6px;
    }

    .game-layout.versus .board-shell {
        --cell-local: clamp(18px, 9vw, 31px);
    }

    .game-layout {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        gap: 10px;
    }

    .panel,
    .stage,
    .telemetry-panel,
    .command-panel {
        width: 100%;
        max-width: 100%;
    }

    .stage {
        order: 1;
    }

    .telemetry-panel {
        order: 2;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        padding: 8px;
    }

    .command-panel {
        order: 3;
    }

    .telemetry-panel .leaderboard {
        max-height: 126px;
        overflow: auto;
    }

    .telemetry-panel .panel-title {
        margin-bottom: 6px;
        font-size: 0.92rem;
    }

    .telemetry-panel .next-row {
        position: fixed;
        left: max(9px, env(safe-area-inset-left));
        top: calc(max(6px, env(safe-area-inset-top)) + 74px);
        z-index: 14;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 44px;
        gap: 4px;
        padding: 3px 2px;
        border: 2px solid #05070a;
        border-radius: 7px;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 38%),
            rgba(8, 10, 15, 0.94);
        box-shadow:
            0 0 0 2px rgba(143, 209, 202, 0.72),
            0 4px 0 rgba(0, 0, 0, 0.55);
        pointer-events: none;
    }

    .telemetry-panel .next-row > div {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        min-width: 0;
    }

    .telemetry-panel .next-row .panel-title {
        margin: 0;
        color: var(--coin);
        font-size: 0;
        line-height: 1;
        white-space: nowrap;
    }

    .telemetry-panel .next-row .panel-title::after {
        content: "NEXT";
        font-size: 0.47rem;
    }

    .leaderboard ol {
        gap: 4px;
        font-size: 0.72rem;
    }

    .preview {
        --cell-local: 15px;
        min-height: 0;
        gap: 2px;
        padding: 3px;
        border-width: 2px;
    }

    .telemetry-panel .next-row .preview {
        --cell-local: 12px;
        gap: 1px;
        padding: 2px;
    }

    .boards {
        width: 100%;
        justify-content: center;
    }

    .stage-action {
        flex-direction: row;
    }

    .stage-doctor {
        display: none;
    }

    .board-shell {
        margin-inline: auto;
        transform: translateX(18px);
    }

    .bottle {
        padding: 23px 8px 8px;
        border-width: 4px;
    }

    .bottle-neck {
        width: 54px;
        height: 25px;
        top: -21px;
    }

    .grid {
        gap: var(--gap);
        padding: 5px;
    }

    .player-strip {
        min-height: 27px;
        margin-bottom: 4px;
        padding: 3px 6px;
        font-size: 0.68rem;
        border-width: 2px;
        box-shadow: 0 3px 0 #05070a;
    }

    .player-strip strong {
        font-size: 0.78rem;
    }

    .board-message {
        width: calc(100% - 18px);
        min-height: 30px;
        font-size: 0.72rem;
    }

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

    .command-panel .panel-title,
    .command-panel .controls-panel,
    .command-panel .room-panel,
    .command-panel .micro-panel {
        grid-column: 1 / -1;
    }

    .control-group {
        margin-bottom: 0;
    }

    .control-group label,
    .stat-label {
        font-size: 0.72rem;
    }

    .segmented {
        gap: 4px;
    }

    .segmented button,
    .primary-button,
    .secondary-button {
        min-height: 34px;
        border-width: 2px;
        box-shadow: 0 3px 0 #05070a;
        font-size: 0.82rem;
    }

    .command-panel .button-stack {
        position: fixed;
        left: max(9px, env(safe-area-inset-left));
        top: calc(max(6px, env(safe-area-inset-top)) + 150px);
        z-index: 12;
        transform: none;
        width: 44px;
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        margin: 0;
        padding: 0;
    }

    .command-panel .button-stack .primary-button,
    .command-panel .button-stack .secondary-button {
        min-height: 42px;
        padding: 3px 2px;
        border-width: 2px;
        box-shadow: 0 2px 0 #05070a;
        font-size: 0.54rem;
        line-height: 1.05;
        writing-mode: horizontal-tb;
    }

    .game-layout.is-running .command-panel .button-stack .primary-button {
        opacity: 0.42;
        filter: grayscale(0.55);
    }

    .controls-panel,
    .room-panel,
    .micro-panel {
        margin-top: 8px;
        padding-top: 8px;
    }

    .control-bind-row {
        grid-template-columns: minmax(0, 1fr) minmax(66px, auto);
    }

    .control-bind-button {
        min-height: 28px;
        min-width: 66px;
    }

    .touch-controls {
        left: 6px;
        right: 6px;
        bottom: max(7px, env(safe-area-inset-bottom));
        width: auto;
        transform: none;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-template-rows: 50px 52px;
        gap: 5px;
        padding: 6px;
        border-width: 2px;
        border-radius: 10px;
        background:
            linear-gradient(90deg, rgba(73, 220, 230, 0.18), transparent 46%, rgba(255, 63, 180, 0.16) 54%),
            rgba(8, 10, 15, 0.94);
    }

    .touch-controls button {
        min-height: 0;
        border-width: 2px;
        border-radius: 8px;
        box-shadow:
            0 4px 0 #05070a,
            inset 0 0 0 2px rgba(255, 255, 255, 0.05);
    }

    .touch-controls button::after {
        content: "";
        position: absolute;
        inset: 5px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 5px;
        pointer-events: none;
    }

    .touch-controls button:active {
        transform: translateY(2px);
        box-shadow:
            0 2px 0 #05070a,
            inset 0 0 0 2px rgba(255, 255, 255, 0.09),
            0 0 18px rgba(255, 216, 78, 0.22);
        filter: brightness(1.18);
    }

    .touch-controls b {
        display: block;
        position: absolute;
        left: 4px;
        right: 4px;
        bottom: 4px;
        color: var(--coin);
        font-family: "Arial Black", "Trebuchet MS", "Courier New", monospace;
        font-size: 0.52rem;
        line-height: 1;
        text-transform: uppercase;
        text-shadow: 1px 1px 0 #05070a;
        pointer-events: none;
    }

    .touch-controls span {
        bottom: 12px;
    }

    [data-touch="left"] {
        grid-column: 1;
        grid-row: 1;
        border-color: rgba(143, 209, 202, 0.85);
    }

    [data-touch="right"] {
        grid-column: 4;
        grid-row: 1;
        border-color: rgba(143, 209, 202, 0.85);
    }

    [data-touch="down"] {
        grid-column: 1 / span 2;
        grid-row: 2;
        border-color: rgba(119, 242, 126, 0.72);
    }

    [data-touch="rotate-left"] {
        grid-column: 2;
        grid-row: 1;
        border-color: rgba(240, 108, 255, 0.8);
    }

    [data-touch="rotate-right"] {
        grid-column: 3;
        grid-row: 1;
        border-color: rgba(240, 108, 255, 0.8);
    }

    [data-touch="drop"] {
        grid-column: 3 / span 2;
        grid-row: 2;
        border-color: rgba(255, 216, 78, 0.88);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 38%),
            linear-gradient(180deg, #37230b, #141018);
    }

    [data-touch="rotate-left"],
    [data-touch="rotate-right"] {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 38%),
            #1c1024;
    }

    [data-touch="down"] {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 38%),
            #102018;
    }

    .blast-screen {
        padding: 14px;
    }

    .blast-card {
        padding: 18px 12px;
    }

    .blast-card h2 {
        font-size: 2rem;
    }

    .blast-doctor {
        width: 96px;
        height: 96px;
        background-size: 576px 576px;
    }

    .blast-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    @keyframes blast-doctor-victory {
        from { background-position: 0 -384px; }
        to { background-position: -576px -384px; }
    }

    @keyframes blast-doctor-lose {
        from { background-position: 0 -480px; }
        to { background-position: -576px -480px; }
    }
}

@media (max-width: 360px) {
    .command-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) and (max-height: 800px) {
    :root {
        --cell: clamp(18px, 7.25vw, 25px);
    }

    .touch-controls {
        grid-template-rows: 48px 48px;
    }

    .command-panel .button-stack {
        top: calc(max(6px, env(safe-area-inset-top)) + 136px);
    }
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
    .touch-controls {
        display: grid;
    }

    .stage {
        padding-bottom: 122px;
    }
}

@media (hover: hover) and (pointer: fine) and (min-width: 761px) {
    .app-shell {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }

    .doctor-pixel {
        animation: none !important;
    }

    .blast-screen::before,
    .blast-rays span,
    .blast-card,
    .blast-doctor {
        animation: none !important;
    }
}
