:root {
    --bg: #050505;
    --primary: #00f2ff;
    --secondary: #ff007a;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: radial-gradient(circle at center, #1a1a2e 0%, #050505 100%);
    color: #eee;
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    /* 랜딩 페이지는 스크롤 허용 */
    width: 100%;
    min-height: 100vh;
}

body.in-game {
    overflow: hidden;
    /* 게임 입장 시 스크롤 차단 */
}

#landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background: transparent;
    padding: 0;
    scroll-behavior: smooth;
}

.landing-content {
    width: 100%;
    max-width: 1000px;
}

section {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    /* 간격을 더욱 좁게 (6rem -> 3rem) */
    /* 전체 화면 대신 균형 잡힌 여백 */
    opacity: 0;
    transform: translateY(30px);
    transition: all 1s ease-out;
}

#hero {
    min-height: 100vh;
    /* 히어로 섹션만 전체 화면 유지 */
    padding: 2rem;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-section {
    position: relative;
}

.info-section {
    padding: 2rem 2rem;
    /* 추가 축소 */
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    /* 시각적 구분선 추가 */
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 600px;
    width: 90%;
}

h1 {
    font-size: 4rem;
    letter-spacing: 0.5rem;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    background: rgba(0, 242, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 50px;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 242, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 242, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 242, 255, 0);
    }
}

.main-panel {
    padding: 4rem;
    margin-top: -10vh;
    /* 히어로 중앙 정렬 보정 */
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.7;
    margin-bottom: 3rem;
    font-weight: 300;
}

.choice-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.protocol-guide {
    margin-top: 2rem;
    font-size: 0.9rem;
}

.protocol-guide .protocol-link {
    margin-top: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.protocol-guide .protocol-link:hover {
    opacity: 1;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
    text-transform: uppercase;
}

.primary {
    background: var(--primary);
    color: #000;
}

.primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--primary);
}

.secondary {
    background: var(--glass);
    color: #eee;
    border: 1px solid var(--border);
}

.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    width: 100%;
}

.card {
    padding: 3rem;
    text-align: left;
    transition: 0.5s;
}

.card:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.card h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.protocol-link {
    display: inline-block;
    margin-top: 2rem;
    color: var(--secondary);
    text-decoration: none;
    font-weight: bold;
    letter-spacing: 1px;
    transition: 0.3s;
    border-bottom: 1px solid transparent;
}

.protocol-link:hover {
    letter-spacing: 2px;
    border-bottom-color: var(--secondary);
}

.hidden {
    display: none !important;
}

#world-view {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #050505 100%);
}

#stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* 캔버스보다는 뒤, 배경보다는 앞 */
    pointer-events: none;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: twinkling var(--duration) infinite ease-in-out;
}

@keyframes twinkling {

    0%,
    100% {
        opacity: 0;
        transform: scale(0.5);
    }

    50% {
        opacity: var(--opacity);
        transform: scale(1.2);
    }
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* 최하단 */
}

#btn-back {
    position: absolute;
    top: 20px;
    left: 360px;
    /* UI-Overlay 너비(320px) + 간격 */
    z-index: 10000;
}

.toggle-container {
    position: absolute;
    top: 70px;
    left: 360px;
    z-index: 10000;
}

#mobile-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: none;
    /* 데스크탑에서는 숨김 */
    gap: 10px;
    z-index: 20000;
}

#mobile-controls .btn {
    padding: 8px 15px;
    font-size: 11px;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
}

#mobile-controls .btn.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.room-status-window {
    position: absolute;
    bottom: 20px;
    left: 360px;
    width: 400px;
    height: 350px;
    /* 높이 증가 */
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid var(--primary);
    border-radius: 15px;
    z-index: 10000;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

.room-dashboard {
    background: rgba(0, 242, 255, 0.05);
    border-bottom: 1px solid rgba(0, 242, 255, 0.2);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 13px;
    font-family: 'JetBrains Mono';
}

.dashboard-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px edge rgba(255, 255, 255, 0.05);
}

.dashboard-label {
    opacity: 0.6;
    font-size: 11px;
}

.room-status-item {
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.room-status-window h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 14px;
}

/* Tooltip Styles */
#tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid var(--primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #eee;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: none;
}

#tooltip h4 {
    color: var(--primary);
    margin-bottom: 4px;
    font-size: 1rem;
}

#tooltip p {
    opacity: 0.8;
    font-size: 0.8rem;
    margin: 0;
}

#tooltip .meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-family: 'JetBrains Mono';
    font-size: 0.75rem;
    color: var(--secondary);
}

#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 350px;
    pointer-events: none;
    z-index: 9999;
    /* 채팅 UI 등이 위치한 전역 오버레이 */
}

#leaderboard,
#chat-feed {
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 20px;
    pointer-events: auto;
    /* UI 요소는 클릭 가능하게 */
}

#leaderboard h2,
#chat-feed h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

#leaderboard {
    height: 40%;
    display: flex;
    flex-direction: column;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

#leaderboard-table th {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

#leaderboard-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

#leaderboard-table tbody tr {
    transition: 0.3s;
}

#leaderboard-table tbody tr:hover {
    background: rgba(0, 242, 255, 0.05);
}

#leaderboard-table tbody tr:hover td {
    color: var(--primary);
    transform: translateX(5px);
}

.table-container::-webkit-scrollbar {
    width: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

#chat-feed {
    height: 60%;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Telegram Style Bubble */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    margin-bottom: 12px;
    align-items: flex-start;
}

.message .nickname {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 4px;
    margin-left: 5px;
    cursor: pointer;
    transition: 0.2s;
}

.message .nickname:hover {
    color: var(--secondary);
    text-decoration: underline;
    transform: scale(1.05);
}

.bubble {
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.85rem;
    line-height: 1.4;
    background: #2b2b2b;
    color: #eee;
    border-top-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: left;
}

.message.self {
    align-self: flex-end;
}

.message.self .bubble {
    background: #2b5278;
    /* Telegram Blueish */
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 2px;
}

.message.self .nickname {
    align-self: flex-end;
    margin-left: 0;
    margin-right: 5px;
    color: var(--secondary);
}

/* 스크롤바 커스텀 */

#room-logs::-webkit-scrollbar {
    width: 4px;
}

#room-logs::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.highlight {
    color: var(--secondary);
    font-weight: bold;
}

#challenge-timer {
    font-size: 2rem;
    margin: 1rem 0;
    font-family: 'JetBrains Mono';
}

#room-logs {
    overflow-y: scroll;
}

ul#leaderboard-list {
    list-style: none;
    padding: 0;
}

ul#leaderboard-list li {
    margin-bottom: 10px;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

ul#leaderboard-list li:hover {
    transform: scale(1.05);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }

    #ui-overlay {
        left: 20px;
        right: 20px;
        width: auto;
        bottom: 20px;
        top: 70px;
        /* 버튼 아래부터 시작 */
        pointer-events: none;
    }

    #leaderboard,
    #chat-feed {
        display: none;
        /* 기본적으로 숨김 */
        height: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 15000;
        pointer-events: auto;
    }

    #leaderboard.show,
    #chat-feed.show {
        display: flex;
        /* 활성화 시 보임 */
    }

    #status-bar {
        font-size: 0.7rem;
        margin-bottom: 5px;
    }

    #btn-back {
        left: 20px;
        top: auto;
        bottom: 380px;
        z-index: 25000;
    }

    .toggle-container {
        left: 20px;
        top: auto;
        bottom: 340px;
        z-index: 25000;
    }

    .room-status-window {
        left: 20px;
        right: 20px;
        width: auto;
        height: 320px;
        bottom: 10px;
    }

    h1 {
        font-size: 2.2rem;
    }

    .glass-panel {
        padding: 1.2rem;
    }
}