:root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-strong: #1d222d;
    --surface-soft: #13161e;
    --border: #303643;
    --border-soft: #252a35;
    --text: #f5f7fa;
    --text-secondary: #c0c4cc;
    --text-muted: #909399;
    --primary: #409eff;
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
    --cyan: #2ec7c9;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background-color: var(--bg);
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.app-shell {
    width: min(1580px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px;
}

.topbar,
.machine-section,
.stage-panel,
.machine-info-panel {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.topbar {
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 20px;
    border-top: 3px solid var(--primary);
}

.brand-block {
    min-width: 0;
}

.brand-kicker,
.section-kicker {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.brand-title {
    margin: 0;
    font-size: clamp(22px, 3vw, 32px);
    line-height: 1.2;
    font-weight: 760;
}

.brand-subtitle {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.account-area {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 280px;
}

.connection-pill,
.status-chip,
.machine-state,
.stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.connection-dot,
.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.connection-pill[data-state="connected"] .connection-dot,
.machine-state.online .status-dot {
    background: var(--success);
    box-shadow: 0 0 10px rgba(103, 194, 58, 0.65);
}

.connection-pill[data-state="connecting"] .connection-dot {
    background: var(--warning);
}

.connection-pill[data-state="closed"] .connection-dot,
.connection-pill[data-state="error"] .connection-dot {
    background: var(--danger);
}

.user-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-strong);
    object-fit: cover;
}

.avatar-fallback {
    display: grid;
    place-items: center;
    color: var(--primary);
    font-size: 18px;
    font-weight: 800;
}

.user-copy {
    min-width: 0;
}

.user-name,
.user-meta {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name {
    max-width: 180px;
    font-size: 14px;
    font-weight: 700;
}

.user-meta {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.icon-button,
.command-button,
.text-button,
.primary-button,
.danger-button {
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    padding: 0;
    background: var(--surface-strong);
}

.icon-button:hover,
.text-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.icon-button:disabled,
.command-button:disabled,
.text-button:disabled,
.primary-button:disabled,
.danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.icon-button svg,
.text-button svg,
.primary-button svg,
.danger-button svg {
    width: 17px;
    height: 17px;
    pointer-events: none;
}

.text-button,
.primary-button,
.danger-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 13px;
    background: var(--surface-strong);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.primary-button {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.primary-button:hover {
    background: #66b1ff;
}

.danger-button {
    border-color: rgba(245, 108, 108, 0.55);
    background: rgba(245, 108, 108, 0.1);
    color: #ffb4b4;
}

.danger-button:hover {
    background: rgba(245, 108, 108, 0.2);
}

.machine-section {
    margin-top: 14px;
    padding: 14px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.section-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.25;
}

.section-description {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.machine-strip-shell {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: stretch;
    gap: 8px;
}

.machine-strip-shell > .icon-button {
    align-self: center;
}

.machine-strip {
    min-height: 114px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 8px;
    cursor: grab;
    scrollbar-color: var(--primary) var(--surface-soft);
    scrollbar-width: thin;
    scroll-behavior: smooth;
    touch-action: pan-x;
}

.machine-strip.dragging {
    cursor: grabbing;
    scroll-behavior: auto;
    user-select: none;
}

.machine-strip::-webkit-scrollbar {
    height: 7px;
}

.machine-strip::-webkit-scrollbar-track {
    background: var(--surface-soft);
}

.machine-strip::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--primary);
}

.machine-card {
    width: calc((100% - 20px) / 3);
    height: 104px;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    flex: 0 0 calc((100% - 20px) / 3);
    gap: 11px;
    padding: 9px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.machine-card:hover {
    border-color: #5c6575;
    transform: translateY(-1px);
}

.machine-card.selected {
    border-color: var(--primary);
    background: #192738;
    box-shadow: inset 0 0 0 1px rgba(64, 158, 255, 0.32);
}

.machine-card:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.machine-cover {
    width: 78px;
    height: 84px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: #11151e;
    object-fit: cover;
}

.machine-cover-wrap {
    position: relative;
    width: 78px;
    height: 84px;
}

.machine-participation-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 1;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
}

.machine-participation-badge.is-queued {
    background: #409eff;
}

.machine-participation-badge.is-active {
    background: #67c23a;
}

.machine-participation-badge svg {
    width: 14px;
    height: 14px;
}

.machine-card-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 0;
}

.machine-card-title,
.machine-card-room,
.machine-card-price {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.machine-card-title {
    font-size: 14px;
    font-weight: 750;
}

.machine-card-room {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.machine-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
}

.machine-card-price {
    color: var(--warning);
    font-size: 12px;
    font-weight: 800;
}

.machine-state {
    min-height: 23px;
    padding: 3px 7px;
    font-size: 10px;
}

.room-layout {
    display: grid;
    grid-template-columns: minmax(690px, 1.55fr) minmax(290px, 0.62fr);
    align-items: stretch;
    gap: 14px;
    margin-top: 14px;
}

.stage-panel {
    min-width: 0;
    padding: 14px;
}

.stage-grid {
    min-height: 620px;
    display: grid;
    grid-template-columns: minmax(320px, 0.92fr) minmax(330px, 1.08fr);
    align-items: stretch;
    gap: 14px;
}

.video-column,
.control-column {
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.video-column {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.video-frame {
    position: relative;
    width: min(100%, 350px);
    aspect-ratio: 9 / 16;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid #3a4352;
    border-radius: var(--radius);
    background: #07090d;
}

#live-player {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#live-player,
#live-player > div,
#live-player video,
#live-player canvas {
    width: 100% !important;
    height: 100% !important;
}

#live-player video {
    display: block;
    aspect-ratio: 9 / 16;
    object-fit: cover;
}

.stream-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    border-color: rgba(64, 158, 255, 0.52);
    background: rgba(8, 11, 17, 0.82);
    color: #d9ecff;
}

.video-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 9, 13, 0.94);
    text-align: center;
}

.video-overlay.visible {
    display: flex;
}

.video-overlay-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    color: var(--primary);
}

.video-overlay h3 {
    margin: 0;
    font-size: 16px;
}

.video-overlay p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.7;
}

.video-overlay .text-button {
    margin-top: 16px;
}

.control-column {
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.control-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.control-heading-copy {
    min-width: 0;
}

.control-title-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.control-title {
    margin: 0;
    font-size: 18px;
}

.control-clock {
    min-width: 104px;
    color: var(--text-secondary);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}

.control-helper {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
}

.control-status-banner {
    margin-top: 14px;
    padding: 11px 12px;
    border: 1px solid rgba(64, 158, 255, 0.35);
    border-radius: 6px;
    background: rgba(64, 158, 255, 0.09);
    color: #d9ecff;
    font-size: 13px;
    line-height: 1.55;
}

.control-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.stat-box {
    min-width: 0;
    padding: 9px 8px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-strong);
    text-align: center;
}

.stat-value,
.stat-label {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-value {
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
}

.stat-label {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

.control-surface {
    min-height: 330px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: #10131a;
}

.coin-panel,
.locked-panel {
    width: min(100%, 360px);
    text-align: center;
}

.auto-grab-entry {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

.auto-grab-config {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
    text-align: left;
}

.auto-grab-config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.auto-grab-config-label {
    flex: 0 0 auto;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.auto-grab-round-options {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(40px, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.auto-grab-round-option {
    min-width: 40px;
    height: 34px;
    padding: 0 5px;
    border: 0;
    border-right: 1px solid var(--border);
    background: #171d27;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.auto-grab-round-option:last-child {
    border-right: 0;
}

.auto-grab-round-option:hover,
.auto-grab-round-option.selected {
    background: rgba(64, 158, 255, 0.2);
    color: #d9ecff;
}

.auto-grab-round-option:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.auto-grab-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.auto-grab-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.coin-button {
    width: 100%;
    min-height: 68px;
    border: 1px solid #ff8f8f;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}

.coin-button:hover {
    background: #ff7878;
}

.auto-grab-start-button {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid rgba(64, 158, 255, 0.7);
    border-radius: 7px;
    background: rgba(64, 158, 255, 0.12);
    color: #a9d5ff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.auto-grab-start-button:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(64, 158, 255, 0.22);
    color: #fff;
}

.auto-grab-start-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.auto-grab-start-button svg {
    width: 18px;
    height: 18px;
}

.coin-price {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.auto-grab-requirement {
    margin: 6px 0 0;
    color: var(--primary);
    font-size: 11px;
    line-height: 1.55;
}

.auto-grab-requirement.unavailable {
    color: var(--text-muted);
}

.auto-grab-panel {
    width: min(100%, 440px);
    padding: 18px;
    border: 1px solid rgba(64, 158, 255, 0.45);
    border-radius: 8px;
    background: #121923;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.auto-grab-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.auto-grab-heading h3 {
    margin: 2px 0 0;
    font-size: 18px;
}

.auto-grab-kicker {
    margin: 0;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.auto-grab-count {
    flex: 0 0 auto;
    color: #fff;
    font-size: 23px;
    font-weight: 800;
    line-height: 1;
}

.auto-grab-progress {
    height: 8px;
    overflow: hidden;
    margin-top: 16px;
    border-radius: 4px;
    background: #252c38;
}

.auto-grab-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 220ms ease;
}

.auto-grab-message {
    min-height: 42px;
    margin: 14px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.auto-grab-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.auto-grab-stats > div {
    min-width: 0;
    padding: 10px 7px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: #0d1118;
    text-align: center;
}

.auto-grab-stats strong,
.auto-grab-stats span {
    display: block;
    overflow-wrap: anywhere;
}

.auto-grab-stats strong {
    color: var(--text);
    font-size: 16px;
}

.auto-grab-stats span {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.auto-grab-last-result {
    margin: 12px 0 0;
    padding: 9px 10px;
    border-left: 3px solid var(--success);
    background: rgba(103, 194, 58, 0.08);
    color: #b3e19d;
    font-size: 12px;
    line-height: 1.5;
}

.auto-grab-stop-button {
    width: 100%;
    margin-top: 16px;
}

.auto-grab-summary {
    width: min(100%, 440px);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 12px auto 0;
    padding: 11px 12px;
    border: 1px solid rgba(245, 108, 108, 0.28);
    border-radius: 7px;
    background: rgba(245, 108, 108, 0.07);
    color: #fab6b6;
    text-align: left;
}

.auto-grab-summary.completed {
    border-color: rgba(103, 194, 58, 0.32);
    background: rgba(103, 194, 58, 0.08);
    color: #b3e19d;
}

.auto-grab-summary svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin-top: 1px;
}

.auto-grab-summary strong {
    color: currentColor;
    font-size: 12px;
}

.auto-grab-summary p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.55;
}

.dpad {
    position: relative;
    width: min(100%, 316px);
    display: grid;
    grid-template-columns: repeat(3, 84px);
    grid-template-rows: repeat(3, 76px);
    justify-content: center;
    gap: 9px;
    padding: 17px;
    border: 1px solid #303746;
    border-radius: 8px;
    background: #0b0e14;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 24px rgba(0, 0, 0, 0.26);
}

.dpad::before {
    content: "";
    position: absolute;
    inset: 9px;
    border: 1px solid #202632;
    border-radius: 6px;
    pointer-events: none;
}

.command-button {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border-color: #465164;
    border-radius: 7px;
    background: #232a36;
    color: #d8dee9;
    box-shadow: 0 5px 0 #080a0f, 0 8px 14px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(0);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 130ms ease, background-color 130ms ease, color 130ms ease, box-shadow 130ms ease, transform 90ms ease;
}

.command-button::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border: 1px solid #11151d;
    border-radius: 50%;
    background: #596273;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.command-button svg {
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 1;
    pointer-events: none;
    transition: transform 120ms ease;
}

.direction-button:not(:disabled):hover {
    border-color: var(--primary);
    background: #25364a;
    color: #b9dcff;
    transform: translateY(-1px);
}

.direction-button.is-pressing,
.direction-button.is-holding {
    border-color: var(--primary);
    background: #1d3148;
    color: #d9ecff;
    box-shadow: 0 2px 0 #080a0f, 0 4px 8px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(64, 158, 255, 0.22);
    transform: translateY(3px);
}

.direction-button.is-pressing svg,
.direction-button.is-holding svg {
    transform: scale(0.92);
}

.direction-button.is-holding {
    box-shadow: 0 2px 0 #080a0f, 0 4px 8px rgba(0, 0, 0, 0.28), inset 0 0 0 2px rgba(64, 158, 255, 0.46), 0 0 14px rgba(64, 158, 255, 0.24);
}

.direction-button.is-holding::after {
    background: var(--success);
    box-shadow: 0 0 0 1px rgba(103, 194, 58, 0.2), 0 0 8px rgba(103, 194, 58, 0.72);
    animation: direction-hold-pulse 900ms ease-in-out infinite;
}

.direction-button.is-tap-feedback {
    animation: direction-tap-release 180ms ease-out;
}

.command-button.grab-button {
    border-color: rgba(230, 162, 60, 0.62);
    background: var(--warning);
    color: #17110a;
    box-shadow: 0 5px 0 #71480e, 0 8px 14px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.command-button.grab-button:not(:disabled):hover {
    background: #ebb563;
    color: #17110a;
    transform: translateY(-1px);
}

.command-button.grab-button:not(:disabled):active {
    box-shadow: 0 2px 0 #71480e, 0 4px 8px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(3px);
}

.command-button.grab-button::after {
    background: #fff2c7;
    border-color: rgba(113, 72, 14, 0.56);
}

@keyframes direction-hold-pulse {
    0%, 100% {
        opacity: 0.72;
    }

    50% {
        opacity: 1;
    }
}

@keyframes direction-tap-release {
    0% {
        border-color: #9dccff;
        background: #29496a;
        box-shadow: 0 2px 0 #080a0f, 0 4px 8px rgba(0, 0, 0, 0.28), inset 0 0 0 2px rgba(64, 158, 255, 0.58);
        transform: translateY(3px);
    }

    100% {
        border-color: #465164;
        background: #232a36;
        box-shadow: 0 5px 0 #080a0f, 0 8px 14px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
        transform: translateY(0);
    }
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-grab { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.locked-panel svg {
    width: 46px;
    height: 46px;
    color: var(--warning);
}

.locked-panel h3 {
    margin: 12px 0 0;
    font-size: 18px;
}

.locked-panel p {
    max-width: 330px;
    margin: 9px auto 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.7;
}

.machine-info-panel {
    min-width: 0;
    padding: 16px;
}

.machine-info-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}

.machine-info-name {
    overflow-wrap: anywhere;
    margin: 0;
    font-size: 22px;
    line-height: 1.35;
}

.machine-info-room {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.machine-code {
    flex: 0 0 auto;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 14px;
}

.status-chip.primary { border-color: rgba(64, 158, 255, 0.45); color: #b9dcff; }
.status-chip.success { border-color: rgba(103, 194, 58, 0.45); color: #c2e7b0; }
.status-chip.warning { border-color: rgba(230, 162, 60, 0.45); color: #f3d19e; }
.status-chip.danger { border-color: rgba(245, 108, 108, 0.45); color: #fab6b6; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: 14px;
}

.info-item {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-soft);
}

.info-label,
.info-value {
    margin: 0;
}

.info-label {
    color: var(--text-muted);
    font-size: 10px;
}

.info-value {
    overflow-wrap: anywhere;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.queue-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

.watcher-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

.queue-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    font-size: 14px;
}

.queue-list {
    display: grid;
    gap: 7px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    max-height: 292px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.queue-item,
.watcher-item,
.queue-empty {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 12px;
}

.participant-profile {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.participant-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-strong);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.participant-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.participant-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watcher-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.watcher-item {
    min-width: 0;
    justify-content: flex-start;
    padding: 7px 8px;
}

.watcher-item .participant-avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
}

.watcher-list .queue-empty {
    grid-column: 1 / -1;
}

.queue-empty {
    justify-content: center;
    color: var(--text-muted);
}

.page-state {
    min-height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 0 100%;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    text-align: center;
}

.page-state-inner svg {
    width: 34px;
    height: 34px;
    margin-bottom: 9px;
    color: var(--primary);
}

.page-state-inner p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
}

.page-state-inner .text-button {
    margin-top: 12px;
}

.skeleton-card {
    position: relative;
    overflow: hidden;
    background: var(--surface-strong);
}

.skeleton-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    animation: shimmer 1.25s infinite;
    transform: translateX(-100%);
}

@keyframes shimmer {
    to { transform: translateX(100%); }
}

.fatal-banner {
    display: none;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(245, 108, 108, 0.48);
    border-radius: var(--radius);
    background: rgba(245, 108, 108, 0.09);
    color: #fab6b6;
    font-size: 13px;
    line-height: 1.6;
}

.fatal-banner.visible {
    display: block;
}

.ui-widget,
.ui-widget input,
.ui-widget button {
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

.ui-widget-overlay {
    background: #06080c;
    opacity: 0.78;
}

.ui-dialog {
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    color: var(--text);
}

.ui-dialog .ui-dialog-titlebar {
    padding: 14px 16px;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    border-radius: 0;
    background: var(--surface-strong);
    color: var(--text);
}

.ui-dialog .ui-dialog-titlebar-close {
    top: 50%;
    margin-top: -12px;
    border: 0;
    background: transparent;
}

.ui-dialog .ui-dialog-content {
    padding: 18px;
    background: var(--surface);
    color: var(--text-secondary);
}

.ui-dialog .ui-dialog-buttonpane {
    margin: 0;
    padding: 12px 16px;
    border: 0;
    border-top: 1px solid var(--border-soft);
    background: var(--surface);
}

.ui-dialog .ui-dialog-buttonpane button {
    min-height: 36px;
    margin: 0 0 0 8px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-strong);
    color: var(--text);
    cursor: pointer;
}

.ui-dialog .ui-dialog-buttonpane button.primary-dialog-button {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.dialog-form {
    display: grid;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 7px;
}

.form-field label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.form-field input {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
}

.form-field input:focus {
    border-color: var(--primary);
}

.form-error {
    display: none;
    margin: 0;
    padding: 9px 10px;
    border: 1px solid rgba(245, 108, 108, 0.4);
    border-radius: 6px;
    background: rgba(245, 108, 108, 0.09);
    color: #fab6b6;
    font-size: 12px;
}

.form-error.visible {
    display: block;
}

.dialog-message {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.75;
}

.result-content {
    text-align: center;
}

.result-content svg {
    width: 58px;
    height: 58px;
    color: var(--warning);
}

.result-content.lose svg {
    color: var(--text-muted);
}

.result-content h3 {
    margin: 12px 0 0;
    color: var(--text);
    font-size: 21px;
}

.result-content p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.result-content .result-sync-status {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--warning);
}

.result-content .result-sync-status.success {
    color: var(--success);
}

.result-content .result-sync-status.background {
    color: var(--text-secondary);
}

[hidden] {
    display: none !important;
}

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

    .machine-info-panel {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
        gap: 16px;
    }

    .machine-info-main {
        min-width: 0;
    }

    .queue-panel {
        margin-top: 0;
        padding-top: 0;
        padding-left: 16px;
        border-top: 0;
        border-left: 1px solid var(--border-soft);
    }
}

@media (max-width: 820px) {
    .app-shell {
        padding: 10px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .account-area {
        width: 100%;
        min-width: 0;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .stage-grid {
        grid-template-columns: 1fr;
    }

    .video-column {
        min-height: 500px;
    }

    .control-column {
        min-height: 560px;
    }

    .machine-info-panel {
        display: block;
    }

    .queue-panel {
        margin-top: 14px;
        padding-top: 14px;
        padding-left: 0;
        border-top: 1px solid var(--border-soft);
        border-left: 0;
    }
}

@media (max-width: 560px) {
    .topbar,
    .machine-section,
    .stage-panel,
    .machine-info-panel {
        box-shadow: none;
    }

    .topbar {
        padding: 14px;
    }

    .account-area {
        align-items: stretch;
    }

    .user-summary {
        order: -1;
        width: 100%;
    }

    .user-name {
        max-width: 230px;
    }

    .section-heading {
        align-items: flex-start;
    }

    .machine-strip-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .machine-strip-shell > .icon-button {
        display: none;
    }

    .machine-card {
        width: 86%;
        flex-basis: 86%;
    }

    .stage-panel {
        padding: 8px;
    }

    .stage-grid {
        min-height: 0;
        gap: 8px;
    }

    .video-column,
    .control-column {
        padding: 10px;
    }

    .video-column {
        min-height: 520px;
    }

    .control-column {
        min-height: 540px;
    }

    .control-surface {
        min-height: 350px;
        padding: 9px;
    }

    .auto-grab-config-row {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
    }

    .auto-grab-round-options {
        width: 100%;
    }

    .auto-grab-panel {
        padding: 14px;
    }

    .auto-grab-heading {
        gap: 10px;
    }

    .auto-grab-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .auto-grab-stats > div {
        padding: 9px 4px;
    }

    .control-header {
        flex-direction: column;
    }

    .control-heading-copy {
        width: 100%;
    }

    .control-title-row {
        justify-content: space-between;
    }

    .control-header .text-button,
    .control-header .primary-button,
    .control-header .danger-button {
        width: 100%;
    }

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

    .dpad {
        grid-template-columns: repeat(3, minmax(68px, 84px));
        gap: 7px;
        padding: 13px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .machine-info-head {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    .command-button,
    .command-button svg {
        transition-duration: 0.01ms;
    }

    .direction-button.is-holding::after,
    .direction-button.is-tap-feedback {
        animation: none;
    }
}
