/* 双机对战页面 */
.net-page [hidden] { display: none !important; }
body.net-page {
    min-height: 100dvh;
    background: radial-gradient(1200px 700px at 20% -10%, #1a1440 0%, transparent 60%),
                radial-gradient(900px 600px at 90% 0%, #08303a 0%, transparent 55%),
                var(--bg);
    display: flex;
    flex-direction: column;
}

.net-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 10, 18, 0.82);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.net-back {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.06);
    font-size: 18px;
}

.net-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .5px;
}

.net-title small {
    font-weight: 400;
    color: var(--muted);
    margin-left: 8px;
    font-size: 12px;
}

.net-ping {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--green);
    background: rgba(56, 230, 164, .08);
}

.net-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- 开始页 ---------- */
.net-warn {
    margin: 12px 14px 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 95, 126, .45);
    background: rgba(255, 95, 126, .12);
    color: #ffc2cf;
    font-size: 13px;
    line-height: 1.6;
}

.net-start {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 26px 18px calc(30px + env(safe-area-inset-bottom));
}

.net-start h1 {
    font-size: clamp(22px, 3.4vw, 34px);
    margin: 0 0 8px;
    letter-spacing: .5px;
}

.net-sub {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 22px;
    max-width: 720px;
}

.net-cols {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 16px;
}

.net-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.net-card h2 {
    margin: 0;
    font-size: 16px;
}

.net-games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow: auto;
    padding-right: 2px;
}

.net-game {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, .03);
    transition: .15s;
}

.net-game input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.net-game img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    background: #000;
}

.net-game span {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.3;
}

.net-game:has(input:checked) {
    border-color: var(--accent);
    background: rgba(124, 92, 255, .12);
}

.net-game:has(input:checked) span {
    color: var(--text);
}

.net-wide {
    width: 100%;
    padding: 13px 16px;
    font-size: 15px;
}

.net-note,
.net-hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

.net-code-input {
    width: 100%;
    text-align: center;
    font-size: 30px;
    letter-spacing: 10px;
    padding: 14px 8px;
    border-radius: 14px;
    border: 1px solid var(--line-strong);
    background: #04070f;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    outline: none;
}

.net-code-input:focus {
    border-color: var(--accent);
}

.net-foot {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
    margin: 18px 0 0;
    opacity: .85;
}

/* ---------- 房间视图 ---------- */
.net-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.net-roombar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    flex-wrap: wrap;
}

.net-code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.net-code-box b {
    font-size: 20px;
    letter-spacing: 4px;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

.net-copy {
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
}

.net-status {
    font-size: 13px;
    color: var(--muted);
    margin-right: auto;
}

.net-status.ok {
    color: var(--green);
}

.net-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #000;
    overflow: hidden;
}

.net-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.net-role {
    position: absolute;
    z-index: 12;
    top: calc(8px + env(safe-area-inset-top));
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    background: rgba(0, 0, 0, .55);
    border: 1px solid var(--line-strong);
    color: var(--text);
    pointer-events: none;
}

.net-role.p1 { left: 10px; }
.net-role.p2 { right: 10px; }

.net-wait {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 30px 20px;
    text-align: center;
}

.net-wait-code {
    font-size: clamp(46px, 13vw, 92px);
    letter-spacing: 12px;
    font-weight: 800;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 40px rgba(255, 209, 102, .25);
}

.net-wait p {
    color: var(--muted);
    max-width: 420px;
    line-height: 1.8;
    font-size: 14px;
    margin: 0;
}

.net-dots {
    display: flex;
    gap: 6px;
}

.net-dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: .35;
    animation: netPulse 1.2s infinite;
}

.net-dots i:nth-child(2) { animation-delay: .2s; }
.net-dots i:nth-child(3) { animation-delay: .4s; }

@keyframes netPulse {
    0%, 100% { opacity: .2; transform: scale(.85); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ---------- 加入方 ---------- */
.guest-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.guest-stage canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    pointer-events: none;
}

.net-connecting {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 24px;
    background: #04070f;
}

.net-connecting[hidden] { display: none; }

.net-connecting p { margin: 0; font-size: 15px; }

.net-connecting small {
    color: var(--muted);
    font-size: 12px;
    max-width: 360px;
    line-height: 1.7;
}

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(124, 92, 255, .25);
    border-top-color: var(--accent);
    animation: spin .9s linear infinite;
}

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

/* P2 虚拟按键（加入方） */
.net-p2pad {
    position: absolute;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(3, var(--sz));
    grid-template-rows: repeat(3, var(--sz));
    gap: 8px;
    --sz: clamp(42px, 10vmin, 70px);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.net-p2pad button {
    width: var(--sz);
    height: var(--sz);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(18, 22, 38, .62);
    color: #fff;
    font-size: calc(var(--sz) * .34);
    backdrop-filter: blur(6px);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    display: grid;
    place-items: center;
    padding: 0;
}

.net-p2pad button.on {
    background: rgba(124, 92, 255, .75);
    border-color: #b7a6ff;
    transform: scale(.96);
}

.net-p2pad .up { grid-column: 2; grid-row: 1; }
.net-p2pad .left { grid-column: 1; grid-row: 2; }
.net-p2pad .down { grid-column: 2; grid-row: 3; }
.net-p2pad .right { grid-column: 3; grid-row: 2; }
.net-p2pad .fire {
    grid-column: 3;
    grid-row: 1;
    border-radius: 50%;
    background: rgba(255, 95, 126, .5);
    font-size: calc(var(--sz) * .3);
}

@media (max-width: 760px) {
    .net-cols { grid-template-columns: 1fr; }
    .net-start { padding-top: 18px; }
    .net-title small { display: none; }
}
