/* ==========================================================================
   BlinkDuel Arena - Persistent Real-Time Duel Room Styles (Light Brand Theme)
   ========================================================================== */

:root {
    --bd-arena-max-width: 1480px;
    --bd-bg: #f5f7fa;
    --bd-surface: #ffffff;
    --bd-surface-glass: rgba(255, 255, 255, 0.94);
    --bd-border: #c0c6cb;
    --bd-border-light: #e4e8eb;
    --bd-border-focus: #0284c7;
    --bd-cyan: #0284c7;
    --bd-cyan-light: #e0f2fe;
    --bd-lime: #c8fa46;
    --bd-coral: #ff695e;
    --bd-green: #15803d;
    --bd-green-light: #dcfce7;
    --bd-red: #dc2626;
    --bd-text: #111315;
    --bd-text-muted: #515960;
    --bd-radius: 16px;
}

/* Room Lobby Container */
#room-lobby[data-entry="false"] {
    max-width: var(--bd-arena-max-width);
    margin: 0 auto;
    padding: 8px 0 32px;
    width: 100%;
}

/* Arena Header */
#room-lobby[data-entry="false"] .duel-room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: var(--bd-surface);
    border: 1px solid var(--bd-border);
    border-radius: 14px;
    margin-bottom: 12px;
    position: sticky;
    top: 8px;
    z-index: 25;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#room-lobby[data-entry="false"] .duel-room-header .eyebrow {
    color: var(--bd-cyan);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 2px 0;
}

#room-lobby[data-entry="false"] .duel-room-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--bd-text);
}

#room-lobby #leave-room {
    min-height: 38px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #fca5a5;
    color: var(--bd-red);
    background: #fef2f2;
    transition: all 0.15s ease;
}

#room-lobby #leave-room:hover {
    background: #fee2e2;
    border-color: var(--bd-red);
    color: #991b1b;
}

/* ==========================================================================
   Desktop Arena Layout (YOU | VS | OPPONENT)
   ========================================================================== */

#duel-media {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

#duel-media .duel-videos {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    position: relative;
    width: 100%;
}

/* Player Panels */
#duel-media .local-video,
#duel-media .remote-video {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    width: 100%;
    position: relative;
}

/* Player Header Bar */
#duel-media .arena-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bd-surface);
    border: 1px solid var(--bd-border);
    border-radius: 12px;
    min-height: 48px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

#duel-media .player-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#duel-media .player-tag {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

#duel-media .self-tag {
    background: var(--bd-cyan-light);
    color: var(--bd-cyan);
    border: 1px solid #bae6fd;
}

#duel-media .opponent-tag {
    background: #ffe4e6;
    color: #e11d48;
    border: 1px solid #fecdd3;
}

#duel-media .arena-player h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bd-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#duel-media .player-badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--bd-text-muted);
    border: 1px solid #cbd5e1;
    flex-shrink: 0;
}

#duel-media .arena-player:has([id$="-status"]:is(:contains("Ready"), [data-ready="true"])) .player-badge {
    background: var(--bd-green-light);
    color: var(--bd-green);
    border-color: #86efac;
}

/* Camera Stages */
#duel-media .camera-stage {
    width: 100%;
    max-width: none;
    aspect-ratio: 4 / 3;
    min-height: 380px;
    max-height: 560px;
    background: #101114;
    border: 2px solid var(--bd-border);
    border-radius: var(--bd-radius);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#duel-media .camera-stage.duel-frame {
    border: 6px solid transparent;
    background: linear-gradient(#101114, #101114) padding-box, var(--rim) border-box;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

#duel-media .local-video .camera-stage:not(.duel-frame) {
    border-color: #93c5fd;
}

#duel-media .remote-video .camera-stage:not(.duel-frame) {
    border-color: #fda4af;
}

#duel-media .camera-stage video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    border-radius: inherit;
}

#duel-media #camera-video {
    transform: scaleX(-1);
}

#duel-media #opponent-video {
    transform: none;
}

#duel-media .camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    padding: 24px;
}

#duel-media .placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

/* Simulated Opponent Avatar */
#duel-media .simulated-opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
}

#duel-media .simulated-opponent img {
    width: 96px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

#duel-media .simulated-opponent strong {
    font-size: 1rem;
    color: #f8fafc;
}

#duel-media #simulated-opponent-state {
    font-size: 0.85rem;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.18);
    padding: 3px 10px;
    border-radius: 12px;
}

/* ==========================================================================
   Center VS Column & Game State
   ========================================================================== */

#duel-media .duel-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 10;
}

#duel-media .versus-label {
    font-size: 1.85rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--bd-text);
    line-height: 1;
    margin-bottom: 6px;
    background: var(--bd-surface);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid var(--bd-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

#duel-media #room-state {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bd-text-muted);
    background: var(--bd-surface);
    border: 1px solid var(--bd-border);
    border-radius: 14px;
    padding: 4px 8px;
    margin: 0;
    max-width: 90px;
    overflow-wrap: break-word;
    text-align: center;
    line-height: 1.25;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Match Stage & Countdown / Result Overlays
   ========================================================================== */

#duel-media .match-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

/* Countdown Overlay: Dramatic, immersive, scale animation */
#room-lobby[data-arena="countdown"] #match-stage {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(245, 247, 250, 0.88);
    backdrop-filter: blur(8px);
    border-radius: var(--bd-radius);
    pointer-events: none;
    text-align: center;
}

#room-lobby[data-arena="countdown"] #match-label {
    font-size: clamp(4.5rem, 12vw, 8.5rem);
    font-weight: 900;
    color: var(--bd-green);
    text-shadow: 0 4px 24px rgba(21, 128, 61, 0.25);
    line-height: 1;
    animation: countdownScale 0.9s cubic-bezier(0.16, 1, 0.3, 1) infinite;
    letter-spacing: 0.02em;
}

@keyframes countdownScale {
    0% { transform: scale(1.18); opacity: 0.85; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.96); opacity: 0.92; }
}

#room-lobby:is([data-arena="countdown"], [data-arena="playing"]) .versus-label,
#room-lobby:is([data-arena="countdown"], [data-arena="playing"]) #room-state {
    display: none;
}

/* During Duel (Playing Mode) */
#room-lobby[data-arena="playing"] #match-stage {
    display: flex;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    pointer-events: none;
    background: var(--bd-surface);
    border: 1px solid var(--bd-border);
    border-radius: 20px;
    padding: 6px 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

#room-lobby[data-arena="playing"] #match-label {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--bd-green);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

#room-lobby[data-arena="playing"] #match-label::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bd-green);
    box-shadow: 0 0 10px rgba(21, 128, 61, 0.5);
    animation: livePulse 1.2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Face loss warning banner */
#duel-media #face-loss-warning {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 28;
    background: rgba(220, 38, 38, 0.95);
    color: #fff !important;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.35);
    pointer-events: none;
    white-space: nowrap;
}

/* Conceal setup and lobby controls during duel */
#room-lobby:is([data-arena="countdown"], [data-arena="playing"]) .room-overview,
#room-lobby:is([data-arena="countdown"], [data-arena="playing"]) #clock-status,
#room-lobby:is([data-arena="countdown"], [data-arena="playing"]) .room-actions {
    display: none !important;
}

#room-lobby[data-arena="playing"] #get-ready-drawer,
#room-lobby[data-arena="playing"] #camera-consent-details,
#room-lobby[data-arena="playing"] #readiness-panel,
#room-lobby[data-arena="playing"] #preparation-calibration,
#room-lobby[data-arena="playing"] #duel-diagnostics,
#room-lobby[data-arena="playing"] .ready-controls {
    display: none !important;
}

/* ==========================================================================
   Result Overlay (Over Arena, Cameras Visible Behind)
   ========================================================================== */

#room-lobby[data-arena="result"] .duel-videos {
    position: relative;
    min-height: 420px;
}

#room-lobby[data-arena="result"] #duel-media .duel-center {
    position: static;
    z-index: auto;
}

#room-lobby[data-arena="result"] .versus-label,
#room-lobby[data-arena="result"] #room-state {
    display: none;
}

#duel-media .duel-videos.result-active::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 50;
    border-radius: var(--bd-radius);
    pointer-events: none;
}

#room-lobby[data-arena="result"] #match-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    width: min(440px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(17, 19, 21, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 20px;
    padding: clamp(20px, 3.5vw, 32px) clamp(16px, 3vw, 24px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    animation: resultPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

@keyframes resultPopIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#duel-media #result-artwork {
    width: 88px;
    height: 88px;
    object-fit: contain;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.3));
    margin-bottom: 10px;
}

#duel-media #match-label {
    font-size: clamp(2rem, 5vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    overflow-wrap: break-word;
    text-align: center;
}

#duel-media #match-stage[data-outcome="win"] #match-label {
    color: var(--bd-lime);
    text-shadow: 0 0 28px rgba(200, 250, 70, 0.45);
}

#duel-media #match-stage[data-outcome="loss"] #match-label {
    color: #ff796a;
    background: #101114;
    padding: 4px 16px;
    border-radius: 8px;
    text-shadow: 0 0 36px rgba(239, 68, 68, 0.4);
}

#duel-media #match-stage[data-outcome="draw"] #match-label {
    color: var(--bd-cyan);
    text-shadow: 0 0 28px rgba(85, 205, 224, 0.45);
}

#duel-media #match-stage[data-outcome="pending"] #match-label {
    color: #f5f7fa;
}

#duel-media #match-detail {
    font-size: 1.05rem;
    color: #bac1c7;
    margin: 0 0 6px 0;
    max-width: 380px;
    text-align: center;
}

#duel-media #match-flair {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bd-lime);
    margin: 0 0 8px 0;
    text-align: center;
}

#duel-media #match-duration {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f5f7fa;
    font-variant-numeric: tabular-nums;
    margin: 0 0 14px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#duel-media .result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
}

#duel-media .result-actions .btn {
    min-height: 44px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.15s ease;
}

#duel-media #draw-rematch {
    background: var(--bd-lime);
    color: var(--bd-text);
    border: 1px solid var(--bd-text);
    box-shadow: 0 4px 14px rgba(200, 250, 70, 0.35);
}

#duel-media #draw-rematch:hover:not(:disabled) {
    background: #b5e834;
    transform: translateY(-1px);
}

#duel-media #share-result {
    background: rgba(85, 205, 224, 0.15);
    color: var(--bd-cyan);
    border: 1px solid var(--bd-cyan);
}

#duel-media #share-result:hover {
    background: var(--bd-cyan);
    color: #111315;
    transform: translateY(-1px);
}

#duel-media #new-duel {
    background: transparent;
    color: #f5f7fa;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#duel-media #new-duel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: translateY(-1px);
}

#duel-media #rematch-status {
    font-size: 0.88rem;
    color: #bac1c7;
    margin-top: 12px;
    max-width: 360px;
    text-align: center;
}

/* ==========================================================================
   Header Audio Controls
   ========================================================================== */
.duel-room-header .audio-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bd-surface);
    border: 1px solid var(--bd-border);
    border-radius: 20px;
    padding: 4px 10px;
    margin-left: auto;
}

.duel-room-header .audio-toggle {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}

.duel-room-header .audio-volume {
    width: 60px;
    height: 6px;
    accent-color: var(--bd-green);
    cursor: pointer;
}

/* ==========================================================================
   Result Share Layer (Modal / Bottom Sheet)
   ========================================================================== */
.result-share-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.result-share-card {
    background: #111315;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    color: #f5f7fa;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-share-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 12px;
}

.result-share-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #f5f7fa;
}

.result-share-close {
    font-size: 1.5rem;
    line-height: 1;
    color: #bac1c7;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}

.result-share-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.result-card-preview-wrap {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 12px;
    max-height: 240px;
    overflow: hidden;
}

.result-card-preview {
    max-height: 216px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.result-share-message {
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    color: #f5f7fa;
    margin: 0;
}

.result-share-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.result-share-quick-actions .btn {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 10px;
}

.result-share-social-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.result-share-social-grid .btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #f5f7fa;
    transition: all 0.15s ease;
}

.result-share-social-grid .btn-social:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.btn-whatsapp:hover { border-color: #25d366 !important; color: #25d366 !important; }
.btn-telegram:hover { border-color: #229ed9 !important; color: #229ed9 !important; }
.btn-x:hover { border-color: #ffffff !important; color: #ffffff !important; }
.btn-facebook:hover { border-color: #1877f2 !important; color: #1877f2 !important; }
.btn-reddit:hover { border-color: #ff4500 !important; color: #ff4500 !important; }

.result-qr {
    display: flex;
    justify-content: center;
    background: #ffffff;
    padding: 12px;
    border-radius: 12px;
    margin: 8px auto;
}

.result-share-feedback {
    min-height: 20px;
    font-size: 0.85rem;
    color: var(--bd-lime);
    text-align: center;
    margin: 0;
}

/* ==========================================================================
   Public Result Page Shell
   ========================================================================== */
.result-page-shell {
    min-height: 100vh;
    background: #111315;
    color: #f5f7fa;
    display: flex;
    flex-direction: column;
}

.result-page-container {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.result-page-header {
    text-align: center;
    margin-bottom: 32px;
}

.result-card-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-public-card {
    background: rgba(26, 29, 32, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 40px 28px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.result-public-card.result-badge-win { border-color: var(--bd-lime); }
.result-public-card.result-badge-loss { border-color: #ff695e; }
.result-public-card.result-badge-draw { border-color: var(--bd-cyan); }

.result-public-badge {
    display: inline-block;
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: 6px 24px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.result-badge-win .result-public-badge { background: var(--bd-lime); color: #111315; }
.result-badge-loss .result-public-badge { background: #ff695e; color: #111315; }
.result-badge-draw .result-public-badge { background: var(--bd-cyan); color: #111315; }

.result-public-headline {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 900;
    margin-bottom: 12px;
    color: #f5f7fa;
}

.result-public-time {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 18px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.result-public-message {
    font-size: 1.1rem;
    color: #bac1c7;
    margin-bottom: 32px;
    line-height: 1.5;
}

.result-public-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
}

.result-public-actions .btn {
    min-height: 52px;
    padding: 12px 28px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 14px;
}

.result-page-footer {
    text-align: center;
    margin-top: 40px;
    color: #717d88;
    font-size: 0.85rem;
}

.result-page-footer a {
    color: #bac1c7;
    text-decoration: underline;
}

/* ==========================================================================
   Mobile Arena Layout (FaceTime / PIP Mode <= 768px)
   ========================================================================== */

@media (max-width: 768px) {
    #duel-media .duel-videos {
        position: relative;
        width: 100%;
        height: 66vh;
        min-height: 460px;
        max-height: 680px;
        border-radius: var(--bd-radius);
        overflow: hidden;
        background: #101114;
        border: 2px solid var(--bd-border);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        display: block;
        margin: 6px 0 16px;
    }

    /* Opponent video is full background */
    #duel-media .remote-video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }

    #duel-media .remote-video .camera-stage {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: none;
        aspect-ratio: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #duel-media .remote-video .arena-player {
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 6;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(10px);
        padding: 6px 12px;
        border-radius: 20px;
        border: 1px solid var(--bd-border);
        min-height: auto;
        gap: 8px;
    }

    #duel-media .remote-video .arena-player h3 {
        font-size: 0.85rem;
    }

    /* Local "You" video is floating PIP in upper-right */
    #duel-media .local-video {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 124px;
        height: 168px;
        z-index: 15;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
        border: 2px solid #ffffff;
        background: #101114;
        transition: transform 0.2s ease;
    }

    #duel-media .local-video .camera-stage {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: none;
        aspect-ratio: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #duel-media .local-video .camera-stage.duel-frame {
        border: 3px solid transparent;
        background: linear-gradient(#101114, #101114) padding-box, var(--rim) border-box;
    }

    #duel-media .local-video video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
    }

    #duel-media .local-video .camera-placeholder {
        padding: 8px;
        gap: 4px;
        font-size: 0.72rem;
    }

    #duel-media .local-video .placeholder-icon {
        width: 40px;
        height: 40px;
    }

    #duel-media .local-video .placeholder-icon svg {
        width: 20px;
        height: 20px;
    }

    #duel-media .local-video .arena-player {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 4;
        background: linear-gradient(transparent, rgba(17, 19, 21, 0.85));
        padding: 4px 6px;
        border-radius: 0;
        border: 0;
        min-height: auto;
    }

    #duel-media .local-video .player-tag {
        font-size: 0.65rem;
        padding: 1px 4px;
    }

    #duel-media .local-video .arena-player h3 {
        font-size: 0.75rem;
        color: #ffffff;
    }

    #duel-media .local-video .player-badge {
        display: none;
    }

    /* Center overlays */
    #duel-media .duel-center {
        position: absolute;
        inset: 0;
        z-index: 8;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }

    /* Hide center VS badge and state when the invitation card is active on mobile */
    #duel-media.is-inviting .duel-center .versus-label,
    #duel-media.is-inviting .duel-center #room-state,
    #duel-media:has(#room-invitation:not([hidden])) .duel-center .versus-label,
    #duel-media:has(#room-invitation:not([hidden])) .duel-center #room-state {
        display: none;
    }

    #duel-media .duel-center .versus-label {
        font-size: 2.2rem;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(8px);
        padding: 4px 18px;
        border-radius: 24px;
        border: 1px solid var(--bd-border);
    }

    #duel-media .duel-center #room-state {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        margin-top: 8px;
        max-width: 180px;
    }

    #duel-media #match-stage {
        pointer-events: auto;
    }

    #room-lobby[data-arena="result"] #match-stage {
        width: min(380px, calc(100% - 24px));
        max-height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
        padding: 20px 16px;
    }

    .result-share-layer {
        align-items: flex-end;
        padding: 0;
    }

    .result-share-card {
        border-radius: 20px 20px 0 0;
        max-height: calc(88vh - env(safe-area-inset-bottom, 0px));
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
}

/* Reduced Motion & Forced Colors */
@media (prefers-reduced-motion: reduce) {
    #duel-media * {
        animation: none !important;
        transition: none !important;
    }
}

@media (forced-colors: active) {
    #duel-media .arena-player,
    #duel-media .camera-stage {
        border-color: CanvasText;
    }
}

@media (max-height: 500px) { #room-lobby[data-entry="false"] .duel-room-header { position: static; } }

/* Game Addiction & Engagement Upgrades */
.streak-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 105, 0, 0.2);
    color: #ff7700;
    border: 1px solid rgba(255, 105, 0, 0.4);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
    animation: streak-glow 2s infinite alternate ease-in-out;
}
@keyframes streak-glow {
    0% { box-shadow: 0 0 4px rgba(255, 105, 0, 0.3); }
    100% { box-shadow: 0 0 12px rgba(255, 105, 0, 0.7); }
}
.match-streak-banner {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffa500;
    background: rgba(255, 165, 0, 0.15);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 8px;
    padding: 6px 14px;
    margin: 8px 0;
}

/* Escalating Tension Vignette */
.tension-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 5;
}
.tension-low #tension-vignette {
    opacity: 0.35;
    box-shadow: inset 0 0 60px rgba(255, 60, 60, 0.4);
    animation: tension-pulse 1s infinite alternate ease-in-out;
}
.tension-med #tension-vignette {
    opacity: 0.65;
    box-shadow: inset 0 0 90px rgba(255, 40, 40, 0.6);
    animation: tension-pulse 0.65s infinite alternate ease-in-out;
}
.tension-high #tension-vignette {
    opacity: 0.95;
    box-shadow: inset 0 0 120px rgba(255, 0, 0, 0.85);
    animation: tension-pulse 0.44s infinite alternate ease-in-out;
}
@keyframes tension-pulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.008); filter: brightness(1.2); }
}

/* Distraction Taunts & Floating Emojis */
.taunt-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.taunt-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #a0aec0;
    margin-right: 2px;
}
.taunt-btn {
    padding: 3px 10px;
    font-size: 0.8rem;
    border-radius: 12px;
}
.taunt-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}
.floating-emoji {
    font-size: 4.5rem;
    animation: float-taunt 1.6s forwards cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes float-taunt {
    0% { opacity: 0; transform: translateY(40px) scale(0.4); }
    20% { opacity: 1; transform: translateY(-10px) scale(1.2); }
    70% { opacity: 1; transform: translateY(-30px) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) scale(0.8); }
}

/* Reaction Photo Preview */
.result-reaction-preview {
    margin: 8px auto;
    text-align: center;
}
.reaction-thumb {
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    display: block;
    margin: 0 auto;
    object-fit: cover;
}
.reaction-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

/* Quick Match Button */
.quick-match-btn {
    font-weight: 700;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
    animation: quick-pulse 2.5s infinite alternate ease-in-out;
}
@keyframes quick-pulse {
    0% { box-shadow: 0 0 6px rgba(255, 193, 7, 0.2); }
    100% { box-shadow: 0 0 16px rgba(255, 193, 7, 0.6); }
}
.lobby-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Solo Endurance Trainer Styling */
.endurance-container { max-width: 1050px; margin: 0 auto; padding: 24px 16px; }
.endurance-header { text-align: center; margin-bottom: 24px; }
.endurance-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; }
@media (max-width: 840px) { .endurance-grid { grid-template-columns: 1fr; } }
.endurance-stage-card { background: #13171c; border-radius: 16px; padding: 20px; text-align: center; border: 1px solid rgba(255,255,255,0.08); }
.endurance-camera { width: 100%; max-width: 540px; height: 380px; margin: 0 auto; border-radius: 12px; overflow: hidden; position: relative; background: #000; }
.stopwatch-display { margin: 16px 0; }
.timer-value { font-family: 'Courier New', monospace; font-size: 3.5rem; font-weight: 900; color: #c8fa46; letter-spacing: 2px; }
.current-tier { font-size: 1.25rem; font-weight: 700; color: #fff; margin-top: 4px; }
.endurance-countdown-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; font-size: 5rem; font-weight: 900; color: #c8fa46; z-index: 10; }
.tier-list { list-style: none; padding: 0; margin: 0; }
.tier-item { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; background: rgba(255,255,255,0.03); }
.tier-item.tier-active { background: rgba(200, 250, 70, 0.15); border: 1px solid #c8fa46; font-weight: 700; }
.stat-card { background: #13171c; border-radius: 12px; padding: 16px; margin-bottom: 16px; border: 1px solid rgba(255,255,255,0.08); }
.best-time-display { font-size: 2.2rem; font-weight: 800; color: #ffd700; font-family: monospace; }
.endurance-dialog { border: none; border-radius: 16px; background: #1a1e24; color: #fff; padding: 28px; max-width: 440px; width: 90%; text-align: center; box-shadow: 0 12px 32px rgba(0,0,0,0.8); }
.endurance-dialog::backdrop { background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.dialog-time { font-size: 3rem; font-weight: 900; color: #c8fa46; font-family: monospace; margin: 12px 0; }
.dialog-tier { font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; }
.pb-alert { font-size: 1.1rem; font-weight: 800; color: #ffd700; margin: 12px 0; }
.dialog-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

