@font-face {
    font-family: 'BpmfHuninn';
    src: url('../assets/fonts/BpmfHuninn-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-dark: #0f0f1a;
    --bg-panel: rgba(255, 255, 255, 0.05);

    /* Neon Colors */
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-green: #00ff9d;
    --neon-yellow: #ffbd00;

    /* Team Colors */
    --team-left: var(--neon-blue);
    --team-right: var(--neon-pink);

    --font-main: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    /* Prevent browser zooming/scrolling */
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    background-color: #000;
    color: #fff;
    font-family: var(--font-main);
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Prevent bouncy scroll on iOS */
}

#app-container {
    width: 1920px;
    height: 1080px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    background-color: #000;
    overflow: hidden;
}

#game-screen,
#rule-overlay {
    font-family: 'BpmfHuninn', var(--font-main);
}

/* --- Typography --- */
h1,
h2,
h3 {
    margin: 0;
    text-shadow: 0 0 10px currentColor;
}

.text-neon-blue {
    color: var(--neon-blue);
}

.text-neon-pink {
    color: var(--neon-pink);
}

/* --- Components --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    z-index: 10;
    transition: opacity 0.5s, transform 0.5s;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.1);
    z-index: -1;
}

.btn-primary {
    padding: 15px 40px;
    font-size: 1.5rem;
    border: 2px solid var(--neon-blue);
    background: rgba(0, 243, 255, 0.1);
    color: var(--neon-blue);
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary:active {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 30px var(--neon-blue);
}

.btn-danger {
    border-color: var(--neon-pink);
    color: var(--neon-pink);
    background: rgba(255, 0, 255, 0.1);
}

.btn-danger:active {
    background: var(--neon-pink);
    color: #000;
}

/* --- Login Screen --- */
#login-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
    overflow: hidden;
}

.main-title-container {
    position: relative;
    width: 100%;
    text-align: center;
    margin-bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.center-glow-line {
    position: absolute;
    width: 4px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(to bottom,
            rgba(0, 243, 255, 0) 0%,
            rgba(0, 243, 255, 0.8) 40%,
            rgba(255, 0, 255, 0.8) 60%,
            rgba(255, 0, 255, 0) 100%);
    box-shadow: -1px 0 8px rgba(0, 243, 255, 0.5), 1px 0 8px rgba(255, 0, 255, 0.5);
    z-index: 0;
}

.main-title {
    font-size: 12rem;
    font-weight: 800;
    letter-spacing: 25px;
    z-index: 10;
    line-height: 1;
    position: relative;
}

.title-blue {
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue);
}

.title-pink {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
}

.title-split {
    position: relative;
    color: #fff;
    text-shadow: -15px 0 30px var(--neon-blue), 15px 0 30px var(--neon-pink);
}

.title-split::after {
    content: '';
    position: absolute;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 140%;
    background: radial-gradient(circle, #fff 0%, transparent 70%);
    filter: blur(10px);
    z-index: -1;
}

.subtitle-row {
    display: flex;
    width: 1250px;
    justify-content: space-between;
    margin-top: 30px;
    z-index: 10;
}

.subtitle-left,
.subtitle-right {
    font-size: 2.5rem;
    letter-spacing: 10px;
    color: #888;
    text-transform: uppercase;
    font-weight: 300;
}

.vs-logo {
    margin-top: 60px;
    font-size: 6rem;
    font-weight: 900;
    font-style: italic;
    font-family: 'Arial Black', sans-serif;
    position: relative;
    z-index: 10;
    background: linear-gradient(135deg, #fff 50%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

.login-panel {
    width: 900px;
    padding: 60px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 1.5rem;
    color: #888;
    text-transform: uppercase;
}

.team-inputs {
    display: flex;
    gap: 20px;
}

.team-inputs.single-player {
    justify-content: center;
}

.team-inputs.single-player .input-group {
    flex: 0 1 500px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.team-inputs.single-player input[type="text"] {
    text-align: center;
    width: 80% !important;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #333;
    padding: 25px;
    color: white;
    font-size: 2rem;
    border-radius: 8px;
    width: 100%;
}

input[type="text"]::placeholder {
    color: #888;
    opacity: 0.7;
}

#enter-btn {
    padding: 25px;
    font-size: 3rem;
    letter-spacing: 5px;
    margin-top: 30px !important;
}

input[type="text"]:focus {
    border-color: var(--neon-blue);
    outline: none;
}

.match-settings {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.setting-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #555;
    background: transparent;
    color: #888;
    cursor: pointer;
}

.setting-btn.active {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.2);
}

/* --- Dashboard --- */
#dashboard-screen {
    padding: 40px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.score-board {
    display: flex;
    align-items: center;
    gap: 40px;
    font-size: 3rem;
    font-weight: bold;
}

.score-left {
    color: var(--team-left);
    text-shadow: 0 0 20px var(--team-left);
}

.score-right {
    color: var(--team-right);
    text-shadow: 0 0 20px var(--team-right);
}

.game-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    align-content: start;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 20px 10px 40px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 243, 255, 0.45) rgba(255, 255, 255, 0.05);
}

.game-grid,
.game-grid * {
    touch-action: pan-y;
}

.game-grid::-webkit-scrollbar {
    width: 8px;
}

.game-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
}

.game-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 243, 255, 0.45);
    border-radius: 999px;
}

.game-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 243, 255, 0.75);
}

.game-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    height: 400px;
}

.game-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-5px);
    border-color: var(--neon-blue);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.1);
}

.game-card h3 {
    margin-top: 5px;
    font-size: 3rem;
    text-align: center;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
}

.game-card p {
    font-size: 1.6rem !important;
}

.game-icon {
    font-size: 11rem;
    margin-bottom: 5px;
    height: 13rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-icon img {
    width: 13rem !important;
    height: 13rem !important;
    object-fit: contain;
}

/* --- Game Container (Split Screen) --- */
#game-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
}

.player-zone {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 4px solid rgba(255, 255, 255, 0.9);
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 5;
    overflow: hidden;
}

.player-zone:last-child {
    border-right: none;
    box-shadow: none;
    z-index: 1;
}

#game-wrapper.single-player #zone-right {
    display: none;
}

#game-wrapper.single-player #zone-left {
    flex: 1;
    border-right: none;
}

/* Single player timer adjustment to avoid center overlap */
#game-screen.single-player .timer-float {
    left: auto;
    right: 20px;
    transform: none;
}

/* Game Specific Styles */

#game-wrapper[data-game="stroop"] .game-content {
    justify-content: flex-start;
    /* Align to top */
    padding-top: 50px;
    /* Space from top */
    padding-left: 20px;
    padding-right: 20px;
}

#game-wrapper[data-game="path"] svg {
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
}

#game-wrapper[data-game="path"]:not(.single-player) svg {
    width: 46% !important;
    height: 70% !important;
}

#game-wrapper[data-game="path"].single-player svg {
    width: 44% !important;
    height: 75% !important;
}

.zone-header {
    position: absolute;
    top: 10px;
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    z-index: 100;
    pointer-events: none;
    /* Allow clicks to pass through to game */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

#zone-left .zone-header {
    left: 0;
}

#zone-right .zone-header {
    right: 0;
}


/* --- Common Game UI --- */
.game-content {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.timer-float {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    border: 1px solid #333;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 2rem;
    z-index: 100;
}

#rule-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1 !important;
    /* Override inline style */
}

/* --- Victory Screen --- */
#victory-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: #000;
    z-index: 99999 !important;
}

.winner-announce {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
        text-shadow: 0 0 20px currentColor;
    }

    to {
        transform: scale(1.05);
        text-shadow: 0 0 50px currentColor;
    }
}

/* --- Utilities --- */
.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20000;
    opacity: 0.8;
    padding: 5px 10px;
    font-size: 1.8rem;
    border-radius: 8px;
}

.back-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* --- Orientation Lock --- */
#orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 100000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

#orientation-overlay .phone-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: rotate-phone 2s infinite ease-in-out;
}

@keyframes rotate-phone {
    0% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }

    100% {
        transform: rotate(90deg);
    }
}

@media screen and (orientation: portrait) {
    #orientation-overlay {
        display: flex;
    }
}

/* --- Block Counter Game --- */
.block-game-area {
    font-family: 'Courier New', monospace;
}

.iso-scene {
    position: relative;
    /* transition: transform 0.5s; Handles rotation smoothly */
}

/* 3D Blocks */
.block {
    position: absolute;
    width: 50px;
    height: 50px;
}

.face {
    position: absolute;
    width: 50px;
    height: 50px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.3s, opacity 0.3s;
}

/* Colors & Shading */
/* Colors & Shading - 2.5D Isometric Optimization */
/* Light Source: Top Left */

/* TOP Face - Lightest */
.face-top {
    transform: rotateX(0deg) translateZ(50px);
    background: var(--team-left);
    /* Dynamic team color potentially, but using base for now */
    filter: brightness(1.3);
    /* Brightest */
    width: 50px;
    height: 50px;
}

/* RIGHT Face - Medium (Side) */
.face-right {
    transform: rotateY(90deg) translateZ(25px) translateX(25px);
    background: var(--team-left);
    filter: brightness(0.9);
    /* Medium Shadow */
    width: 50px;
    height: 50px;
}

/* FRONT Face - Darkest (Front/Side) */
.face-front {
    transform: rotateX(-90deg) translateZ(25px) translateY(25px);
    background: var(--team-left);
    filter: brightness(0.6);
    /* Dark Shadow */
    width: 50px;
    height: 50px;
}

/* Left/Back/Bottom are usually hidden or same as Right/Front reversed */
.face-left {
    transform: rotateY(-90deg) translateZ(25px) translateX(-25px);
    background: var(--team-left);
    filter: brightness(0.9);
    width: 50px;
    height: 50px;
}

.face-back {
    transform: rotateX(90deg) translateZ(25px) translateY(-25px);
    background: var(--team-left);
    filter: brightness(0.6);
    width: 50px;
    height: 50px;
}

.face-bottom {
    transform: rotateX(180deg) translateZ(0px);
    /* At base */
    background: #000;
    width: 50px;
    height: 50px;
}

/* We don't really see bottom/back usually in this angle */


/* X-Ray Mode */
.iso-scene.xray-mode .face {
    opacity: 0.3;
    border: 1px solid rgba(0, 243, 255, 0.8);
    background: rgba(0, 243, 255, 0.1);
}

.iso-scene.xray-mode .face-top {
    background: rgba(0, 243, 255, 0.2);
}

/* Keypad Frozen State */
.input-area.frozen .num-btn {
    background: #555;
    color: #888;
    border-color: #555;
    cursor: not-allowed;
}

/* Input Display */
/* --- Loader Overlay --- */
#loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

#loader.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

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

.ready-text,
.go-text,
.round-winner-text {
    font-size: 8rem;
    font-weight: bold;
    color: var(--neon-blue);
    text-shadow: 0 0 20px var(--neon-blue), 0 0 50px var(--neon-blue);
    letter-spacing: 15px;
    animation: pulse-loader 0.8s infinite alternate;
}

.ready-text.hidden,
.go-text.hidden,
.round-winner-text.hidden {
    display: none !important;
}

.go-text {
    color: #2ed573;
    text-shadow: 0 0 20px #2ed573, 0 0 50px #2ed573;
}

@keyframes pulse-loader {
    from {
        transform: scale(0.9);
        opacity: 0.7;
    }

    to {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Symmetry Game Axis Line */
.symmetry-grid {
    position: relative;
}

.symmetry-grid::after {
    content: '';
    position: absolute;
    background: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 0;
}

.symmetry-grid[data-axis="v"]::after {
    opacity: 1;
    width: 4px;
    height: 100%;
    left: calc(50% - 2px);
    top: 0;
}

.symmetry-grid[data-axis="h"]::after {
    opacity: 1;
    width: 100%;
    height: 4px;
    left: 0;
    top: calc(50% - 2px);
}

/* --- Shared Camera Stage (雙人鏡頭模式：單一畫面加寬、中央中線) --- */
.camera-game-active {
    position: relative !important;
}

.camera-game-active .player-zone {
    z-index: 20 !important;
    background: transparent !important;
    pointer-events: none;
    border-right: none !important;
    box-shadow: none !important;
}

.camera-game-active .game-content {
    background: transparent !important;
}

.camera-game-active .player-zone * {
    pointer-events: auto;
}

#shared-camera-stage {
    position: absolute;
    top: 14px;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 20px);
    max-width: 1600px;
    height: calc(100% - 26px);
    background: #090914;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.6);
    z-index: 2;
    display: flex;
}

#shared-camera-stage.single-player {
    max-width: 1000px;
}

.shared-cam-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.92;
    transition: transform 0.2s ease;
}

.shared-cam-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5;
    pointer-events: none;
}

/* 中央發光中線 */
.shared-cam-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.95) 25%, rgba(255, 255, 255, 0.95) 75%, rgba(255, 255, 255, 0.3) 100%);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.8), 0 0 25px rgba(0, 243, 255, 0.5);
    z-index: 15;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.shared-cam-divider-badge {
    position: absolute;
    top: 10px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
    display: flex;
    gap: 8px;
    z-index: 16;
}

.badge-tag-left {
    color: #00f3ff;
}

.badge-tag-right {
    color: #ff00ff;
}

/* 左右槽 (Slots) */
.shared-cam-slot {
    position: relative;
    flex: 1;
    height: 100%;
    z-index: 12;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.shared-cam-slot > * {
    pointer-events: auto;
}

/* 控制按鈕列 */
.shared-cam-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

.cam-btn-pill {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cam-btn-pill:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: #fff;
}

.badge-tag-left,
.badge-tag-right {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* --- Line Icons --- */
.line-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.game-icon .line-icon {
    width: 8.5rem;
    height: 8.5rem;
    vertical-align: middle;
    color: var(--neon-blue);
    filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.35));
    transition: transform 0.25s ease, filter 0.25s ease;
}

.game-card:hover .game-icon .line-icon {
    transform: scale(1.06);
    filter: drop-shadow(0 0 18px rgba(0, 243, 255, 0.65));
}

#orientation-overlay .phone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

#orientation-overlay .phone-icon .line-icon {
    width: 5.5rem;
    height: 5.5rem;
    vertical-align: middle;
    color: var(--neon-blue);
    filter: drop-shadow(0 0 16px rgba(0, 243, 255, 0.6));
}

.victory-trophy-icon {
    width: 10rem;
    height: 10rem;
    color: #ffd700;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
}

/* =========================================================
   Online Multiplayer Mode UI
   ========================================================= */

.online-mode-hint.hidden,
.online-top-bar.hidden,
.online-dash-bar.hidden,
.online-player-hud.hidden,
.rule-waiting-hint.hidden,
.online-localhost-warn.hidden,
.online-host-timer.hidden,
.online-bar-btn.hidden,
.online-footer-btn.hidden,
#rule-cancel-btn.hidden,
.victory-podium-container.hidden,
.victory-sub-hint.hidden,
.online-join-error.hidden,
.btn-subtle-link.hidden {
    display: none !important;
}

.text-neon-yellow {
    color: var(--neon-yellow);
}

.btn-subtle-link {
    background: transparent;
    border: none;
    color: rgba(0, 243, 255, 0.85);
    font-size: 1.35rem;
    cursor: pointer;
    padding: 8px 16px;
    text-decoration: underline;
    text-underline-offset: 6px;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.btn-subtle-link:hover {
    color: #fff;
}

.online-mode-hint {
    background: rgba(0, 243, 255, 0.08);
    border: 1px solid rgba(0, 243, 255, 0.35);
    border-radius: 12px;
    padding: 18px 24px;
    text-align: center;
    line-height: 1.6;
    font-size: 1.35rem;
    color: rgba(255, 255, 255, 0.9);
}

.online-mode-hint p {
    margin: 4px 0;
}

.online-top-bar {
    position: absolute;
    top: 32px;
    right: 40px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 20;
}

.online-dash-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(0, 243, 255, 0.45);
    color: #fff;
    font-size: 1.35rem;
    letter-spacing: 1px;
}

.online-pill strong {
    color: var(--neon-blue);
    font-family: var(--font-mono);
    font-size: 1.5rem;
}

.online-pill-green {
    background: rgba(0, 255, 157, 0.1);
    border-color: rgba(0, 255, 157, 0.45);
}

.online-pill-green strong {
    color: var(--neon-green);
}

.online-bar-btn {
    font-size: 1.15rem;
    padding: 10px 22px;
    border-radius: 8px;
}

.online-bar-btn-gold {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    background: rgba(255, 189, 0, 0.12);
    box-shadow: 0 0 15px rgba(255, 189, 0, 0.2);
}

.online-bar-btn-gold:active {
    background: var(--neon-yellow);
    color: #000;
}

/* --- Online Client In-Game HUD --- */
.online-player-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20000;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.78);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 16px rgba(0, 243, 255, 0.35);
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
}

.online-hud-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-green);
}

.online-hud-room {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--neon-blue);
    opacity: 0.85;
}

.rule-waiting-hint {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    font-size: 2.8rem;
    color: var(--neon-green);
    padding: 24px 54px;
    border-radius: 16px;
    border: 2px solid rgba(0, 255, 157, 0.55);
    background: rgba(0, 255, 157, 0.08);
    text-shadow: 0 0 18px rgba(0, 255, 157, 0.6);
    flex-shrink: 0;
}

.waiting-pulse-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 16px var(--neon-green);
    animation: online-pulse 1.2s ease-in-out infinite;
}

@keyframes online-pulse {
    0%, 100% {
        transform: scale(0.85);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.25);
        opacity: 1;
    }
}

/* --- Host Lobby Screen --- */
#online-lobby-screen {
    padding: 36px 56px;
    background: radial-gradient(circle at top center, #181a34 0%, #07070f 100%);
    gap: 28px;
}

.online-lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.online-header-btn {
    font-size: 1.35rem;
    padding: 12px 26px;
}

.online-lobby-title-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
}

.online-lobby-title-wrap h2 {
    font-size: 3.2rem;
    letter-spacing: 6px;
}

.online-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 1.25rem;
    color: var(--neon-green);
    background: rgba(0, 255, 157, 0.12);
    border: 1px solid rgba(0, 255, 157, 0.5);
}

.online-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
}

.online-room-code-chip {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 28px;
    border-radius: 14px;
    background: rgba(0, 243, 255, 0.1);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 24px rgba(0, 243, 255, 0.25);
    font-size: 1.4rem;
}

.online-room-code-chip strong {
    font-family: var(--font-mono);
    font-size: 2.6rem;
    letter-spacing: 6px;
    color: var(--neon-blue);
    text-shadow: 0 0 14px var(--neon-blue);
}

.online-lobby-body {
    flex: 1;
    display: grid;
    grid-template-columns: 620px 1fr;
    gap: 36px;
    min-height: 0;
}

.online-qr-panel,
.online-roster-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.online-qr-panel {
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

.online-qr-frame {
    width: 390px;
    height: 390px;
    background: #ffffff;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 36px rgba(0, 243, 255, 0.35);
}

.online-qr-frame svg,
.online-qr-frame img {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.qr-loading {
    color: #222;
    font-size: 1.4rem;
    font-weight: bold;
}

.online-qr-caption {
    font-size: 1.55rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.online-url-row {
    width: 100%;
    display: flex;
    gap: 12px;
    align-items: center;
}

.online-url-row input[type="text"] {
    flex: 1;
    padding: 14px 18px;
    font-size: 1.25rem;
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--neon-blue);
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.online-copy-btn {
    padding: 14px 24px;
    font-size: 1.25rem;
    white-space: nowrap;
}

.online-localhost-warn {
    width: 100%;
    background: rgba(255, 189, 0, 0.14);
    border: 1px solid rgba(255, 189, 0, 0.65);
    color: #ffe380;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: left;
}

.online-localhost-warn code {
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
}

.online-roster-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 20px;
}

.online-roster-header h3 {
    font-size: 2.3rem;
    color: #fff;
}

.online-count-badge {
    font-size: 1.6rem;
    color: var(--neon-green);
    background: rgba(0, 255, 157, 0.12);
    border: 1px solid rgba(0, 255, 157, 0.45);
    padding: 8px 22px;
    border-radius: 999px;
}

.online-player-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    align-content: start;
    overflow-y: auto;
    touch-action: pan-y;
    padding-right: 6px;
}

.online-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 90px 20px;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.45);
}

.online-player-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-radius: 14px;
    background: rgba(0, 243, 255, 0.08);
    border: 1px solid rgba(0, 243, 255, 0.4);
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.12);
}

.online-player-card.offline {
    opacity: 0.45;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
}

.online-player-card-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.online-player-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
    color: #000;
    font-weight: 900;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.online-player-name {
    font-size: 1.65rem;
    font-weight: bold;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-kick-btn {
    background: transparent;
    border: 1px solid rgba(255, 71, 87, 0.6);
    color: #ff6b81;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.online-kick-btn:hover {
    background: rgba(255, 71, 87, 0.25);
    color: #fff;
}

.online-lobby-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.online-proceed-btn {
    font-size: 2.2rem;
    padding: 20px 56px;
    border-radius: 14px;
    border-color: var(--neon-green);
    color: var(--neon-green);
    background: rgba(0, 255, 157, 0.14);
    box-shadow: 0 0 24px rgba(0, 255, 157, 0.28);
}

.online-proceed-btn:active {
    background: var(--neon-green);
    color: #000;
}

/* --- Host Live Leaderboard Screen --- */
#online-host-game-screen {
    padding: 36px 56px;
    background: radial-gradient(circle at top center, #141930 0%, #05050b 100%);
    gap: 22px;
}

.online-host-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.online-host-game-meta {
    display: flex;
    align-items: center;
    gap: 22px;
}

.online-host-game-meta h2 {
    font-size: 3.4rem;
    letter-spacing: 4px;
}

.online-host-right-meta {
    display: flex;
    align-items: center;
    gap: 20px;
}

.online-host-timer {
    min-width: 130px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 3.6rem;
    font-weight: 900;
    color: var(--neon-yellow);
    background: rgba(255, 189, 0, 0.12);
    border: 2px solid var(--neon-yellow);
    border-radius: 16px;
    padding: 8px 24px;
    text-shadow: 0 0 18px rgba(255, 189, 0, 0.6);
}

.online-lb-tabs {
    display: flex;
    align-items: center;
    gap: 16px;
}

.online-lb-tab {
    font-size: 1.5rem;
    padding: 12px 30px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
}

.online-lb-tab.active {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
    background: rgba(0, 243, 255, 0.14);
    box-shadow: 0 0 16px rgba(0, 243, 255, 0.25);
}

.online-progress-summary {
    margin-left: auto;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    padding: 10px 22px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.online-lb-container {
    flex: 1;
    overflow-y: auto;
    touch-action: pan-y;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
}

.online-lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.85rem;
}

.online-lb-table thead th {
    position: sticky;
    top: 0;
    background: #121528;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 600;
    text-align: left;
    padding: 20px 28px;
    border-bottom: 2px solid rgba(0, 243, 255, 0.35);
    font-size: 1.45rem;
    letter-spacing: 2px;
}

.online-lb-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    transition: background 0.2s ease;
}

.online-lb-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.online-lb-table tbody td {
    padding: 20px 28px;
    color: #fff;
}

.online-lb-row-rank-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.16), transparent 65%);
}

.online-lb-row-rank-2 {
    background: linear-gradient(90deg, rgba(192, 206, 224, 0.14), transparent 65%);
}

.online-lb-row-rank-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.14), transparent 65%);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 46px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1.7rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.rank-badge-1 {
    background: linear-gradient(135deg, #ffd700, #ff9f00);
    color: #000;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.6);
}

.rank-badge-2 {
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    color: #000;
    box-shadow: 0 0 14px rgba(226, 232, 240, 0.45);
}

.rank-badge-3 {
    background: linear-gradient(135deg, #e09145, #9c5221);
    color: #000;
    box-shadow: 0 0 14px rgba(224, 145, 69, 0.45);
}

.lb-metric-value {
    font-family: var(--font-mono);
    font-weight: bold;
    color: var(--neon-blue);
    font-size: 2rem;
}

.lb-status-pill {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 1.25rem;
    font-weight: bold;
}

.lb-status-playing {
    color: var(--neon-blue);
    background: rgba(0, 243, 255, 0.14);
    border: 1px solid rgba(0, 243, 255, 0.45);
}

.lb-status-done {
    color: var(--neon-green);
    background: rgba(0, 255, 157, 0.15);
    border: 1px solid rgba(0, 255, 157, 0.5);
}

.lb-status-offline {
    color: #aaa;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.lb-points-cell {
    font-family: var(--font-mono);
    font-weight: bold;
    color: var(--neon-yellow);
    font-size: 1.9rem;
}

.lb-points-gain {
    margin-left: 8px;
    font-size: 1.2rem;
    color: var(--neon-green);
}

.online-empty-row {
    text-align: center;
    padding: 80px 20px !important;
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 1.8rem;
}

.online-host-footer {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

.online-footer-btn {
    font-size: 1.7rem;
    padding: 16px 38px;
    border-radius: 12px;
}

/* --- Client Waiting Screen --- */
#online-waiting-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #181c36 0%, #05050a 100%);
}

.online-waiting-card {
    width: 980px;
    padding: 60px 70px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(0, 243, 255, 0.4);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.16);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    text-align: center;
}

.online-waiting-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    border-radius: 999px;
    background: rgba(0, 255, 157, 0.12);
    border: 1px solid rgba(0, 255, 157, 0.45);
    color: var(--neon-green);
    font-size: 1.5rem;
}

.online-waiting-title {
    font-size: 4rem;
    letter-spacing: 6px;
}

.online-waiting-info {
    display: flex;
    gap: 40px;
    width: 100%;
    justify-content: center;
}

.waiting-info-item {
    min-width: 260px;
    padding: 18px 28px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.waiting-label {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.65);
}

.waiting-info-item strong {
    font-size: 2.5rem;
    color: var(--neon-blue);
    font-family: var(--font-mono);
    letter-spacing: 4px;
}

.waiting-name-box {
    width: 100%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.waiting-name-edit-row {
    display: flex;
    gap: 14px;
}

.waiting-name-edit-row input[type="text"] {
    flex: 1;
    padding: 18px 22px;
    font-size: 1.85rem;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.waiting-name-edit-row button {
    font-size: 1.45rem;
    padding: 16px 30px;
    white-space: nowrap;
}

.waiting-sub-note {
    font-size: 1.45rem;
    color: rgba(255, 255, 255, 0.65);
    margin: 8px 0 0;
}

/* --- Modals (QR & Overall Leaderboard) --- */
.online-modal-backdrop {
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(8px);
    z-index: 35000 !important;
    justify-content: center;
    align-items: center;
}

.online-modal-card {
    width: 1120px;
    max-height: 900px;
    padding: 40px 48px;
    border-radius: 22px;
    background: linear-gradient(135deg, #15172a, #080912);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.3);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.online-modal-wide {
    width: 1280px;
    border-color: var(--neon-yellow);
    box-shadow: 0 0 50px rgba(255, 189, 0, 0.25);
}

.online-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.online-modal-header h2 {
    font-size: 2.8rem;
}

.online-modal-qr-body {
    display: flex;
    gap: 40px;
    align-items: center;
}

.online-modal-qr-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.online-room-code-big {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.85);
}

.online-room-code-big strong {
    font-family: var(--font-mono);
    font-size: 3.2rem;
    color: var(--neon-blue);
    letter-spacing: 6px;
}

.online-modal-roster-title {
    font-size: 1.5rem;
    color: var(--neon-green);
}

.online-player-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
    touch-action: pan-y;
}

.online-player-chip {
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(0, 243, 255, 0.14);
    border: 1px solid rgba(0, 243, 255, 0.45);
    color: #fff;
    font-size: 1.35rem;
}

.online-modal-lb-scroll {
    max-height: 660px;
}

/* --- Online Victory Podium --- */
.victory-podium-container {
    margin-top: 24px;
    width: 1180px;
    max-height: 460px;
    overflow-y: auto;
    touch-action: pan-y;
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid rgba(255, 215, 0, 0.45);
    border-radius: 20px;
    padding: 20px 30px;
    z-index: 5;
}

.victory-sub-hint {
    margin-top: 20px;
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.65);
}

/* --- Responsive Mobile-First Client Join Overlay (Outside #app-container) --- */
body.online-join-active #orientation-overlay {
    display: none !important;
}

#online-join-overlay {
    position: fixed;
    inset: 0;
    z-index: 120000;
    background: radial-gradient(circle at top center, #1b1f3b 0%, #05050a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    touch-action: pan-y;
}

#online-join-overlay.hidden {
    display: none;
}

.online-join-card {
    width: 100%;
    max-width: 460px;
    padding: 32px 26px;
    border-radius: 20px;
    background: rgba(15, 18, 34, 0.92);
    border: 2px solid rgba(0, 243, 255, 0.55);
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.22);
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: center;
}

.online-join-logo {
    font-size: 2.3rem;
    font-weight: 900;
    letter-spacing: 6px;
}

.online-join-heading {
    font-size: 1.45rem;
    color: #fff;
    margin: 0;
    text-shadow: none;
}

.online-join-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.online-join-field label {
    font-size: 1rem;
    color: var(--neon-blue);
    font-weight: bold;
}

.online-join-field input[type="text"] {
    padding: 14px 16px;
    font-size: 1.25rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

.online-join-field input[type="text"]:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.35);
}

#join-room-code-input {
    font-family: var(--font-mono);
    letter-spacing: 4px;
    text-transform: uppercase;
    text-align: center;
    font-weight: bold;
    font-size: 1.5rem;
}

.online-join-error {
    color: #ff6b81;
    background: rgba(255, 71, 87, 0.16);
    border: 1px solid rgba(255, 71, 87, 0.5);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
}

.online-join-submit {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.35rem;
    border-radius: 12px;
    border-color: var(--neon-green);
    color: var(--neon-green);
    background: rgba(0, 255, 157, 0.14);
}

.online-join-submit:active {
    background: var(--neon-green);
    color: #000;
}

.online-join-tip {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 4px 0 0;
    line-height: 1.5;
}