* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg1: #f4edff;
    --panel: #ffffff;
    --panel-grad: linear-gradient(165deg, #ffffff 0%, #faf6ff 100%);
    --card-grad: linear-gradient(165deg, #ffffff 0%, #fbf8ff 100%);
    --line: #e0d2f7;
    --text: #5c4b78;
    --dim: #9d8fb8;
    --accent: #b79bea;
    --accent-dark: #8a6ad2;
    --good: #86dcc4;
    --good-dark: #3fae95;
    --bad: #ff9fc0;
    --bad-dark: #e0679a;
    --warn: #ffcf7a;
    --shadow: 0 6px 0 rgba(120, 90, 170, .12);
    --sheen: inset 0 1px 0 rgba(255, 255, 255, .8);
}

body {
    background: var(--bg1) url("assets/bg/bg-main.png") center/cover no-repeat fixed;
    color: var(--text);
    font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif;
    font-weight: 600;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* 게임 화면만 더 옅은 배경(bg-play.png)으로 바꿔서 맵·HUD 가독성을 지킨다 */
#screen-game {
    background: var(--bg1) url("assets/bg/bg-play.png") center/cover no-repeat fixed;
    border-radius: 28px;
    padding: 16px;
    margin: -16px;
}

.screen {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

#screen-game { max-width: 1000px; }

.hidden { display: none !important; }

/* 메뉴 화면 뒤에 잔잔하게 떠다니는 거품·물고기 — 게임 화면에서는 숨긴다 */
#ambient-bg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* 배경음악 켜기/끄기 — 화면이 바뀌어도 항상 같은 자리에 떠 있다 */
.music-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 30;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 19px;
    line-height: 1;
    background: var(--panel-grad);
    color: var(--text);
    box-shadow: var(--shadow);
    border: 3px solid var(--line);
}
.music-toggle.muted { opacity: .55; }

.lang-picker {
    position: fixed;
    top: 16px;
    right: 68px;
    z-index: 30;
    display: flex;
    gap: 4px;
    background: var(--panel-grad);
    border: 3px solid var(--line);
    border-radius: 999px;
    padding: 4px;
    box-shadow: var(--shadow);
}
.lang-btn {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.lang-btn:hover { background: rgba(183, 155, 234, .18); }
.lang-btn.active { background: var(--accent); color: #fff; }

@media (max-width: 640px) {
    .lang-picker { top: auto; bottom: 16px; right: 16px; }
    .lang-btn { padding: 5px 7px; font-size: 11px; }
}

.logo-row { display: flex; align-items: center; justify-content: center; gap: 4px; }
.mascot { width: 64px; height: 64px; image-rendering: pixelated; }

.logo {
    font-size: 42px;
    letter-spacing: 2px;
    font-weight: 900;
    background: linear-gradient(135deg, #b89af0 0%, var(--accent-dark) 55%, #7c5cc4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: 3px 3px 0 #fff, 5px 5px 0 rgba(183, 155, 234, .28);
}
.tagline { color: var(--dim); line-height: 1.7; font-size: 14px; }

.panel {
    width: 100%;
    background: var(--panel-grad);
    border: 3px solid var(--line);
    border-radius: 26px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow), var(--sheen);
}

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span { font-size: 12px; color: var(--dim); }

input {
    background: #fbf8ff;
    border: 3px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 700;
}
input:focus { outline: none; border-color: var(--accent); }
#input-room { letter-spacing: 8px; text-align: center; text-transform: uppercase; font-weight: 900; }

button {
    border: 0;
    border-radius: 18px;
    padding: 14px;
    font-size: 15px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: transform .06s, box-shadow .06s, filter .1s;
}
button:active:not(:disabled) { transform: translateY(3px); box-shadow: none !important; }
button:disabled { opacity: .45; cursor: not-allowed; }
@media (hover: hover) {
    button:not(:disabled):hover { filter: brightness(1.05); }
}

.primary {
    background: linear-gradient(165deg, #cab2f5 0%, var(--accent) 55%, #a488e0 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--accent-dark), var(--sheen);
}
.secondary {
    background: linear-gradient(165deg, #ffffff 0%, #f3ecff 100%);
    color: var(--text);
    box-shadow: 0 4px 0 var(--line), var(--sheen);
}
.danger {
    background: linear-gradient(165deg, #ffbdd7 0%, var(--bad) 55%, #f186ae 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--bad-dark), var(--sheen);
}
.quick {
    background: linear-gradient(135deg, #a3ecd5 0%, var(--good) 40%, #7fb8f0 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--good-dark), var(--sheen);
    font-size: 16px;
}

.divider { position: relative; text-align: center; color: var(--dim); font-size: 12px; }
.divider::before {
    content: ""; position: absolute; left: 0; right: 0; top: 50%;
    border-top: 2px dashed var(--line);
}
.divider span { position: relative; background: var(--panel); padding: 0 10px; }

.conn { font-size: 12px; color: var(--dim); }
.label { font-size: 12px; color: var(--dim); }
.hint { font-size: 12px; color: var(--dim); line-height: 1.6; }

.code {
    font-size: 54px;
    letter-spacing: 12px;
    color: var(--accent-dark);
    font-weight: 900;
    text-shadow: 3px 3px 0 #fff;
}

.players { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.players li {
    background: var(--card-grad);
    border: 2px solid var(--line);
    border-radius: 16px;
    padding: 10px 14px;
    text-align: left;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.players .tag,
.players .me,
.players .botTag {
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 999px;
}
.players .tag { background: var(--accent); color: #fff; }
.players .me { background: var(--good); color: #fff; }
.players .botTag { background: #efe8fa; color: var(--dim); }

.howto {
    font-size: 12px;
    color: var(--dim);
    line-height: 1.8;
    background: var(--card-grad);
    border: 2px dashed var(--line);
    border-radius: 20px;
    padding: 14px 16px;
    width: 100%;
}

/* 내 색 배너 */
.role {
    width: 100%;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    border: 3px solid var(--line);
}

/* HUD */
.hud {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    background: var(--panel-grad);
    border: 3px solid var(--line);
    border-radius: 24px;
    padding: 14px 18px;
    box-shadow: var(--shadow);
}
.hud-item { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.hud-item b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--accent-dark); }
.hud-item.grow { flex: 1; }
.hud-item i { font-style: normal; color: var(--text); font-weight: 800; }

.bar {
    height: 14px;
    background: #f3ecff;
    border-radius: 999px;
    overflow: hidden;
    border: 2px solid var(--line);
}
.bar-fill {
    height: 100%;
    width: 0;
    background: var(--bad);
    border-radius: 999px;
    transition: width .05s linear, background .2s;
}

.compass-wrap { align-items: center; }
#compass { width: 76px; height: 76px; }

.stage { position: relative; width: 100%; }
#view {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 24px;
    border: 4px solid var(--line);
    background: #fdfaff;
    box-shadow: var(--shadow);
}

.overlay {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
.overlay b { font-size: 30px; font-weight: 900; }
.stun { background: rgba(120, 180, 230, .32); }
.stun b, .stun span { color: #2f5f86; }
.pause { background: rgba(90, 75, 120, .5); }
.pause b, .pause span { color: #fff; }
.pause span { font-size: 13px; font-weight: 700; }

.footer { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mine b { color: var(--accent-dark); font-size: 16px; }

/* 점수판 */
.scoreboard {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-grad);
    border: 3px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 3px 0 rgba(120, 90, 170, .1);
}
.chip.mineChip { background: #f6f0ff; }
.chip b { color: var(--accent-dark); font-size: 15px; font-weight: 900; }
.chip small { color: var(--dim); font-size: 11px; font-weight: 700; }
.chip small.done { color: var(--good-dark); font-weight: 900; }

.dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1.5px rgba(120, 90, 170, .15);
    flex: none;
}
.with-dot { display: flex; align-items: center; gap: 8px; }
.score { font-weight: 900; color: var(--accent-dark); }

/* 명예의 전당 */
.hall { gap: 10px; }
.hall-title { font-size: 18px; font-weight: 900; color: var(--accent-dark); }
.hall-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.hall-list li {
    background: var(--card-grad);
    border: 2px solid var(--line);
    border-radius: 16px;
    padding: 10px 14px;
    text-align: left;
}
.hall-head { display: flex; align-items: baseline; gap: 8px; }
.hall-rank { font-size: 16px; font-weight: 900; min-width: 34px; }
.hall-head b { font-size: 18px; font-weight: 900; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.hall-head small { font-size: 11px; color: var(--dim); margin-left: auto; }
.hall-team { font-size: 12px; color: var(--text); margin-top: 4px; line-height: 1.5; }

.record {
    width: 100%;
    background: #fff;
    border: 3px solid var(--accent);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow);
}
.record b { color: var(--accent-dark); font-size: 17px; font-weight: 900; }

/* 탭 */
.tabs { display: flex; gap: 8px; width: 100%; }
.hall-tabs { margin-bottom: 2px; }
.tab {
    flex: 1;
    background: #f3ecff;
    color: var(--dim);
    box-shadow: 0 3px 0 var(--line);
    padding: 11px;
    font-size: 14px;
}
.tab.active { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }

/* 내 정보 바 */
.me-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-grad);
    border: 3px solid var(--line);
    border-radius: 999px;
    padding: 8px 10px 8px 18px;
    box-shadow: var(--shadow);
}
.me-name { font-weight: 900; color: var(--accent-dark); flex: 1; text-align: left; }
.me-bar button { padding: 8px 14px; font-size: 13px; }

.wallet-chip {
    background: #fff6e2;
    border: 2px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
}
.wallet-chip b { color: var(--accent-dark); }

/* 상점 모달 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(92, 75, 120, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
    overflow-y: auto;
}
.modal-box {
    width: 100%;
    max-width: 720px;
    background: var(--panel-grad);
    border: 4px solid var(--line);
    border-radius: 28px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 0 rgba(120, 90, 170, .18);
    max-height: 90vh;
}
.shop-head { display: flex; align-items: center; gap: 10px; }
.shop-head .hall-title { flex: 1; text-align: left; }
.shop-head button { padding: 9px 16px; font-size: 13px; }

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    overflow-y: auto;
    min-height: 0; /* 30개로 늘어난 목록이 모달 밖으로 안 밀려나고 이 안에서 스크롤되게 */
    padding: 4px;
}
.shop-card {
    background: var(--card-grad);
    border: 3px solid var(--line);
    border-radius: 18px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
/* 게임 중 가이드 모달 */
.guide-section { text-align: left; }
.guide-section .label { margin-bottom: 6px; display: block; font-weight: 800; }
.guide-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.guide-list li {
    background: var(--card-grad);
    border: 2px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
}
.guide-list .hint { display: inline-block; margin-left: 4px; }
.guide-section + .guide-section { margin-top: 4px; }

.shop-card.equipped { border-color: var(--good); background: #f0fdf8; }
.shop-card b { font-size: 13px; font-weight: 800; }
.shop-card small { color: var(--dim); font-size: 12px; font-weight: 700; }
.shop-card button { width: 100%; padding: 9px; font-size: 13px; border-radius: 12px; }
.shop-preview {
    width: 100%;
    height: auto;
    background: #fff;
    border-radius: 12px;
    border: 2px solid var(--line);
}

.toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 4px 0 rgba(120, 90, 170, .35);
    z-index: 10;
}
