@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

.multiplayer-screen {
    position: relative;
    flex-direction: column;
    padding: 0;
    gap: 1rem;
}

.multiplayer-screen .screen-title-bar {
    padding: 1.5rem;
    background: transparent;
    border-bottom: none;
    gap: 1rem;
}

.multiplayer-screen .toolbar-status {
    flex: 1;
    text-align: center;
    font-weight: 600;
}

.mode-pill {
    font-family: 'Space Grotesk', 'Sora', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: linear-gradient(120deg, rgba(32, 223, 190, 0.2), rgba(20, 20, 35, 0.9));
}

.multiplayer-warning {
    background: rgba(255, 152, 0, 0.15);
    border: 1px solid rgba(255, 152, 0, 0.5);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.95rem;
}

.multiplayer-warning .warning-actions {
    margin-top: 0.5rem;
}

.multiplayer-arenas {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    flex: 1;
}

.player-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.player-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.player-panel .device-status {
    font-size: 0.8rem;
    opacity: 0.8;
}

.player-panel .score-strip {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-panel .score-strip .stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.player-panel .score-strip .progress-bar {
    height: 6px;
}

.player-panel .game-area {
    min-height: 280px;
    position: relative;
}

.player-panel.player-two .game-area,
.player-panel.player-two header,
.player-panel.player-two .score-strip {
    transform: rotate(180deg);
}

.multiplayer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.multiplayer-overlay.hidden {
    display: none;
}

.multiplayer-overlay .result-card {
    background: rgba(20, 20, 20, 0.9);
    padding: 1.5rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.multiplayer-overlay .result-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.multiplayer-overlay .result-body {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.multiplayer-overlay .result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

@media (min-width: 900px) {
    .multiplayer-arenas {
        grid-template-columns: repeat(2, 1fr);
    }

    .player-panel .game-area {
        min-height: 360px;
    }
}

/* Multiplayer setup screen */
.multiplayer-setup-screen {
    padding: 2rem clamp(1.25rem, 4vw, 2.5rem);
    font-family: 'Space Grotesk', 'Sora', sans-serif;
    background: radial-gradient(circle at top left, rgba(34, 226, 182, 0.18), transparent 60%),
        linear-gradient(135deg, rgba(5, 10, 25, 0.9), rgba(11, 4, 31, 0.9));
}

.setup-shell {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setup-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
}

.setup-title-block h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.6rem);
    letter-spacing: -0.02em;
}

.setup-title-block .setup-subtitle {
    margin: 0.25rem 0 0;
    color: rgba(255, 255, 255, 0.75);
}

.eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 0.25rem;
}

.mode-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.multiplayer-mode-card {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.5rem;
    background: var(--surface-color);
    color: var(--text-color);
    text-align: left;
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.multiplayer-mode-card .card-background {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 55%);
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.multiplayer-mode-card .card-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.multiplayer-mode-card .card-pill {
    align-self: flex-start;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.multiplayer-mode-card h2 {
    margin: 0;
    font-size: 1.4rem;
}

.multiplayer-mode-card ul {
    padding-left: 1.2rem;
    margin: 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
}

.multiplayer-mode-card li + li {
    margin-top: 0.35rem;
}

.multiplayer-mode-card .card-icon {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.5;
}

.multiplayer-mode-card.selected {
    transform: translateY(-6px);
    border-color: rgba(48, 246, 198, 0.9);
    box-shadow: 0 25px 60px rgba(48, 246, 198, 0.25);
}

.multiplayer-mode-card.selected .card-background {
    opacity: 0.65;
}

.setup-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hardware-note {
    padding: 0.75rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.footer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dual-tip {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.75);
    border-left: 3px solid rgba(48, 246, 198, 0.7);
    padding-left: 0.75rem;
}

.footer-actions .btn[disabled] {
    background: rgba(255, 255, 255, 0.15);
    border-color: transparent;
    color: rgba(255, 255, 255, 0.4);
}

@media (min-width: 768px) {
    .footer-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .footer-actions .btn {
        width: auto;
    }
}

/* ============================================
   NEW MULTIPLAYER SETUP SCREEN (STAGE SELECTION STYLE)
   ============================================ */

.multiplayer-setup-screen {
    display: flex;
    flex-direction: column;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.multiplayer-setup-screen .screen-title-bar {
    padding: 10px 20px 0px 20px;
    background: transparent;
    border-bottom: none;
    z-index: 10;
}

.multiplayer-setup-screen .screen-scroll-content {
    padding: 0px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    z-index: 1;
}

.multiplayer-setup-screen.hidden {
    display: none;
}

.multiplayer-setup-header {
    padding: 20px 0;
    text-align: center;
    z-index: 1;
}

.setup-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 1.5rem;
}

[data-theme="light"] .setup-subtitle {
    color: rgba(30, 30, 40, 0.7);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .setup-subtitle {
        color: rgba(30, 30, 40, 0.7);
    }
}

.player-count-selector {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.player-count-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-count-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .player-count-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .player-count-btn:hover {
        background: rgba(102, 126, 234, 0.1);
        border-color: rgba(102, 126, 234, 0.3);
    }
}

.player-count-btn.selected {
    background: linear-gradient(120deg, rgba(48, 246, 198, 0.25), rgba(147, 51, 234, 0.25));
    border-color: rgba(48, 246, 198, 0.6);
    color: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .player-count-btn.selected {
    background: linear-gradient(120deg, rgba(48, 246, 198, 0.3), rgba(147, 51, 234, 0.3));
    border-color: rgba(48, 246, 198, 0.8);
    color: rgba(30, 30, 40, 0.95);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .player-count-btn.selected {
        background: linear-gradient(120deg, rgba(48, 246, 198, 0.3), rgba(147, 51, 234, 0.3));
        border-color: rgba(48, 246, 198, 0.8);
        color: rgba(30, 30, 40, 0.95);
    }
}

.multiplayer-setup-screen .stages-grid {
    margin: auto 0;
    min-height: 0;
    z-index: 1;
}

.empty-stages-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
}

.stage-tile.selected {
    border-color: #30f6c6;
    background: linear-gradient(135deg, rgba(48, 246, 198, 0.25) 0%, rgba(147, 51, 234, 0.15) 100%);
    box-shadow: 
        0 0 0 3px rgba(48, 246, 198, 0.5),
        0 4px 20px rgba(48, 246, 198, 0.3);
    transform: translateY(-4px) scale(1.02);
}

/* ============================================
   NEW MULTIPLAYER SPLIT-SCREEN LAYOUT
   ============================================ */

.multiplayer-screen .multiplayer-global-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, rgba(20, 20, 35, 0.95) 0%, rgba(20, 20, 35, 0) 100%);
}

.multiplayer-screen .global-status {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.player-divisions {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.player-divisions[data-player-count="2"] {
    flex-direction: column;
}

.player-divisions[data-player-count="3"] {
    flex-direction: column;
}

/* Horizontal layout on landscape */
@media (orientation: landscape) {
    .player-divisions[data-player-count="2"] {
        flex-direction: row;
    }
    
    .player-divisions[data-player-count="3"] {
        flex-direction: row;
    }
}

.player-division {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.player-division.hidden {
    display: none;
}

/* Player content wrapper - this is what rotates */
.player-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* For 90/270 rotations: swap width and height, then rotate */
.player-division.rotated-90 .player-content,
.player-division.rotated-270 .player-content {
    /* Swap dimensions: width becomes height, height becomes width */
    width: var(--division-height);
    height: var(--division-width);
    position: absolute;
    top: 50%;
    left: 50%;
}

.player-division.rotated-90 .player-content {
    transform: translate(-50%, -50%) rotate(90deg);
}

.player-division.rotated-180 .player-content {
    transform-origin: center center;
    transform: rotate(180deg);
}

.player-division.rotated-270 .player-content {
    transform: translate(-50%, -50%) rotate(270deg);
}

/* Score strip within player division */
.player-division .scorestrip {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95), rgba(118, 75, 162, 0.95));
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.player-division .scorestrip .scorestrip-row-1 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
}

.player-division .scorestrip .scorestrip-row-2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0 0.75rem 0.5rem 0.75rem;
}

.player-division .scorestrip .back-btn,
.player-division .scorestrip .rotation-toggle {
    position: static;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.player-division .scorestrip .back-btn:hover,
.player-division .scorestrip .rotation-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.player-division .scorestrip .player-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    flex: 1;
}

/* Pill styling for multiplayer score strip */
.player-division .scorestrip .score-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.85rem;
    white-space: nowrap;
}

.player-division .scorestrip .stage-pill {
    background: rgba(255, 255, 255, 0.12);
}

.player-division .scorestrip .score-display-pill {
    background: rgba(102, 255, 163, 0.15);
    border-color: rgba(102, 255, 163, 0.3);
}

.player-division .scorestrip .pill-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
    font-weight: 600;
}

.player-division .scorestrip .pill-value {
    font-weight: 700;
    font-size: 0.9rem;
}

.player-division .scorestrip .reaction-timer {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    margin-right: 0.5rem;
}

/* Progress bar container - now outside scorestrip */
.player-division > .progress-bar-container {
    height: 6px;
    background: rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.player-division > .progress-bar-container .progress-bar {
    height: 100%;
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.player-division > .progress-bar-container .hit-progress-bar {
    background: linear-gradient(90deg, #00BCD4, #0097A7);
    width: 0%;
    z-index: 1;
}

[data-theme="dark"] .player-division > .progress-bar-container .hit-progress-bar {
    background: linear-gradient(90deg, #00ACC1, #00838F);
}

.player-division > .progress-bar-container .score-progress-bar {
    background: linear-gradient(90deg, #1565C0, #0D47A1);
    width: 0%;
}

[data-theme="dark"] .player-division > .progress-bar-container .score-progress-bar {
    background: linear-gradient(90deg, #1976D2, #0D47A1);
}

/* Old player-header styles removed - now using scorestrip-row layout */

.player-division .game-area {
    flex: 1;
    position: relative;
    margin: 0;
    overflow: hidden;
    min-height: 0; /* Allow flex shrink */
}

/* Rotation toggle now inline in scorestrip - see .scorestrip .rotation-toggle */

/* Multiplayer end transition overlay - uses player-result theme-aware background */
.player-division .end-transition-overlay {
    background: rgba(240, 240, 250, 1);
}

[data-theme="dark"] .player-division .end-transition-overlay {
    background: rgba(20, 20, 35, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .player-division .end-transition-overlay {
        background: rgba(20, 20, 35, 1);
    }
}

/* Individual player results (shown within each player's division) */
.player-result {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(240, 240, 250, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(15px);
}

[data-theme="dark"] .player-result {
    background: rgba(20, 20, 35, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .player-result {
        background: rgba(20, 20, 35, 1);
    }
}

.player-result.hidden {
    display: none;
}

.player-result .result-content {
    text-align: center;
    padding: 2rem;
    overflow-y: auto;
    max-height: 100%;
}

.player-result .result-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: rgba(30, 30, 40, 0.95);
    margin-bottom: 1rem;
}

[data-theme="dark"] .player-result .result-title {
    color: rgba(255, 255, 255, 0.95);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .player-result .result-title {
        color: rgba(255, 255, 255, 0.95);
    }
}

.player-result .result-winner-status {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    display: inline-block;
}

.player-result .result-winner-status.winner {
    background: linear-gradient(120deg, rgba(48, 246, 198, 0.2), rgba(147, 51, 234, 0.2));
    border: 2px solid rgba(48, 246, 198, 0.6);
    color: #30f6c6;
}

.player-result .result-winner-status.tie {
    background: rgba(255, 193, 7, 0.2);
    border: 2px solid rgba(255, 193, 7, 0.6);
    color: #ffc107;
}

.player-result .result-winner-status.loser {
    background: rgba(100, 100, 120, 0.15);
    border: 2px solid rgba(100, 100, 120, 0.4);
    color: rgba(60, 60, 80, 0.8);
}

[data-theme="dark"] .player-result .result-winner-status.loser {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .player-result .result-winner-status.loser {
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.3);
        color: rgba(255, 255, 255, 0.7);
    }
}

.player-result .result-score {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(120deg, #30f6c6, #9333ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.player-result .result-snap-time {
    font-size: 1rem;
    color: rgba(60, 60, 80, 0.7);
}

[data-theme="dark"] .player-result .result-snap-time {
    color: rgba(255, 255, 255, 0.7);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .player-result .result-snap-time {
        color: rgba(255, 255, 255, 0.7);
    }
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.result-actions .btn {
    min-width: 120px;
}
