* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg1: #ffffff;
    --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);
    /* 입력창·지갑칩·아바타·카드처럼 사방에서 그냥 흰색으로 하드코딩됐던 "표면" 색.
       변수로 빼두면 라이트 모드는 그대로 #fff고, 다크 스코프에서만 덮어쓸 수 있다. */
    --surface: #ffffff;
    --mine-pill-grad: linear-gradient(165deg, #efe6ff, #fff);
    /* 냥이 게임 판(canvas) 바탕색 — 다크 모드에서만 덮어써진다. 칸 자체의 채우기·글자
       색은 canvas 그리기라 CSS로는 못 건드리니 lemon.js의 lemonDarkOn()이 담당한다. */
    --lemon-canvas-bg: #f1e2c2;
}

/* "냥이 게임만 다크 모드" — 이 attribute가 body에 있을 때만(=지금 냥이 게임 화면일
   때만) 적용되므로 오목·바둑 화면은 전혀 영향을 안 받는다. .lemon-dark 토글 클래스는
   냥이 게임을 벗어나도 켜진 채로 남아있지만(재방문 시 바로 적용되게), 이 선택자
   자체가 lemon-* 화면에서만 걸리니 문제없다. */
body.lemon-dark[data-screen^="lemon"] {
    --bg1: #171225;
    --panel: #211a35;
    --panel-grad: linear-gradient(165deg, #211a35 0%, #291f42 100%);
    --card-grad: linear-gradient(165deg, #241d3a 0%, #2c2247 100%);
    --line: #3d3159;
    --text: #ece6fa;
    --dim: #a89bd4;
    --accent: #b79bea;
    --accent-dark: #cbb0ff;
    --good: #6fccb0;
    --good-dark: #3fae95;
    --bad: #ff9fc0;
    --bad-dark: #e0679a;
    --warn: #ffcf7a;
    --shadow: 0 6px 0 rgba(0, 0, 0, .4);
    --sheen: inset 0 1px 0 rgba(255, 255, 255, .06);
    --surface: #241d3a;
    --mine-pill-grad: linear-gradient(165deg, #342a52, #241d3a);
    --lemon-canvas-bg: #2a2244;
}

body {
    background: var(--bg1);
    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;
}

.screen {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}
#screen-game, #screen-go-game { max-width: 860px; }

.hidden { display: none !important; }

.sound-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);
}
.sound-toggle.muted { opacity: .55; }

/* "냥이 게임만 다크 모드 해줘" + "로그인 후 냥이게임 누르면 그때 다크모드 전환 버튼
   만들어주고 게임할 때는 안보이게해줘" — 기본은 숨김이고, 냥이 게임의 비-플레이
   화면(타이틀·로비·결과) 3개에서만 나타난다. */
.lemon-dark-toggle {
    display: none;
    position: fixed; top: 16px; left: 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);
}
body[data-screen="lemon-title"] .lemon-dark-toggle,
body[data-screen="lemon-lobby"] .lemon-dark-toggle,
body[data-screen="lemon-result"] .lemon-dark-toggle {
    display: block;
}

/*
 * 데스크톱에서는 wrapper가 박스를 만들지 않아(display: contents) lang-picker·
 * contact-btn이 각자 자기 fixed 위치(우측 상단 / 우측 하단)를 그대로 쓴다.
 * 모바일에서만 이 wrapper가 flex row로 바뀌면서 둘을 우측 하단에 나란히 붙인다
 * (아래 미디어 쿼리 참고) — 언어 선택이 화면 위에 계속 떠서 콘텐츠를 가리던 문제 해결.
 */
.bottom-right-bar { display: contents; }

.contact-btn {
    position: fixed; bottom: 16px; right: 16px; z-index: 30;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 999px;
    background: var(--panel-grad); color: var(--text);
    box-shadow: var(--shadow); border: 3px solid var(--line);
    font-weight: 800; font-size: 13px; text-decoration: none;
}
.contact-btn:hover { background: rgba(183, 155, 234, .18); }

.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) {
    .bottom-right-bar {
        display: flex; position: fixed; bottom: 16px; right: 16px; z-index: 30;
        align-items: center; gap: 6px;
    }
    /* 부모(.bottom-right-bar)가 이제 fixed로 자리를 잡으니, 둘 다 그 안에서 나란히
       흐르도록 각자의 fixed 위치는 꺼준다. */
    .lang-picker, .contact-btn { position: static; }
    .lang-btn { padding: 5px 7px; font-size: 11px; }
    /* "모바일에서 게임 플레이할때는 언어 선택이랑 문의 빼줘" + "오른쪽 위 소리 끄기도
       거슬려" — 실제 대국 화면에서는 판 위·아래를 가리니 둘 다 숨긴다(로비·결과 화면
       등에서는 그대로 둠). */
    body[data-screen="game"] .bottom-right-bar,
    body[data-screen="go-game"] .bottom-right-bar,
    body[data-screen="lemon-game"] .bottom-right-bar,
    body[data-screen="game"] .sound-toggle,
    body[data-screen="go-game"] .sound-toggle,
    body[data-screen="lemon-game"] .sound-toggle {
        display: none;
    }
}

.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-emoji { font-size: 40px; }
.logo { font-size: 28px; letter-spacing: 1px; color: var(--accent-dark); }
.tagline { color: var(--dim); font-size: 13px; line-height: 1.6; font-weight: 500; }

/* 로그인 직후 게임 선택(오목/바둑/레몬게임) 카드 3개 — 좁은 화면에선 줄바꿈된다 */
.game-pick-row { display: flex; flex-wrap: wrap; gap: 14px; width: 100%; }
.game-pick-card {
    flex: 1 1 130px; display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: var(--card-grad); border: 3px solid var(--line); border-radius: 20px;
    padding: 22px 12px; cursor: pointer; box-shadow: var(--shadow), var(--sheen);
}
.game-pick-card:hover { border-color: var(--accent); }
.game-pick-emoji { font-size: 36px; }
.game-pick-name { font-size: 17px; font-weight: 800; color: var(--accent-dark); }
.game-pick-desc { font-size: 11px; color: var(--dim); text-align: center; }

.panel {
    width: 100%;
    background: var(--panel-grad);
    border: 3px solid var(--line);
    border-radius: 22px;
    padding: 18px;
    box-shadow: var(--shadow), var(--sheen);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tabs { display: flex; gap: 6px; background: rgba(224, 210, 247, .35); padding: 4px; border-radius: 999px; }
.tab {
    flex: 1; border: none; background: transparent; color: var(--dim);
    font-weight: 700; font-size: 13px; padding: 9px 6px; border-radius: 999px; cursor: pointer;
}
.tab.active { background: #fff; color: var(--accent-dark); box-shadow: var(--shadow); }
.mode-tabs .tab { font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 12px; color: var(--dim); }
.field input {
    border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px;
    font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
}
.field input:focus { outline: none; border-color: var(--accent); }

button {
    font-family: inherit; cursor: pointer; border-radius: 14px; border: none;
    font-weight: 800; font-size: 14px; padding: 12px 16px;
    box-shadow: var(--shadow), var(--sheen);
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: linear-gradient(165deg, #cbb0f5, var(--accent-dark)); color: #fff; }
.secondary { background: var(--panel-grad); color: var(--text); border: 2px solid var(--line); }
.quick { background: linear-gradient(165deg, #ffe08a, var(--warn)); color: #6b4c00; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; width: 100%; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.hint { color: var(--dim); font-size: 12px; line-height: 1.6; font-weight: 500; }
.label { color: var(--dim); font-size: 12px; font-weight: 700; }
.code { font-size: 40px; letter-spacing: 8px; color: var(--accent-dark); }

.conn { font-size: 12px; color: var(--dim); }

.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: rgba(60, 45, 90, .92); color: #fff; padding: 10px 18px;
    border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.hidden { display: none; }

/* ------------------------------------------------------------ 상단 바 / 지갑 / 랭크 */

.me-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.me-name { font-weight: 800; color: var(--accent-dark); }
.wallet-chip {
    display: inline-flex; align-items: center; gap: 4px; background: var(--surface);
    border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px;
}

.rank-badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
    border-radius: 999px; font-size: 12px; background: #fff; border: 3px solid #b08d57;
}
.rank-badge.tier-bronze { border-color: #c07a4d; background: linear-gradient(165deg, #fff, #f6e3d3); }
.rank-badge.tier-silver { border-color: #9aa3ad; background: linear-gradient(165deg, #fff, #eef1f4); }
.rank-badge.tier-gold { border-color: #e0b23a; background: linear-gradient(165deg, #fff, #fbeec2); box-shadow: 0 0 10px rgba(224, 178, 58, .35); }
.rank-badge.tier-platinum { border-color: #7fd8d0; background: linear-gradient(165deg, #fff, #e2fbf8); box-shadow: 0 0 10px rgba(127, 216, 208, .4); }
.rank-badge.tier-emerald { border-color: #35c47a; background: linear-gradient(165deg, #fff, #dcf9e9); box-shadow: 0 0 12px rgba(53, 196, 122, .45); }
.rank-badge.tier-master {
    border-color: transparent; background: linear-gradient(165deg, #ffe0f5, #e4d3ff);
    box-shadow: 0 0 14px rgba(183, 108, 234, .55);
    border-image: linear-gradient(135deg, #ff9ee8, #b79bea, #8fc4f0) 1;
    border-width: 3px; border-style: solid;
}
.rank-badge.tier-challenger {
    border: 3px solid transparent;
    background: linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, #ff9fc0, #ffcf7a, #86dcc4, #8fc4f0, #b79bea) border-box;
    box-shadow: 0 0 18px rgba(183, 108, 234, .65);
    animation: rankGlow 2.4s ease-in-out infinite;
}
@keyframes rankGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 159, 192, .5); }
    50% { box-shadow: 0 0 22px rgba(143, 196, 240, .75); }
}

/* 내 캐릭터 아바타 — 랭크 티어 테두리는 .rank-badge와 같은 색상 규칙을 정사각형에 그대로 적용 */
.avatar-frame {
    width: 180px; height: 180px; padding: 0; border-radius: 36px; overflow: hidden;
    background: var(--surface); border: 6px solid #c07a4d; box-shadow: var(--shadow), var(--sheen);
    cursor: pointer; background-size: cover; background-position: center;
}
.avatar-frame canvas { width: 100%; height: 100%; display: block; }
.avatar-frame.tier-bronze { border-color: #c07a4d; }
.avatar-frame.tier-silver { border-color: #9aa3ad; }
.avatar-frame.tier-gold { border-color: #e0b23a; box-shadow: 0 0 12px rgba(224, 178, 58, .4); }
.avatar-frame.tier-platinum { border-color: #7fd8d0; box-shadow: 0 0 12px rgba(127, 216, 208, .45); }
.avatar-frame.tier-emerald { border-color: #35c47a; box-shadow: 0 0 14px rgba(53, 196, 122, .5); }
.avatar-frame.tier-master {
    border-color: transparent;
    background: linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, #ff9ee8, #b79bea, #8fc4f0) border-box;
    box-shadow: 0 0 16px rgba(183, 108, 234, .6);
}
.avatar-frame.tier-challenger {
    border-color: transparent;
    background: linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, #ff9fc0, #ffcf7a, #86dcc4, #8fc4f0, #b79bea) border-box;
    box-shadow: 0 0 20px rgba(183, 108, 234, .7);
    animation: rankGlow 2.4s ease-in-out infinite;
}

/* ------------------------------------------------------------ 로비 / 참가자 목록 */

.players { list-style: none; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.players li {
    display: flex; align-items: center; gap: 8px; background: #fff;
    border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px;
}
.swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.players li .name { flex: 1; text-align: left; font-weight: 700; }
.badge-host, .badge-bot, .badge-ready { font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 800; }
.badge-host { background: var(--warn); color: #6b4c00; }
.badge-bot { background: var(--line); color: var(--dim); }
.badge-ready { background: var(--good); color: #1c5a4a; }
.badge-notready { background: #f1e9fb; color: var(--dim); font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.badge-disconnected { background: var(--warn); color: #6b4c00; font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.badge-team { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 800; color: #fff; }
.badge-team-a { background: #ff6b6b; }
.badge-team-b { background: #4dabf7; }
.badge-team-swap { cursor: pointer; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6) inset; }
.badge-team-swap:hover { filter: brightness(1.1); }

.kick-btn {
    flex-shrink: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%;
    background: #fff; border: 2px solid var(--bad); color: var(--bad-dark);
    font-size: 11px; font-weight: 800; line-height: 1; box-shadow: none;
}
.kick-btn:hover { background: var(--bad); color: #fff; }

/* 캐릭터 아바타 카드 — 로비/대기실과 대국 화면(보드 위)에서 공유하는 가로 배치, 최대 4명 */
.player-cards {
    display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px;
    justify-content: center; width: 100%;
}
.player-card {
    position: relative; width: 94px; display: flex; flex-direction: column; align-items: center;
    gap: 4px; background: var(--surface); border: 2px solid var(--line); border-radius: 16px;
    padding: 8px 6px 7px; box-shadow: var(--shadow);
}
.player-card.turn { border-color: var(--good-dark); box-shadow: 0 0 8px rgba(63, 174, 149, .4); }
.player-card.disconnected { opacity: .6; border-style: dashed; border-color: var(--warn); }
.player-avatar {
    width: 56px; height: 56px; border-radius: 14px; overflow: hidden; background: var(--surface);
    border: 3px solid var(--accent); background-size: cover; background-position: center;
}
.player-avatar canvas { width: 100%; height: 100%; display: block; }
.player-card-name {
    font-size: 11px; font-weight: 800; width: 100%; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; text-align: center;
}
/*
 * 명찰(decorNameplate) 배경 이미지 — 원본이 가로로 긴 배너(1024×384)라서 박스도
 * 같은 비율(aspect-ratio)로 맞춰야 글자 한 줄 높이에 짓눌려 찌그러지지 않는다.
 * 예전엔 글자 크기만큼만 박스가 생겨서 배너가 얇은 띠로 눌리고 글자가 위아래로
 * 삐져나왔다 — 이제 박스 자체를 배너 비율로 키우고 그 안에서 글자를 가운데 정렬한다.
 * 다양한 배너 위에서도 글자가 읽히게 흰 텍스트 셰도우로 후광을 준다.
 */
.player-card-name.has-nameplate {
    aspect-ratio: 1024 / 384; display: flex; align-items: center; justify-content: center;
    background-size: 100% 100%; background-position: center; background-repeat: no-repeat;
    padding: 0 18%; border-radius: 6px; color: #3c2d5a;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 1px 1px #fff;
}
.player-card-badges { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
/* 대국 참가자 카드용 축소 랭크 뱃지 — .rank-badge 색상 규칙은 그대로 쓰고 크기만 줄인다 */
.player-card-badges .rank-badge.card-rank-badge {
    padding: 2px 8px; font-size: 9px; border-width: 2px; gap: 2px; font-weight: 800;
}
.player-cards.lobby .player-card-badges .rank-badge.card-rank-badge { font-size: 11px; padding: 3px 10px; border-width: 3px; }
.card-kick { position: absolute; top: -7px; right: -7px; }

.howto { font-size: 12px; color: var(--dim); line-height: 1.7; background: rgba(255, 255, 255, .5); border-radius: 14px; padding: 12px; }

/* 로비 캐릭터 카드 — 참가자 파악이 우선이라 상점/대국 화면보다 큼직하게 */
.player-cards.lobby { gap: 14px; }
.player-cards.lobby .player-card { width: 164px; padding: 14px 10px 12px; gap: 8px; }
.player-cards.lobby .player-avatar { width: 122px; height: 122px; border-radius: 24px; border-width: 5px; }
.player-cards.lobby .player-card-name { font-size: 14px; }
.player-cards.lobby .player-card-badges { gap: 4px; }
.player-cards.lobby .badge-host, .player-cards.lobby .badge-bot,
.player-cards.lobby .badge-ready, .player-cards.lobby .badge-notready,
.player-cards.lobby .badge-disconnected { font-size: 11px; padding: 3px 8px; }

/* 로비 액션 버튼 — 세로로 쌓지 않고 가로로 나열, 공간 부족하면 자동 줄바꿈 */
.lobby-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.lobby-actions button { flex: 1 1 120px; }

/* 1대1대1(3인) 전용 규칙 선택 — 정확히 3명일 때만 로비에 보인다 */
.trio-rule-panel {
    width: 100%; background: rgba(224, 210, 247, .25); border-radius: 14px; padding: 10px 12px;
    display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
}
.trio-rule-panel .label { font-size: 12px; }
.trio-rule-options { display: flex; gap: 6px; }
.trio-rule-btn {
    flex: 1; border: 2px solid var(--line); background: #fff; color: var(--dim);
    font-weight: 700; font-size: 12px; padding: 8px 6px; border-radius: 12px; cursor: pointer;
}
.trio-rule-btn.active { border-color: var(--accent); background: var(--card-grad); color: var(--accent-dark); box-shadow: var(--shadow); }
.trio-rule-panel .hint { margin: 0; }

@media (max-width: 640px) {
    .player-cards.lobby .player-card { width: 128px; padding: 10px 7px 9px; }
    .player-cards.lobby .player-avatar { width: 92px; height: 92px; }
    .player-cards.lobby .player-card-name { font-size: 12px; }
}

/* ------------------------------------------------------------ 주사위 모달 */

.modal {
    position: fixed; inset: 0; background: rgba(60, 45, 90, .45);
    display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
    background: var(--panel-grad); border: 3px solid var(--line); border-radius: 22px;
    padding: 20px; width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
}
.dice-box { align-items: center; text-align: center; }
.dice-list { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.die {
    width: 60px; height: 68px; border-radius: 14px; background: #fff; border: 3px solid var(--line);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    box-shadow: var(--shadow);
}
.die-face { width: 38px; height: 38px; }
.die small { font-size: 10px; color: var(--dim); font-weight: 700; }
.die.rolling { animation: diceRoll .18s ease-in-out infinite; border-color: var(--accent); }
@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(-6deg) scale(1.06); }
}
.dice-order { list-style: decimal; text-align: left; padding-left: 22px; font-size: 13px; font-weight: 700; }
.dice-order.hidden { display: none; }

.hall-title { font-size: 16px; color: var(--accent-dark); }

/* ------------------------------------------------------------ 대국 화면 */

.turn-banner {
    width: 100%; padding: 10px 16px; border-radius: 14px; font-weight: 800; font-size: 15px;
    background: var(--panel-grad); border: 2px solid var(--line); color: var(--text);
}
.turn-banner.mine { background: linear-gradient(165deg, #d8f5ea, var(--good)); color: #1c5a4a; }
.win-length-hint { margin-top: -6px; }

.board-row { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; }
.stage { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; }
/* 바둑 점수판(따낸 돌 수) */
.go-score-strip {
    display: flex; gap: 16px; justify-content: center; font-size: 13px; font-weight: 700;
    color: var(--dim); width: 100%;
}
.go-score-strip b { color: var(--text); }

/* 플레이어 카드 맨 아래에 붙는 실시간 시계(지참 시간 / 초읽기) */
.go-clock {
    margin-top: 6px; text-align: center; font-size: 13px; font-weight: 800;
    color: var(--dim); font-variant-numeric: tabular-nums;
}
.go-clock.byoyomi { color: var(--accent-dark); }
.go-clock.urgent { color: var(--bad-dark); animation: goClockPulse 1s ease-in-out infinite; }
@keyframes goClockPulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* 대국 화면에서 언제든 눌러 규칙을 다시 볼 수 있는 링크형 버튼 */
.link-btn {
    background: none; border: none; padding: 2px 4px; margin-top: -4px;
    color: var(--accent-dark); font-size: 12px; font-weight: 700; text-decoration: underline;
    cursor: pointer; align-self: center;
}

/* 바둑 결과 화면 — 흑/백 최종 집 점수 비교 */
.go-result-score { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.go-score-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-grad); border: 2px solid var(--line); border-radius: 12px;
    padding: 10px 14px; font-weight: 800; font-size: 15px;
}
.go-score-row b { font-size: 20px; color: var(--accent-dark); }

#board, #go-board, #result-recap-board {
    width: 100%; max-width: 600px; aspect-ratio: 1 / 1;
    background: var(--lemon-canvas-bg); border-radius: 16px; box-shadow: var(--shadow);
    touch-action: manipulation;
}
/* 결과 화면의 마지막 판 재현 — "바로 결과창으로 넘어가니까 왜 졌는지 모르겠다"는
   피드백 때문에 추가. 승리 라인이 하이라이트된 채로 끝난 판을 다시 보여준다. */
.result-recap-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* ------------------------------------------------------------ 레몬게임 */

.lemon-grid-wrap { width: 100%; display: flex; justify-content: center; }
/* 캔버스 딱 그 크기만큼만 차지하는 위치 기준 컨테이너 — 카운트다운 오버레이가
   .lemon-grid-wrap(100% 폭) 전체가 아니라 캔버스 위에만 정확히 겹치도록 한다. */
.lemon-grid-stage { position: relative; width: 100%; max-width: 420px; }
/* 캔버스의 실제 픽셀 크기(width/height 속성)를 lemon.js가 화면 폭에 따라 세로형(모바일)/
   가로형(웹, 판을 눕혀서 그림)으로 매 프레임 맞춰준다 — 그래서 CSS에는 고정 aspect-ratio를
   안 두고 height:auto로 캔버스 자신의 intrinsic 비율을 그대로 따라가게 한다. */
#lemon-grid-canvas {
    width: 100%; height: auto; max-width: 420px;
    background: var(--lemon-canvas-bg); border-radius: 16px; box-shadow: var(--shadow);
    touch-action: none; /* 드래그 제스처를 브라우저가 스크롤로 가로채지 않게 */
}
/* "3 -> 2 -> 1 숫자 카운트 다음에 시작" — 라운드 시작 직후 서버가 endsAt을 카운트다운
   길이만큼 미뤄주는 동안(LemonRoom.START_COUNTDOWN_MS) 판 위에 큼직한 숫자를 띄워
   드래그를 막아둔다. */
.lemon-countdown-overlay {
    position: absolute; inset: 0; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(30, 20, 50, .38);
}
.lemon-countdown-overlay.hidden { display: none; }
#lemon-countdown-number {
    font-size: 88px; font-weight: 900; color: #fff;
    text-shadow: 0 4px 16px rgba(0,0,0,.35);
    animation: lemon-countdown-pop .5s ease;
}
@keyframes lemon-countdown-pop {
    from { transform: scale(.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
/* "웹은 가로로 길게" 요청 — 좁은 화면 기준(640px)을 넘으면 판이 눕혀 그려지니(lemon.js
   lemonGeometry 참고) 화면·캔버스 폭도 그만큼 넉넉하게 넓혀준다. */
@media (min-width: 641px) {
    #screen-lemon-game { max-width: 900px; }
    #lemon-grid-canvas, .lemon-grid-stage { max-width: 760px; }
}
/* 배틀(최대 6인) 중 상단에 뜨는 실시간 순위 스코어보드 — 점수 내림차순으로 알약(pill)이
   나열된다. 인원이 많아도 좁은 화면에 다 들어가게 줄바꿈한다. */
.lemon-scoreboard { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.lemon-score-pill {
    display: flex; align-items: center; gap: 6px; min-width: 0;
    background: var(--card-grad); border: 2px solid var(--line); border-radius: 999px;
    padding: 5px 12px 5px 8px; font-size: 12px; font-weight: 700;
}
.lemon-score-pill.mine { border-color: var(--accent); background: var(--mine-pill-grad); }
.lemon-score-pill.leader { border-color: var(--warn); }
.lemon-score-pill-rank { color: var(--dim); font-weight: 800; }
.lemon-score-pill-name { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lemon-score-pill-score { color: var(--accent-dark); font-size: 14px; font-weight: 800; }

/* 배틀 중 다른 플레이어들의 판을 작게 실시간으로 보여주는 미니 프리뷰(테트리스 멀티
   플레이의 상대방 보드처럼) — "다른 사람것들도 실시간으로 조금하게 보이게" 요청. */
.lemon-mini-boards { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lemon-mini-board {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: var(--card-grad); border: 1px solid var(--line); border-radius: 8px;
    padding: 4px 6px;
}
.lemon-mini-board-name { font-size: 10px; color: var(--dim); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lemon-mini-board-canvas { display: block; background: var(--lemon-canvas-bg); border-radius: 4px; }

/* 결과 화면의 "마지막 판 리캡" — 오목의 result-recap-wrap과 같은 취지("바로 결과창으로
   넘어가니까 왜 졌는지 모르겠다")를 레몬게임에 맞게: 끝난 시점 내 판을 다시 보여주고
   그때 놓친(합 10인 인접 칸) 자리를 옅게 하이라이트한다. */
#lemon-result-recap-board {
    width: 100%; max-width: 220px; height: auto;
    background: var(--lemon-canvas-bg); border-radius: 12px; box-shadow: var(--shadow);
}

/* 대국 중 캐릭터 카드 — 보드 양옆이라 자리가 좁지만, 꾸민 티가 나야 하니 크게 */
.player-cards.side { flex: 0 0 auto; flex-direction: column; width: 148px; gap: 10px; }
.player-cards.side .player-card { width: 148px; padding: 12px 8px 10px; }
.player-cards.side .player-avatar { width: 108px; height: 108px; border-radius: 22px; border-width: 5px; }
.player-cards.side .player-card-name { font-size: 13px; }

/*
 * 모바일 대국 화면: 예전엔 보드 양옆에 캐릭터 카드를 크게 두는 데스크톱 레이아웃을
 * 그대로 좁은 화면에 욱여넣어서, 카드는 큼직한데 정작 오목판은 가운데 조그맣게
 * 짜부라졌다. 모바일에서는 순서만 바꿔서(order) 왼쪽·오른쪽 카드 컨테이너를 보드
 * 위 한 줄로 모으고(카드 자체도 세로 배치 대신 가로로 나열), 보드는 그 아래에서
 * 폭 전체를 그대로 쓰게 한다.
 */
@media (max-width: 640px) {
    .board-row { flex-wrap: wrap; justify-content: center; gap: 6px; }
    .player-cards.side {
        order: 1; flex-direction: row; flex-wrap: wrap; justify-content: center;
        width: auto; gap: 6px;
    }
    .stage { order: 2; flex: 1 1 100%; width: 100%; }
    .player-cards.side .player-card { width: 76px; padding: 5px 3px 4px; gap: 3px; }
    .player-cards.side .player-avatar { width: 50px; height: 50px; border-radius: 12px; border-width: 3px; }
    .player-cards.side .player-card-name { font-size: 9px; }
    .player-cards.side .player-card-badges { gap: 2px; }
    .player-cards.side .player-card-badges .rank-badge.card-rank-badge { font-size: 7px; padding: 1px 4px; border-width: 1px; }
    .player-cards.side .badge-host, .player-cards.side .badge-bot, .player-cards.side .badge-ready,
    .player-cards.side .badge-notready, .player-cards.side .badge-disconnected, .player-cards.side .badge-team {
        font-size: 7px; padding: 1px 4px;
    }
}


.footer { display: flex; gap: 8px; width: 100%; }
.footer button { flex: 1; }

/* ------------------------------------------------------------ 결과 화면 */

.record {
    width: 100%; background: var(--panel-grad); border: 3px solid var(--line); border-radius: 18px;
    padding: 14px; font-size: 14px; font-weight: 700; display: flex; flex-direction: column; gap: 4px;
}
.record.hidden { display: none; }
.record .rank-loss { color: var(--bad-dark); }

/* ------------------------------------------------------------ 상점 */

.modal-box.shop-box { max-width: 920px; }

.shop-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shop-head .hall-title { flex: 1; text-align: left; font-size: 20px; }

.shop-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px;
    max-height: 64vh; overflow-y: auto; padding: 3px;
}
.shop-card {
    background: var(--card-grad); border: 2px solid var(--line); border-radius: 18px;
    padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px;
}
.shop-card canvas { width: 180px; height: 180px; }
.shop-card .name { font-weight: 700; text-align: center; min-height: 34px; font-size: 14px; }
.shop-card .price { color: var(--dim); font-size: 12px; }
.shop-card button { width: 100%; padding: 9px 6px; font-size: 12px; }
.shop-card.equipped { border-color: var(--good-dark); }
.shop-card.owned .price { display: none; }

.decor-subtabs { margin-top: -2px; }
.decor-subtabs.hidden { display: none; }

/* ------------------------------------------------------------ 내 정보(모드별 전적) */

.myinfo-body { display: flex; flex-direction: column; gap: 10px; }
.myinfo-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--card-grad); border: 2px solid var(--line); border-radius: 14px;
    padding: 12px 16px;
}
.myinfo-mode { font-weight: 800; font-size: 14px; }
.myinfo-stats { font-size: 13px; color: var(--dim); text-align: right; }
.myinfo-stats b { color: var(--text); }

@media (max-width: 640px) {
    body { padding: 12px; }
    .modal-box { padding: 14px; }
    .shop-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 58vh; }
    .shop-card canvas { width: 130px; height: 130px; }
}
