/* ==================================================================
   기본 레이아웃 · 타이머 · 본문
   구 style.css 1~481줄
   ⚠️ 파일명 번호 = 로드 순서. 뒤 파일이 앞을 덮어쓰므로 순서를 바꾸면 화면이 깨진다.
   ================================================================== */
@charset "UTF-8";

/* --- 공통 스타일 --- */
html {
    /* 모바일 pull-to-refresh 방지 */
    overscroll-behavior-y: contain;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--ns-bg-primary, #0b0b15);
    color: var(--ns-text-primary, #e0e6ed);
    margin: 0;
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    overflow: hidden;
    height: 100vh;
    height: 100svh;
    max-height: 100svh;
    display: flex;
    flex-direction: column;
    /* 모바일 pull-to-refresh 방지 */
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.35);
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('img/background.webp') no-repeat center center fixed;
    background-size: cover;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    /* 빛 효과가 화면 밖으로 나갈 때 스크롤 생기지 않도록 */
}

/* 빛나는 라인 효과 (스캔라인) */
#start-screen::after {
    content: "";
    position: absolute;
    top: -50%;
    left: 0;
    width: 100%;
    height: 100px;
    /* 빛의 두께 */
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.15) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: rotate(0deg);
    /* 일자로 내려오도록 */
    animation: shine-scan 4s infinite linear;
    pointer-events: none;
    /* 클릭 방해하지 않음 */
    z-index: 1;
    /* 로고/버튼 뒤? 앞? 앞이면 버튼 색이 변함. 보통 맨 위나 로고 위. */
}

/* z-index 조정: 로고와 버튼이 빛 효과보다 위에 오게 할지, 아래에 오게 할지 결정.
   "광나는 듯한 효과"라면 위에 덮어씌워야 함. 하지만 버튼 클릭은 되어야 하므로 pointer-events: none 필수.
*/

@keyframes shine-scan {
    0% {
        top: -20%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 120%;
        opacity: 0;
    }
}

.start-btn-group {
    display: flex;
    flex-direction: row;
    /* 모바일에서도 가로 배치 */
    gap: 8px;
    /* 간격 축소 */
    width: 100%;
    align-items: stretch;
    /* 높이 맞춤 */
    justify-content: center;
    padding: 0 10px;
    /* 양옆 여백 */
    box-sizing: border-box;
}

/* 모바일 전용 버튼 스타일 재정의 */
@media (max-width: 768px) {
    .mode-btn {
        width: auto !important;
        flex: 1;
        /* 가로 공간 균등 분할 */
        padding: 10px 5px !important;
        /* 패딩 대폭 축소 */
        font-size: 0.85rem !important;
        /* 폰트 크기 축소 */
        min-height: 80px;
        /* 최소 높이 확보 */
        max-width: none !important;
        /* 너비 제한 해제 */
    }

    /* 버튼 내부 줄바꿈 허용 */
    .mode-btn br {
        display: block;
    }

    /* 설명 텍스트 크기 축소 */
    .mode-btn span {
        font-size: 0.65rem !important;
    }
}

.start-logo {
    display: block;
    /* 블록 요소로 변경하여 마진 오토 적용 */
    margin: 0 auto 20px auto;
    /* 가로 중앙 정렬 */
    width: 100%;
    max-width: 90%;
    /* 모바일: 화면 가로 90%까지 키움 */
    height: auto;
    max-height: 300px;
    /* 모바일: 세로 300px까지 키움 */
    object-fit: contain;
}

/* PC 화면 (가로 768px 이상) */
@media (min-width: 768px) {
    .start-logo {
        max-width: 800px;
        /* PC: 가로 최대 800px */
        max-height: 400px;
        /* PC: 세로 최대 400px */
        margin-bottom: 40px;
        /* 버튼과 간격 넓힘 */
    }

    .start-btn-group {
        flex-direction: row;
        /* PC: 가로 배치 */
        max-width: 1000px;
        gap: 20px;
    }

    .mode-btn {
        width: 200px !important;
        height: auto;
        /* PC에서는 버튼 키우기 */
    }
}

.mode-btn {
    padding: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    border: 2px solid #ffd700;
    background: rgba(0, 0, 0, 0.8);
    /* 명시적인 검은 배경 */
    color: #ffd700;
    border-radius: 2px;
    cursor: pointer;
    transition: 0.3s;
    width: 80%;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: normal;
}

.mode-btn.player-btn {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.mode-btn:hover {
    transform: scale(1.05);
    /* box-shadow: 0 0 15px rgba(255, 215, 0, 0.5); */
    /* Remove background change to avoid weird effects behind images */
    background: transparent !important;
    border-color: transparent !important;
}

.mode-btn.player-btn:hover {
    /* background: #218838; */
    /* box-shadow: 0 0 15px rgba(40, 167, 69, 0.5); */
    background: transparent !important;
}

/* 블러 처리를 위한 메인 래퍼 */
#app-root {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    transition: filter 0.3s ease;
    overflow: hidden;
}

body.blind-active #app-root {
    filter: blur(15px);
    pointer-events: none;
}

header {
    text-align: center;
    padding: max(8px, env(safe-area-inset-top)) 0 8px 0;
    background: var(--ns-bg-secondary, #111827);
    flex-shrink: 0;
    border-bottom: 1px solid var(--ns-border-accent, rgba(0, 240, 255, 0.2));
    z-index: 100;
    position: relative;
}

h1 {
    margin: 0;
    font-size: 1.1rem;
    color: #ffd700;
}

/* 운영자 투어 재실행 — 헤더 우측 빈 공간. 운영자 화면에서만 보인다 */
#tour-replay-btn {
    display: none;
}

body.admin-mode #tour-replay-btn {
    display: block;
    position: absolute;
    /* header 패딩 + .timer-area 패딩(10px) 만큼 내려 날짜 줄과 눈높이를 맞춘다 */
    top: calc(max(8px, env(safe-area-inset-top)) + 8px);
    right: 10px;
    /* 같은 header 안의 .timer-area 가 z-index:10000 이라 그보다 위여야 보인다 */
    z-index: 10001;
    padding: 5px 10px;
    background: rgba(255, 184, 0, 0.10);
    border: 1px solid rgba(255, 184, 0, 0.42);
    border-radius: 2px;
    color: #c9a24d;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: bold;
    cursor: pointer;
}

body.admin-mode #tour-replay-btn:hover {
    background: rgba(255, 184, 0, 0.2);
    color: #ffb800;
}

/* --- Timer & Date Display (New) --- */
.timer-area {
    width: 100%;
    background: var(--ns-bg-secondary, #111827);
    padding: 10px 0;
    border-bottom: 1px solid var(--ns-border-accent, rgba(0, 240, 255, 0.2));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 50;
    position: relative;
}

.timer-bar-container {
    width: 98%;
    height: 40px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--ns-border-accent, rgba(0, 240, 255, 0.2));
    border-radius: var(--ns-radius-md, 10px);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.timer-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--ns-accent-cyan), var(--ns-accent-purple), #ff00aa, var(--ns-accent-gold));
    background-size: 300% 100%;
    animation: gradientMove 3s ease infinite;
    transition: width 1s linear;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

@keyframes gradientMove {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

.date-display {
    font-size: 3rem;
    /* Significantly larger */
    font-weight: 900;
    /* Extra bold */
    color: #fff;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.7);
    margin-bottom: 5px;
    /* Spacing */
}

.year-badge {
    background: #ffd700;
    color: #000;
    padding: 4px 12px;
    border-radius: 2px;
    margin-right: 15px;
    font-size: 2rem;
    /* Significantly larger */
    vertical-align: middle;
}

/* --- Content --- */
.container {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 5px;
    overflow-y: auto;
    gap: 5px;
    padding-bottom: 80px;
    /* footer 높이만큼 여백 확보 (30px NEWS바 + 여유) */
}

/* Viewer mode: smaller footer, less padding needed */
body.viewer-mode .container {
    padding-bottom: 80px !important;
    /* footer 고정 시 여백 필요 */
}

.status-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    flex-shrink: 0;
}

.status-board.fewer-stocks {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.stock-card {
    background: var(--ns-gradient-card, linear-gradient(145deg, #1c2333 0%, #111827 100%));
    padding: 8px 4px;
    border-radius: var(--ns-radius-sm, 6px);
    text-align: center;
    border: 1px solid var(--ns-border-default, rgba(255, 255, 255, 0.1));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 70px;
    transition: border-color var(--ns-transition-fast, 0.15s ease), box-shadow var(--ns-transition-fast, 0.15s ease);
}

.stock-card:hover {
    border-color: var(--ns-accent-cyan, #00f0ff);
    box-shadow: var(--ns-glow-cyan, 0 0 12px rgba(0, 240, 255, 0.3));
}

.stock-number {
    position: absolute;
    top: 5px;
    left: 5px;
    /* Background set dynamically */
    color: #fff;
    /* Text color white */
    font-size: 0.9rem;
    /* Larger font */
    font-weight: bold;
    width: 24px;
    /* Larger size */
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.stock-name {
    font-size: 0.8rem;
    color: #fff !important;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    width: 100%;
}

.stock-price {
    font-size: 1rem;
    font-weight: 700 !important;
    color: var(--ns-accent-cyan, #00f0ff) !important;
    font-family: 'Noto Sans KR', sans-serif !important;
    margin-bottom: 0;
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
}

.up {
    color: var(--ns-color-up, #ff3366);
    text-shadow: 0 0 6px rgba(255, 51, 102, 0.3);
}

.down {
    color: var(--ns-color-down, #3388ff);
    text-shadow: 0 0 6px rgba(51, 136, 255, 0.3);
}

.same {
    color: var(--ns-text-secondary, #8b9bb4);
}

/* 전광판 전년비 (결산 뉴스 효과) — 본딩커브 등락 아래 보조 표기 */
.stock-yoy {
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0.85;
    margin-top: 1px;
    white-space: nowrap;
}

.delisted-badge {
    background: #ff0000;
    color: white;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 0.6rem;
    display: inline-block;
}

.relisted-badge {
    background: #00cc66;
    color: white;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 0.6rem;
    animation: blink 2s infinite;
    display: inline-block;
}

.text-delisted {
    color: #555;
    text-decoration: line-through;
}

.chart-box {
    background: var(--ns-bg-card, #161b2e);
    padding: 5px;
    border-radius: var(--ns-radius-md, 10px);
    flex-grow: 1;
    border: 1px solid var(--ns-border-default, rgba(255, 255, 255, 0.1));
    position: relative;
    min-height: 200px;
    display: flex;
    box-shadow: var(--ns-shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.3));
}

canvas {
    width: 100% !important;
    height: 100% !important;
}
