@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    --bg: #090b10;
    --bg2: #0e111a;
    --panel: #141824;
    --panel2: #1c2233;
    --border: #262e42;
    --text: #e2e8f0;
    --dim: #8b95a9;
    --accent: #ec4899;     /* 아이마스 포인트 핑크 (글자·테두리용) */
    --accent-fill: #ec4899; /* 버튼 등 흰 글자가 올라가는 면 색상 */
    --accent2: #6366f1;    /* 서브 인디고 */
    --good: #34d399;
    --bad: #f43f5e;
    --vo: #fb7185;
    --da: #38bdf8;
    --vi: #fbbf24;
    --me: #c084fc;
    --hp: #34d399;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    height: 100dvh;
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Pretendard', -apple-system, system-ui, sans-serif;
    line-height: 1.5;
    overflow: hidden; /* 전체 화면 덜컹거림 방지 (내부 로그만 스크롤) */
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}
button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* =========================================================
   1. 타이틀 & 초기 설정 화면 (스크롤 허용 래퍼)
   ========================================================= */
.screen-scroll {
    height: 100dvh;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px 60px;
}

.landing-inner {
    width: 100%;
    max-width: 680px;
}

.ui-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 16px;
}

.ui-btn-primary {
    background: linear-gradient(90deg, var(--accent-fill), var(--accent2));
    color: #fff;
    font-weight: 800;
    border: 0;
    border-radius: 10px;
    padding: 13px 24px;
    transition: filter 0.15s, transform 0.1s;
}
.ui-btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.ui-btn-secondary {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.ui-btn-secondary:hover {
    border-color: var(--accent);
}

/* 아이돌 아바타 */
.idol-avatar-sm {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--panel2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.idol-avatar-lg {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--panel2);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.idol-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.idol-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.idol-card.selected {
    border: 2px solid var(--accent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent2) 6%, transparent));
}

/* =========================================================
   2. 본 게임 레이아웃 (레퍼런스의 .play / .topbar / .layout 구조)
   ========================================================= */
.play {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 상단 고정 게이지 & 배속 컨트롤 바 */
.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "age bar controls"
        "hint hint hint";
    align-items: center;
    gap: 6px 16px;
    padding: 10px 20px 8px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.age {
    grid-area: age;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.age b {
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1;
    color: #fff;
}
.age .season {
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 700;
}

/* 턴 게이지바 */
.yearbar {
    grid-area: bar;
    height: 8px;
    background: var(--panel2);
    border-radius: 999px;
    overflow: hidden;
}
.yearbar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.08s linear;
}

.controls {
    grid-area: controls;
    display: flex;
    align-items: center;
    gap: 8px;
}

.speeds {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.speeds button {
    background: var(--panel);
    border: 0;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-right: 1px solid var(--border);
    color: var(--dim);
}
.speeds button:last-child { border-right: 0; }
.speeds button.on {
    background: var(--accent-fill);
    color: #fff;
}

.hint {
    grid-area: hint;
    font-size: 0.8rem;
    color: var(--dim);
    display: flex;
    justify-content: space-between;
}

/* 메인 2단 분할 (PC: 좌측 290px 사이드바 + 우측 로그창) */
.layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 290px 1fr;
}

.side {
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-right: 1px solid var(--border);
    background: var(--bg2);
}

.side-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}

/* 스탯 바 */
.stat { margin-bottom: 10px; }
.stat:last-child { margin-bottom: 0; }
.stat-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
}
.bar {
    height: 6px;
    background: var(--panel2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
}
.bar i {
    display: block;
    height: 100%;
    transition: width 0.35s ease;
}

/* 우측 스테이지 & 로그 영역 */
.stage {
    position: relative;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.log {
    flex: 1;
    overflow-y: auto;
    padding: 20px clamp(16px, 4vw, 48px) 60px;
    scroll-behavior: smooth;
}

/* 레퍼런스 스타일 로그 라인 & 주차 구분선 */
.yearline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 10px;
    color: var(--dim);
    font-size: 0.8rem;
    font-weight: 700;
}
.yearline:before, .yearline:after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.line {
    max-width: 680px;
    margin: 0 auto 12px;
    padding: 4px 0 4px 14px;
    border-left: 2px solid var(--border);
    animation: rise 0.3s ease both;
}
.line.good { border-left-color: var(--good); }
.line.bad { border-left-color: var(--bad); }
.line.great { border-left-color: var(--accent); }

.line p {
    margin: 0;
    font-size: 0.95rem;
}

.deltas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.76rem;
    font-weight: 700;
}
.deltas .up { color: var(--good); }
.deltas .down { color: var(--bad); }

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* =========================================================
   3. 모달 팝업 & '창 숨기고 상황 보기(Peek)' 기능
   ========================================================= */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 6, 9, 0.82);
    backdrop-filter: blur(3px);
}

.modal {
    width: 100%;
    max-width: 540px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.action-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    text-align: left;
    transition: border-color 0.15s, transform 0.1s;
}
.action-btn:hover {
    border-color: var(--accent);
    transform: translateX(2px);
}

.peek-btn {
    display: block;
    margin: 12px auto 0;
    background: none;
    border: 0;
    color: var(--dim);
    font-size: 0.78rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.peek-btn:hover { color: #fff; }

.peek-back {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 50;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--panel);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.8);
}

/* =========================================================
   📱 4. 모바일 자동 압축 (820px 이하 — 레퍼런스 핵심 기법!)
   ========================================================= */
@media (max-width: 820px) {
    .topbar {
        padding: 8px 12px 6px;
        gap: 4px 10px;
    }
    .age b { font-size: 1.25rem; }
    .hint { font-size: 0.7rem; }

    /* 좌우 2단 레이아웃을 상하 1단으로 바꾸고 사이드바를 얇은 상단 바로 압축 */
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .side {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 8px 12px;
        gap: 8px;
        overflow: visible;
    }

    .side-card {
        padding: 0;
        border: 0;
        background: none;
    }

    .idol-avatar-lg {
        width: 38px;
        height: 38px;
    }

    /* 5개 스탯(HP, Vo, Da, Vi, Me)을 한 줄에 얇은 미니 바로 나열 */
    .side-stats {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }
    .side-stats .stat { margin: 0; }
    .side-stats .stat-head {
        font-size: 0.68rem;
        margin-bottom: 2px;
    }
    .side-stats .bar { height: 4px; margin-top: 2px; }

    .log {
        padding: 14px 14px 80px;
    }
}

/* 일시정지 시 게이지바 색상 변경 (레퍼런스 기법) */
.yearbar.paused i {
    background: var(--dim) !important;
}

/* 일시정지 버튼 활성화 강조 */
.btn-pause.on {
    border-color: var(--accent);
    color: var(--accent);
}

/* PC에서는 텍스트(.bt) 표시, 모바일(820px 이하)에서는 단축 아이콘(.bs)만 표시 */
.ctl-actions .bs { display: none; }

@media (max-width: 820px) {
    .ctl-actions .bt { display: none; }
    .ctl-actions .bs { display: inline; }
    .speeds button {
        padding: 5px 7px;
        font-size: 0.72rem;
    }
}

/* =========================================================
   📊 사이드바 2번째 박스: 팬 수 / 친애도 / 컨디션 3열 스트립
   ========================================================= */
.side-status-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 8px;
    text-align: center;
}

.status-cell {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.status-label {
    font-size: 0.7rem;
    color: var(--dim);
    font-weight: 600;
}

.status-cell b {
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

/* 모바일(820px 이하)에서도 3칸이 납작하고 깔끔하게 유지되도록 조정 */
@media (max-width: 820px) {
    .side-status-strip {
        padding: 0;
        gap: 6px;
    }
    .status-cell {
        padding: 4px 2px;
    }
    .status-label {
        font-size: 0.64rem;
    }
    .status-cell b {
        font-size: 0.76rem;
    }
}