:root {
    --primary: #e11d48;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-dim: #64748b;
    --border: #e2e8f0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }

/* 페이지 제어 (중요!) */
.page { display: none; width: 100%; }
.page.active { display: block !important; }

.container { width: 100%; max-width: 800px; margin: 0 auto; padding: 15px; }

/* Navigation */
#main-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; background: white; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1000;
}
.nav-brand { font-weight: 900; font-size: 20px; cursor: pointer; }
.nav-brand span { color: var(--primary); }
.nav-menu { display: flex; gap: 8px; }
.nav-item { padding: 8px 15px; font-size: 13px; font-weight: bold; border-radius: 20px; cursor: pointer; color: var(--text-dim); }
.nav-item.active { background: var(--primary); color: white; }

/* Cards & UI */
.card { background: white; border-radius: 15px; padding: 20px; border: 1px solid var(--border); margin-bottom: 20px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.btn-main { background: var(--primary); color: white; border: none; border-radius: 10px; padding: 12px; font-weight: bold; cursor: pointer; }
.btn-sub { background: #f1f5f9; color: var(--text); border: none; border-radius: 10px; padding: 12px; font-weight: bold; cursor: pointer; }

/* Studio Page */
.input-row { display: flex; gap: 10px; margin-bottom: 15px; }
.input-row input { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.singer-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.singer-btn { background: #f8fafc; border: 2px solid transparent; padding: 12px 5px; border-radius: 10px; text-align: center; cursor: pointer; }
.singer-btn.active { border-color: var(--primary); background: #fff1f2; }
.avatar { font-size: 24px; display: block; }
.name { font-size: 11px; font-weight: bold; }

canvas { width: 100%; height: 80px; background: #000; border-radius: 10px; }

/* Lyric Bar */
.lyric-row {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lyric-controls {
    display: grid;
    /* 화면 크기에 따라 3열 또는 2열로 자동 배치 (겹침 방지) */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); 
    gap: 12px;
    background: #f8fafc;
    padding: 12px;
    border-radius: 10px;
}

.ctrl-item {
    display: flex;
    flex-direction: column; /* 라벨과 슬라이더를 세로로 배치 */
    gap: 4px;
}

.ctrl-item label {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-dim);
    white-space: nowrap; /* 라벨 줄바꿈 방지 */
}

.ctrl-item input[type="range"] {
    width: 100%;
    margin: 0;
    cursor: pointer;
}

.ctrl-item input[type="number"] {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}

/* Bottom Control */
.bottom-ctrl {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; padding: 15px; display: flex; gap: 10px;
    border-top: 1px solid var(--border);
}
.rec-btn { flex: 3; }
.btn-stop { flex: 1; background: #64748b; color: white; border: none; border-radius: 10px; cursor: pointer; font-weight: bold; }

/* Board */
.ranking-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.ranking-row .card { flex: 0 0 200px; text-align: center; border: 1px solid var(--primary); }

/* Mobile */
@media (max-width: 600px) {
    .input-row { flex-direction: column; }
    .nav-item { padding: 6px 10px; font-size: 12px; }
}

/* Loading */
.loading { position: fixed; inset: 0; background: white; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.loader-box { text-align: center; width: 80%; }
.progress-bar { width: 100%; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-top: 15px; }
.progress-fill { width: 0%; height: 100%; background: var(--primary); transition: 0.3s; }

.result-card {
    text-align: center; /* 내부 요소 중앙 정렬 */
    border: 2px solid var(--primary); /* 강조 테두리 */
    background: #fff1f2;
}

.res-head {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 15px;
}

#song-title-input {
    width: 100%;
    max-width: 400px; /* 너무 길지 않게 제한 */
    padding: 12px;
    margin: 10px auto 20px auto; /* 위아래 여백 및 중앙 정렬 */
    display: block;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    text-align: center; /* 입력 텍스트 중앙 정렬 */
    transition: border-color 0.3s;
}

#song-title-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.res-btns {
    display: flex;
    gap: 12px;
    justify-content: center; /* 가로 중앙 정렬 */
    align-items: center;
    flex-wrap: wrap; /* 모바일에서 줄바꿈 허용 */
    margin-top: 15px;
}

.res-btns .btn-main, .res-btns .btn-sub {
    min-width: 140px; /* 버튼 최소 너비 설정 */
    padding: 12px 20px;
    font-size: 15px;
    flex: 1; /* 동일한 비율로 크기 확장 */
    max-width: 200px;
}

.btn-add-bar {
    width: 100%;
    padding: 15px;
    background: white;
    color: var(--text-dim);
    border: 2px dashed var(--border); /* 점선 테두리로 세련되게 */
    border-radius: 12px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.btn-add-bar:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px); /* 살짝 떠오르는 효과 */
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.1);
}

.btn-add-bar:active {
    transform: translateY(0);
}

.ranking-card .likes-count {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: bold;
    color: var(--primary);
    background: #fff1f2;
    padding: 2px 8px;
    border-radius: 20px;
}


/* [수정] 게이트 페이지(핀번호) 중앙 정렬 및 디자인 */

#page-gate {
    display: none;
    height: 80vh; /* 화면 높이에 맞춤 */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#page-gate.active {
    display: flex !important; /* flex로 변경하여 중앙 정렬 활성화 */
}

.gate-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 40px 30px;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.gate-card h1 {
    font-size: 24px;
    letter-spacing: -1px;
    margin-bottom: 10px;
}

.pin-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 25px 0;
}

#pin-code {
    width: 100%;
    height: 60px;
    font-size: 32px;
    text-align: center;
    letter-spacing: 15px; /* 비밀번호 점 사이 간격 */
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    transition: all 0.3s;
}

#pin-code:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.1);
}

#pin-code::placeholder {
    letter-spacing: normal;
    font-size: 16px;
    color: #cbd5e1;
}

.gate-card .btn-main {
    height: 55px;
    font-size: 18px;
    letter-spacing: 2px;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.3);
}

/* [수정] 로딩바 텍스트 애니메이션 */
#load-status {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 10px;
}




