/* 어두운 방에서 폰으로 보는 화면입니다. 밝기를 낮추고, 누를 곳을 크게. */

:root {
    --bg: #0d0b14;
    --bg2: #16121f;
    --line: #2a2338;
    --ink: #f2eefb;
    --dim: #9a90b3;
    --faint: #6b6383;
    --hot: #ff5d73;
    --warm: #ffb648;
    --cool: #61d0ff;
    --good: #57e08a;
    --gold: #ffd166;
    --r: 16px;
    --pad: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 글자를 잡히지 않게 합니다.
   빠르게 두드리는 게임인데, 손가락이 조금만 미끄러지면 글자가 선택되고
   "구글로 검색" 메뉴가 올라옵니다. 그 사이에 박자를 놓칩니다. 홈 화면에
   앱으로 놓아도 같은 엔진이라 증상이 똑같습니다.

   처음에는 body 에만 걸고 상속에 맡겼는데, 그래도 잡히는 곳이 남았습니다.
   단추처럼 브라우저가 제 스타일을 얹는 요소는 상속을 그대로 받지 않기
   때문입니다. 그래서 전부에 걸고, 복사해야 하는 것만 다시 엽니다 —
   방 코드(.selectable)와 글자 입력칸. */
* {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.selectable, .selectable *, input, textarea {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}
/* 잡히더라도 눈에 안 띄게. 잡히는 순간을 아예 없애는 것이 먼저지만,
   빠져나가는 것이 하나쯤 있어도 화면이 번쩍이지는 않습니다. */
::selection { background: rgba(255, 209, 102, .3); }

/* 두 번 두드려 확대되는 것과 그때 생기는 지연을 없앱니다. 자리(.seat)는
   끌어서 옮겨야 해서 따로 touch-action: none 을 씁니다. */
button { touch-action: manipulation; }

/* hidden 은 브라우저 기본 규칙이라 클래스에 display 를 적으면 그냥 집니다.
   덮개 하나가 안 숨어서 화면 전체가 뿌예지는 사고를 여기서 막습니다. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
        'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    /* 세로 overscroll 을 막으면 "당겨서 새로고침" 도 같이 막힙니다. 화면이
       튀는 것보다 새로고침이 안 되는 쪽이 훨씬 답답해서 열어 뒀습니다.
       실수로 새로고침해도 같은 자리·같은 점수로 돌아옵니다. */
    overscroll-behavior-x: contain;
}

body.locked { overflow: hidden; }

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(60% 40% at 20% 0%, #2a1b3d 0%, transparent 60%),
        radial-gradient(50% 40% at 90% 10%, #1b2b45 0%, transparent 60%);
    opacity: .8;
    pointer-events: none;
    z-index: -1;
}

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    min-height: 100dvh;
}

h1, h2 { margin: 0 0 6px; font-weight: 800; letter-spacing: -.02em; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
p { margin: 0 0 10px; }
.muted { color: var(--dim); font-size: 14px; }
ul { margin: 6px 0 0; padding-left: 18px; }
li { margin: 3px 0; color: var(--dim); font-size: 14px; }

/* ---- 공통 부품 ---- */

.screen { display: flex; flex-direction: column; gap: 14px; }

.card {
    background: var(--bg2);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--pad);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field {
    width: 100%;
    background: #0a0810;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    font: inherit;
    padding: 13px 14px;
}
.field:focus { outline: none; border-color: var(--cool); }
.field-label { font-size: 13px; color: var(--dim); font-weight: 600; }
.code-field { text-transform: uppercase; letter-spacing: .18em; font-weight: 800; }

.btn-row { display: flex; gap: 8px; }
.btn-row.center { justify-content: center; }
/* 봇 난이도. 사람 관리의 봇 줄에 작은 단추들과 같은 키로 앉습니다. */
.bot-level {
    flex: 0 0 auto;
    background: #1a1526; color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 6px 8px; font: inherit; font-size: 12px; font-weight: 700;
}

.btn {
    flex: 1;
    background: #221a30;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 12px;
    padding: 13px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #ff5d73, #ff8f5d); border-color: transparent; color: #1a0f14; }
.btn.go { background: linear-gradient(135deg, #57e08a, #61d0ff); border-color: transparent; color: #06180f; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.danger { color: var(--hot); }
.btn.slim { flex: 0 0 auto; padding: 10px 14px; font-size: 14px; }
.btn.wide { flex: 1 1 100%; }
.btn:disabled { opacity: .35; }

.icon {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--dim);
    font-size: 17px;
    cursor: pointer;
}
.icon-space { width: 38px; }

.topbar { display: flex; align-items: center; gap: 8px; }
.topbar-title { flex: 1; font-weight: 700; font-size: 15px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hint { color: var(--faint); font-size: 13px; text-align: center; line-height: 1.6; }
.foot { color: var(--faint); font-size: 12px; text-align: center; margin-top: auto; padding-top: 20px; }
.empty { color: var(--faint); text-align: center; padding: 30px 0; }

/* ---- 홈 ---- */

.brand { text-align: center; padding: 26px 0 6px; }
.brand-mark { font-size: 54px; line-height: 1; filter: drop-shadow(0 6px 18px rgba(255, 93, 115, .35)); }
.brand p { color: var(--dim); font-size: 14px; margin: 4px 0 0; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.switch input { width: 20px; height: 20px; accent-color: var(--hot); }

/* ---- 방 목록 ---- */

.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
    padding: 13px 14px; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.room-item:active { transform: scale(.99); }
.room-item-main { flex: 1; min-width: 0; }
.room-item-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.room-item-sub { font-size: 13px; color: var(--faint); }
.room-item-code { font-weight: 800; letter-spacing: .1em; color: var(--gold); }
.lock { font-size: 12px; }

/* ---- 방 화면 ---- */

.room { gap: 10px; }

/* 한 판의 남은 시간. 게임 안의 초읽기와 헷갈리면 안 되므로 위쪽에 가늘게
   깔고 색도 죽입니다. 마지막 10초에만 눈에 들어오게 합니다. */
.roundbar {
    position: relative;
    height: 3px;
    border-radius: 2px;
    background: #1c1729;
    margin: -2px 0 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    color: var(--hot);
    line-height: 3px;
    overflow: visible;
}
.roundbar::after {
    content: '';
    position: absolute; left: 0; right: 0; top: 0; height: 3px;
    border-radius: 2px;
    transform-origin: left;
    transform: scaleX(var(--p, 0));
    background: var(--line);
    transition: background .3s;
}
.roundbar.urgent::after { background: var(--hot); }

.stage-headline {
    text-align: center;
    font-size: clamp(20px, 6vw, 26px);
    font-weight: 800;
    letter-spacing: -.02em;
    min-height: 34px;
    transition: color .2s;
}
.stage-sub { text-align: center; color: var(--dim); font-size: 14px; min-height: 21px; margin: -6px 0 2px; }

.tone-you { color: var(--gold); }
.tone-warn { color: var(--warm); }
.tone-good { color: var(--good); }
.tone-bad { color: var(--hot); }
.tone-idle { color: var(--ink); }

/* ---- 사람 원 ---- */

/* 자리 하나는 [배지] [얼굴] [이름] [점수] 로 쌓여 있습니다. 이걸 통째로
   원 위에 가운데 맞춤 하면 얼굴이 위로 밀려서, 배지와 왕관이 상자 밖으로
   나가 윗줄 글자를 덮습니다.

   처음에는 .ringbox 에 padding-top 을 줘 봤는데 아무 일도 안 일어났습니다.
   .ring 이 position:absolute; inset:0 이라 패딩 박스 기준으로 잡히고,
   패딩 영역까지 그대로 덮기 때문입니다. 그래서 패딩이 아니라 .ring 의
   위아래를 직접 물립니다.

   남는 자리 때문에 원은 살짝 눌린 타원이 되는데, 앉은 자리를 위에서
   비스듬히 본 것 같아서 오히려 자연스럽습니다. */
.ringbox {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 400px;
    margin: 0 auto;
}
.ring {
    position: absolute;
    top: 26px;      /* 배지와 왕관이 들어갈 자리 */
    left: 0;
    right: 0;
    bottom: 22px;   /* 이름이 들어갈 자리. 점수는 아래 띠에만 있습니다 */
}
.ring::before {
    content: '';
    position: absolute; inset: 12%;
    border: 1px dashed var(--line);
    border-radius: 50%;
}

.seat {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 21%;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transition: left .25s cubic-bezier(.3, 1.4, .5, 1), top .25s cubic-bezier(.3, 1.4, .5, 1);
    touch-action: none;
}
/* 이름·점수 높이의 절반. 이만큼 내려야 얼굴 한가운데가 원 위에 얹힙니다. */
.seat { transform: translate(-50%, calc(-50% + 12px)); }
.ring[data-n="9"] .seat, .ring[data-n="10"] .seat,
.ring[data-n="11"] .seat, .ring[data-n="12"] .seat { width: 18%; }
.ring[data-n="13"] .seat, .ring[data-n="14"] .seat,
.ring[data-n="15"] .seat, .ring[data-n="16"] .seat { width: 16%; }

.seat-face {
    position: relative;
    width: 100%; aspect-ratio: 1;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #1b1528;
    border: 2px solid var(--seat-color, var(--line));
    font-size: clamp(18px, 6.5vw, 28px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .45);
    transition: box-shadow .2s, transform .15s, border-color .2s;
}
/* 인디언 포커. 얼굴 자리에 카드가 붙습니다 — 이마에 붙인 그 카드입니다.
   공개되면 한 번 뒤집히고, 다이한 카드는 타서 없어집니다. */
.seat.card .seat-face {
    border-radius: 16%;
    background: linear-gradient(160deg, #fdfcf7, #e4dfd0);
    color: #1b1528;
    font-weight: 900;
    letter-spacing: -.02em;
}
.seat.flip .seat-face { animation: cardFlip .55s cubic-bezier(.4, 0, .2, 1); }
/* 숫자는 카드가 반쯤 돌아간 뒤에 나타납니다. 안 그러면 뒷면에 답이
   적혀 있는 꼴이 됩니다. */
.seat.flip .seat-avatar { animation: cardFace .55s cubic-bezier(.4, 0, .2, 1); }
@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}
@keyframes cardFace {
    0%, 49% { opacity: 0; }
    50%, 100% { opacity: 1; }
}
.seat.card.burn .seat-face { animation: cardBurn 1.3s ease-in forwards; }
/* 남은 카드 중 제일 낮은 것. 결과를 들이밀기 전에 몇 번 부풀었다 가라앉아
   "저거구나" 할 틈을 줍니다. */
.seat.pulse .seat-face { animation: cardPulse .52s ease-in-out infinite; }
/* 카드가 붙은 게임(인디언)에서는 빨갛게까지 달아 둡니다. 만두의 편 손은
   세라고 흔드는 것이지 지목이 아니라서 움직이기만 합니다. */
.seat.card.pulse .seat-face {
    border-color: var(--hot);
    box-shadow: 0 0 18px rgba(255, 93, 115, .55);
}
@keyframes cardPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.22); }
}
@keyframes cardBurn {
    0% { opacity: 1; }
    35% { filter: sepia(1) saturate(7) hue-rotate(-24deg) brightness(1.3); }
    100% { opacity: 0; transform: scale(.62) rotate(-10deg); filter: sepia(1) saturate(7) brightness(.35); }
}
.seat.me .seat-face { box-shadow: 0 0 0 3px rgba(255, 209, 102, .35), 0 3px 12px rgba(0, 0, 0, .45); }
.seat.lit .seat-face { transform: scale(1.12); box-shadow: 0 0 22px var(--seat-color, #fff); }
.seat.off { opacity: .35; filter: grayscale(1); }
.seat.bot .seat-face { border-style: dashed; }
.seat.draggable .seat-face { cursor: grab; }
.seat.dragging { z-index: 5; transition: none; }
.seat.dragging .seat-face { transform: scale(1.2); cursor: grabbing; }
.seat.pickable .seat-face { border-color: var(--gold); animation: bob 1.1s ease-in-out infinite; cursor: pointer; }
.seat.picked .seat-face { background: var(--gold); color: #241a06; }

.seat-tag { position: absolute; top: -6px; right: -4px; font-size: 12px; }
.seat-name { font-size: 11px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seat-badge {
    position: absolute; top: -8px; left: 50%; transform: translateX(-50%) scale(0);
    background: #2a2338; border-radius: 9px; padding: 1px 6px;
    font-size: 10px; font-weight: 800; white-space: nowrap; z-index: 2;
    transition: transform .18s cubic-bezier(.3, 1.6, .5, 1);
}
.seat-badge.on { transform: translateX(-50%) scale(1); }
.seat-badge.tone-you { background: var(--gold); color: #241a06; }
.seat-badge.tone-warn { background: var(--warm); color: #2a1a00; }
.seat-badge.tone-good { background: var(--good); color: #04200f; }
.seat-badge.tone-bad { background: var(--hot); color: #2a0409; }

@keyframes bob { 50% { transform: scale(1.08); } }

/* ---- 연출 ----
   소리가 없는 게임이라, 누가 무엇을 했는지가 눈에 보여야 옆에서 보는
   사람도 같이 놉니다. 원을 가로지르는 선(지목·사격), 튀어나와 흔들리는
   이모지(당근·손들기), 자리가 부풀었다 돌아오기(두드림). */

/* 화살표는 맨 아래 깔립니다.
   원을 가로지르는 선이 가운데 숫자판을 뚫고 지나가던 것을 여기서 막습니다.
   완전히 피해 그리려면 원 밖으로 나가야 해서, 피하는 대신 층을 나눴습니다.
   자리(.seat)가 맨 위, 가운데 판이 그 아래, 화살표가 맨 아래. */
.ring-fx {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 0;
}
.ring-center { z-index: 1; }
.seat { z-index: 2; }
.fx-line {
    fill: none;
    stroke: var(--gold);
    stroke-width: 3px;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 3px rgba(255, 209, 102, .75));
    animation: fxDraw .24s cubic-bezier(.3, .9, .4, 1) forwards, fxFade .4s ease-in .28s forwards;
}
.fx-line-head {
    fill: var(--gold);
    animation: fxHeadIn .1s ease-out .2s backwards, fxFade .4s ease-in .28s forwards;
}
.fx-line.bad { stroke: var(--hot); filter: drop-shadow(0 0 3px rgba(255, 93, 115, .75)); }
.fx-line-head.bad { fill: var(--hot); }
@keyframes fxHeadIn { from { opacity: 0; } }
@keyframes fxDraw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes fxFade { to { opacity: 0; } }

/* 누른 사람의 얼굴 자리에 그 행동이 크게 떴다 돌아옵니다. 글자가 커지는
   것과 자리가 부푸는 것을 같이 씁니다 — 멀리서도 "쟤가 눌렀다" 가 보이게. */
.seat.pop .seat-face { animation: facePop .72s cubic-bezier(.2, 1.4, .4, 1); }
.seat.pop .seat-avatar { animation: faceGlyph .72s ease-out; }
@keyframes facePop {
    0% { transform: scale(1); }
    22% { transform: scale(1.42); box-shadow: 0 0 26px var(--seat-color, #fff); }
    70% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
@keyframes faceGlyph {
    0% { opacity: 0; transform: scale(.5); }
    22% { opacity: 1; transform: scale(1.15); }
    85% { opacity: 1; }
    100% { opacity: 1; transform: scale(1); }
}

/* 아직 할 일이 남은 자리는 배지가 들썩입니다 — 누가 남았는지가 원만 봐도
   보이게. 다 하고 나면 멈춥니다. */
.seat-badge.beat { animation: badgeBeat .62s ease-in-out infinite; }
@keyframes badgeBeat {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.22) rotate(-8deg); }
}

/* 두드린 사람 자리가 한 번 부풀었다 돌아옵니다. 자막이 튀는 것과 같은 결. */
.seat-face.thump { animation: thump .34s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes thump {
    0% { transform: scale(1); }
    35% { transform: scale(1.4); box-shadow: 0 0 26px var(--seat-color, #fff); }
    100% { transform: scale(1); }
}

.ring-center {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 54%; height: 54%;
    display: grid; place-items: center;
    text-align: center;
}

/* ---- 박자 ---- */

.beat { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.beat-main { font-size: clamp(26px, 11vw, 46px); font-weight: 900; letter-spacing: -.03em; line-height: 1.05; }
.beat-sub { font-size: 12px; font-weight: 800; color: var(--gold); min-height: 16px; }
.beat.tone-intro .beat-main { font-size: clamp(15px, 5vw, 22px); color: var(--dim); }
.beat.tone-count .beat-main { color: var(--ink); }
.beat.tone-hit .beat-main { color: var(--gold); }
.beat.pulse { animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(1.28); } to { transform: scale(1); } }

.beat-dots { display: flex; gap: 5px; margin-top: 4px; }
.beat-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background .1s; }
.beat-dots i.on { background: var(--gold); }

/* ---- 가운데 판들 ---- */

.center-quiet.emoji { font-size: clamp(34px, 14vw, 60px); opacity: .5; }
.center-quiet { color: var(--faint); font-size: 13px; }

/* 짧은 말만 옵니다(숫자, "3모"). 그래도 길어지면 원 밖으로 넘치지 않게
   가운데 상자 안에서 접히게 둡니다. */
.board-big {
    font-weight: 900; letter-spacing: -.03em;
    max-width: 100%;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    line-height: 1.05;
}
/* 가운데 큰 글씨의 세 등급. 글자 수에 따라 stage.js 가 고릅니다. */
.fit-l { font-size: clamp(34px, 15vw, 60px); }
.fit-m { font-size: clamp(22px, 9vw, 38px); }
.fit-s { font-size: clamp(15px, 6vw, 24px); }

.board-light {
    width: 86%; aspect-ratio: 1; border-radius: 50%;
    display: grid; place-items: center;
    background: #3a1220; color: transparent;
    font-weight: 900; font-size: 20px;
    transition: background .1s;
}
.board-light.green { background: var(--good); color: #04200f; box-shadow: 0 0 40px rgba(87, 224, 138, .6); }

.board-counter { display: flex; flex-direction: column; align-items: center; }
.counter-value {
    font-weight: 900; line-height: 1.1;
    max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.counter-goal { font-size: 12px; color: var(--faint); }
.counter-note { font-size: 11px; color: var(--dim); margin-top: 4px; }

.board-range { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.range-nums { font-size: clamp(18px, 7vw, 28px); font-weight: 900; }
.range-track { position: relative; height: 8px; background: #241d33; border-radius: 5px; overflow: hidden; }
.range-fill { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, var(--warm), var(--hot)); }

/* 아파트. 층을 다 늘어놓으면 열 몇 줄이 원 안에 뭉칩니다. 창 하나만 내고
   슬롯머신처럼 굴려서, 지금 세는 층이 늘 가운데에 오게 합니다. */
.board-floors { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.floor-window {
    position: relative;
    width: 100%;
    height: clamp(58px, 22vw, 84px);
    overflow: hidden;
    border-radius: 10px;
    background: #1b1626;
    box-shadow: inset 0 9px 12px -8px #0d0a15, inset 0 -9px 12px -8px #0d0a15;
}
.floor-window::after {
    /* 가운데 한 줄만 밝게. 어디를 읽어야 하는지 손가락으로 짚어 줍니다. */
    content: '';
    position: absolute; left: 0; right: 0; top: 50%;
    height: 22px; margin-top: -11px;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    pointer-events: none;
}
.floor-list {
    position: absolute; left: 0; right: 0; top: 50%;
    display: flex; flex-direction: column-reverse;
    transition: transform .28s cubic-bezier(.3, 0, .2, 1);
}
.floor {
    height: 22px;
    display: flex; gap: 6px; justify-content: center; align-items: center;
    font-size: 11px; white-space: nowrap;
}
.floor b { color: var(--faint); font-size: 9px; font-weight: 700; }
.floor-face { font-size: 14px; line-height: 1; }
.floor-name { max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.floor.hit { color: var(--hot); font-weight: 900; }
.floor.hit b { color: var(--hot); }

.board-words { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.word-now { font-weight: 900; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.board-tally { width: 100%; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.tally-row { display: grid; grid-template-columns: auto 1fr auto; gap: 5px; align-items: center; font-size: 10px; }
.tally-name { font-weight: 700; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally-bar { height: 7px; background: #241d33; border-radius: 4px; overflow: hidden; }
.tally-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--warm), var(--hot)); transition: width .4s; }
.tally-n { font-weight: 900; }
.tally-from { grid-column: 1 / -1; font-size: 8px; color: var(--faint); text-align: left; }

/* 손병호. 가운데에는 내 손만 크게 놓습니다. 여섯 줄을 원 안에 욱여넣으면
   이름은 잘리고 점만 뭉쳐 보입니다 — 실제로 그랬습니다. */
.board-hand { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hand-dots { display: flex; gap: 7px; }
.hand-dots i {
    width: clamp(14px, 5vw, 22px);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: transparent;
    transition: background .25s, border-color .25s;
}
.hand-dots i.on { background: var(--gold); border-color: var(--gold); }
.hand-left { font-size: 12px; color: var(--dim); }

.board-versus { display: flex; align-items: center; gap: 6px; width: 100%; justify-content: center; }
.vs-side { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.vs-role { font-size: 9px; color: var(--faint); }
.vs-show { font-size: clamp(16px, 6vw, 26px); font-weight: 900; min-height: 30px; }
.vs-name { font-size: 10px; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs { font-size: 10px; font-weight: 900; color: var(--faint); }

/* 침묵의 공공칠빵. 네모 하나가 천천히 그려지는 것이 인트로 전부입니다.
   구호를 띄우면 세는 재미가 사라집니다. */
.board-silent { width: 88%; aspect-ratio: 1; display: grid; place-items: center; }
.board-silent svg { width: 100%; height: 100%; overflow: visible; }
/* 위 가운데에서 두 갈래로 갈라져 양옆을 타고 내려와 아래에서 만납니다.
   pathLength=100 을 적어 두어서 모서리 곡선 길이를 재지 않아도 됩니다. */
.silent-half {
    fill: none;
    stroke: #d9d3ea;
    /* 굵기는 그림 좌표(0~100)로 적습니다. non-scaling-stroke 를 쓰면 굵기는
       화면 픽셀로 고정되는데, 그때 대시 길이도 같이 화면 픽셀이 됩니다 —
       그래서 그림 좌표로 잰 --len 과 어긋나 네모가 절반쯤에서 끊겼습니다.
       원인을 두 번이나 다른 데서 찾았던 자리입니다. */
    stroke-width: 2.2;
    stroke-linecap: round;
    /* --len 은 stage.js 가 그림 좌표로 잰 길이를 넣어 줍니다. */
    stroke-dasharray: var(--len, 132);
    stroke-dashoffset: var(--len, 132);
    animation: drawSquare 2.6s cubic-bezier(.45, 0, .55, 1) forwards;
}
/* 판이 시작되면 네모는 배경으로 물러납니다. */
.board-silent.quiet .silent-half { animation: none; stroke-dashoffset: 0; opacity: .18; }
@keyframes drawSquare {
    from { stroke-dashoffset: var(--len, 132); }
    to { stroke-dashoffset: 0; }
}

/* 소주 뚜껑. 병이 기우뚱하고 뚜껑이 따여 가운데로 내려앉습니다.
   딴 사람 화면에만 안쪽 숫자가 있습니다. */
.board-cap { position: relative; width: 100%; height: 100%; }
.cap-bottle {
    position: absolute; left: 50%; bottom: 0;
    width: 20%; height: 62%;
    fill: #2f7d4f;
    opacity: .5;
    transform-origin: 50% 100%;
    animation: bottleTip 3s ease-out forwards;
}
@keyframes bottleTip {
    0%, 6% { transform: translateX(-50%) rotate(0); }
    14% { transform: translateX(-50%) rotate(-10deg); }
    34%, 100% { transform: translateX(-50%) rotate(0); }
}
.cap-coin {
    position: absolute; left: 50%; top: 48%;
    width: 46%; aspect-ratio: 1;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: clamp(20px, 8vw, 34px); font-weight: 900; color: #1d2230;
    animation: capPop 3s cubic-bezier(.2, .7, .3, 1) forwards;
}
.cap-coin.outside {
    background: radial-gradient(circle at 42% 34%, #7fd6a1, #2f7d4f 62%, #1d5836);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .14), 0 6px 18px rgba(0, 0, 0, .45);
}
.cap-coin.inside {
    background: radial-gradient(circle at 40% 34%, #ffffff, #cfd6e4 68%, #9aa4b8);
    box-shadow: inset 0 0 0 3px #8f9bb3, 0 6px 18px rgba(0, 0, 0, .45);
}
.cap-coin::after {
    content: '';
    position: absolute; inset: 7%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, .18);
}
.cap-coin.inside::after { border-color: rgba(0, 0, 0, .12); }
.cap-coin.hidden { color: rgba(29, 34, 48, .3); }
@keyframes capPop {
    0% { transform: translate(-50%, -50%) translateY(30%) scale(.16) rotate(0); opacity: 0; }
    10% { opacity: 1; }
    46% { transform: translate(-50%, -50%) translateY(-46%) scale(.62) rotate(250deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) translateY(0) scale(1) rotate(360deg); opacity: 1; }
}

/* 데스 게임의 두 자리 수. 빈 칸이 먼저 보이고 누르는 대로 채워집니다. */
.board-digits { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.digit-slots { display: flex; gap: 8px; }
.digit-slot {
    min-width: 40px; padding: 2px 8px;
    border-radius: 10px;
    background: #241d33;
    font-size: clamp(24px, 10vw, 42px); font-weight: 900; line-height: 1.15;
}
.digit-slot.empty { color: var(--faint); font-size: 14px; display: grid; place-items: center; }
.digit-left { font-size: clamp(20px, 8vw, 34px); font-weight: 900; color: var(--hot); }
/* 아파트에서는 층 목록과 같이 놓이므로 자리만 알아볼 만큼 작게. */
.digit-slots.mini { gap: 5px; }
.digit-slots.mini .digit-slot { min-width: 24px; padding: 0 6px; font-size: clamp(16px, 6vw, 24px); }
.digit-slots.mini .digit-slot.empty { font-size: 10px; }

/* 만두게임. 편 손과 오므린 손을 한 줄에 늘어놓습니다. 노래가 끝나기 전에는
   누가 냈는지만 보이고, 무엇을 냈는지는 다 같이 펼 때 보입니다. */
.board-mandu { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mandu-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.mandu-hand {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    min-width: 34px; padding: 3px 4px;
    border-radius: 8px; background: #201a2e;
}
.mandu-hand .mh-sign { font-size: clamp(15px, 6vw, 22px); line-height: 1; }
.mandu-hand .mh-name { font-size: 8px; color: var(--faint); max-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mandu-hand.open { background: #33261a; }
.mandu-hand.wait .mh-sign { opacity: .35; }
.mandu-total { font-size: clamp(22px, 9vw, 36px); font-weight: 900; }
.mandu-total.hit { color: var(--gold); }
.mandu-total.miss { color: var(--hot); }


/* 계속 떠 있는 화살표. 지목이 곧 지도인 게임에서 씁니다.

   굵기를 뷰박스 단위로 주면 화면이 클수록 굵어집니다. non-scaling-stroke 는
   굵기만 화면 픽셀로 재게 해서, 폰이든 태블릿이든 같은 두께로 보입니다. */
.arrow {
    fill: none;
    stroke: var(--cool);
    stroke-width: 2.8px;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    opacity: .8;
    filter: drop-shadow(0 0 2px rgba(97, 208, 255, .5));
    transition: opacity .2s, stroke .2s;
}
.arrow-head {
    fill: var(--cool);
    opacity: .8;
    transition: opacity .2s, fill .2s;
}
/* 다 쓴 손. 지워 버리면 누가 누구를 가리켰는지 안 보이니 흐리게만 둡니다. */
.arrow.dim, .arrow-head.dim { opacity: .18; filter: none; }
.arrow.live {
    stroke: var(--hot);
    stroke-width: 4.5px;
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(255, 93, 115, .9));
}
.arrow-head.live { fill: var(--hot); opacity: 1; }


/* ---- 남은 시간 ---- */

.timebar { height: 5px; border-radius: 3px; background: #241d33; overflow: hidden; position: relative; }
.timebar::after {
    content: ''; position: absolute; inset: 0;
    transform-origin: left; transform: scaleX(var(--p, 0));
    background: linear-gradient(90deg, var(--good), var(--warm));
}
.timebar.urgent::after { background: var(--hot); }

/* ---- 조작판 ---- */

.panel { display: flex; flex-direction: column; gap: 8px; }

.pick-hint { text-align: center; font-size: 13px; font-weight: 700; color: var(--gold); }

.keypad-label { font-size: 12px; color: var(--dim); text-align: center; }
.keypad-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; }
.keypad.wide .keypad-grid { grid-template-columns: 1fr; }
.keypad:not(.wide) .keypad-grid { grid-template-columns: repeat(5, 1fr); max-height: 168px; overflow-y: auto; }

.key {
    background: #241c34; border: 1px solid var(--line); color: var(--ink);
    border-radius: 12px; padding: 14px 8px; font: inherit; font-weight: 800;
    cursor: pointer; transition: transform .07s;
}
.key:active { transform: scale(.94); }
.key.on { background: var(--gold); color: #241a06; border-color: transparent; }
.key.go { flex: 0 0 auto; padding: 13px 16px; }
.key:disabled { opacity: .3; }

.text-row { display: flex; flex-direction: column; gap: 6px; }
.text-line { display: flex; gap: 6px; }
.text-field {
    flex: 1; background: #0a0810; border: 1px solid var(--line); border-radius: 12px;
    color: var(--ink); font: inherit; font-weight: 700; padding: 13px 14px;
}
.text-field:focus { outline: none; border-color: var(--gold); }

.actions { display: flex; gap: 8px; }
.act {
    flex: 1; border-radius: 16px; border: 1px solid var(--line);
    background: #221a30; color: var(--ink); font: inherit; cursor: pointer;
    padding: 16px 10px; transition: transform .06s, filter .12s;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.act.big { padding: 22px 10px; }
.act:active { transform: scale(.96); }
.act-label { font-size: 20px; font-weight: 900; letter-spacing: -.02em; }
.act-sub { font-size: 11px; color: var(--faint); }
.act.primary { background: linear-gradient(135deg, #ff5d73, #ff8f5d); border-color: transparent; color: #1a0f14; }
.act.primary .act-sub { color: rgba(26, 15, 20, .65); }
.act.danger { background: #3a1220; border-color: #5a1c30; color: var(--hot); }
.act.ghost { opacity: .5; }
.act:disabled { opacity: .3; }

/* ---- 대기실 / 선택 / 준비 / 결과 ---- */

.below { display: flex; flex-direction: column; gap: 10px; }


.lobby-center { display: flex; flex-direction: column; align-items: center; }
.lobby-code { font-size: clamp(24px, 10vw, 40px); font-weight: 900; letter-spacing: .12em; color: var(--gold); }
.lobby-count { font-size: 12px; color: var(--faint); }

.select-center { display: flex; flex-direction: column; align-items: center; }
.select-avatar { font-size: 40px; animation: bob 1.6s ease-in-out infinite; }
.select-name { font-size: 13px; font-weight: 700; color: var(--dim); }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.game-card {
    position: relative;
    background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 8px 10px; color: inherit; font: inherit; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transition: transform .08s, border-color .15s;
}
.game-card:active { transform: scale(.96); }
.game-card:not(:disabled):hover { border-color: var(--gold); }
.game-card.off, .game-card:disabled { opacity: .4; }
.game-emoji { font-size: 26px; }
.game-name { font-size: 13px; font-weight: 800; }
.game-tag { font-size: 10px; color: var(--faint); line-height: 1.3; }
.game-info {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #2a2338; border: 0; color: var(--dim);
    font-size: 11px; font-weight: 800; cursor: pointer;
}

.ready-center { display: flex; flex-direction: column; align-items: center; }
.ready-emoji { font-size: 44px; }
.ready-count { font-size: clamp(30px, 12vw, 52px); font-weight: 900; color: var(--gold); animation: pop .3s ease-out; }
.rule-quick { margin: 0; padding-left: 20px; }
.rule-quick li { color: var(--dim); font-size: 13px; }

.result-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.result-glass { font-size: 52px; animation: shake .6s ease-in-out; }
.result-faces { display: flex; gap: 4px; font-size: 22px; }
@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-14deg); }
    75% { transform: rotate(14deg); }
}

.score-strip { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.score-chip {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
    padding: 4px 10px 4px 6px; font-size: 11px;
}
.score-chip.me { border-color: var(--gold); }
.score-chip.off { opacity: .4; }
.score-chip .rank { color: var(--faint); font-weight: 800; }
.score-chip .who { font-weight: 700; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-chip .num { color: var(--dim); }

.feed { display: flex; flex-direction: column; gap: 2px; }
.feed-line { font-size: 11px; color: var(--faint); text-align: center; }

/* ---- 알림 / 시트 ---- */

/* 화면 전체 알림. 게임 이름과 손병호 조건. 누르는 것을 막지 않습니다 —
   손병호는 이 글자가 떠 있는 동안에도 접기를 눌러야 하니까요. */
.splash {
    position: fixed; inset: 0; z-index: 70;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    padding: 28px;
    text-align: center;
    background: rgba(8, 6, 14, .84);
    backdrop-filter: blur(3px);
    pointer-events: none;
    animation: splashIn .2s cubic-bezier(.2, 1.5, .4, 1), splashOut .55s ease-in var(--hold, 1.05s) forwards;
}
.splash-emoji { font-size: clamp(48px, 18vw, 90px); line-height: 1; }
.splash-text {
    font-weight: 900;
    max-width: 92vw;
    letter-spacing: -.03em;
    line-height: 1.15;
    color: var(--gold);
    text-shadow: 0 6px 30px rgba(255, 209, 102, .3);
}
.splash-text.fit-l { font-size: clamp(30px, 11vw, 56px); }
.splash-text.fit-m { font-size: clamp(24px, 8vw, 42px); }
.splash-text.fit-s { font-size: clamp(18px, 5.6vw, 30px); line-height: 1.3; }
.splash-sub { font-size: 15px; color: var(--dim); }
/* 진 사람. 이유보다 먼저 눈에 들어와야 합니다 — 남들이 보는 것은 결국
   "누가 마시나" 입니다. */
.splash-who {
    font-size: clamp(24px, 9vw, 44px);
    font-weight: 900;
    letter-spacing: -.02em;
    color: var(--hot);
    text-shadow: 0 6px 30px rgba(255, 93, 115, .35);
    max-width: 92vw;
}
@keyframes splashIn { from { opacity: 0; transform: scale(1.14); } }
@keyframes splashOut { to { opacity: 0; transform: scale(.94); } }

/* 잠깐 멈춤. 화면을 덮지 않습니다 — 멈추는 이유의 절반이 "자리 좀 바꾸자"
   인데, 덮어 버리면 정작 자리를 끌 수가 없습니다. */
.paused-mark { font-size: clamp(40px, 16vw, 72px); line-height: 1; color: var(--gold); }
.paused-tools { display: flex; flex-direction: column; gap: 8px; }

.toast {
    position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: #2a2338; border: 1px solid var(--line); border-radius: 999px;
    padding: 10px 18px; font-size: 14px; font-weight: 600;
    z-index: 60; max-width: 90vw; text-align: center;
    animation: rise .2s ease-out;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.modal {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(6, 4, 12, .7);
    backdrop-filter: blur(6px);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
    position: relative;
    width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
    background: var(--bg2); border: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
    animation: sheetUp .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } }
.sheet-close {
    position: absolute; top: 12px; right: 12px;
    width: 30px; height: 30px; border-radius: 50%;
    background: #2a2338; border: 0; color: var(--dim); font-size: 14px; cursor: pointer;
}
.sheet-body { display: flex; flex-direction: column; gap: 12px; }

.set-block { display: flex; flex-direction: column; gap: 6px; }
.set-label { font-size: 13px; font-weight: 700; color: var(--dim); }
.radios { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 6px; }
.radio {
    background: #1a1526; border: 1px solid var(--line); border-radius: 12px;
    padding: 9px 8px; color: var(--dim); font: inherit; cursor: pointer;
    display: flex; flex-direction: column; gap: 1px;
}
.radio b { font-size: 13px; }
.radio span { font-size: 10px; color: var(--faint); }
.radio.on { background: var(--gold); border-color: transparent; color: #241a06; }
.radio.on span { color: rgba(36, 26, 6, .65); }

/* 다른 설정 때문에 지금은 아무 뜻도 없는 항목. 숨기지 않고 흐리게만
   둡니다 — 숨기면 "그 설정 어디 갔지" 가 됩니다. */
.set-block.dead { opacity: .32; }
.set-block.dead .radio { pointer-events: none; }
.set-block.dead .dead-why { display: block; }
.dead-why { display: none; font-size: 11px; color: var(--warm); text-align: center; }

.toggle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 5px; }
.toggle {
    display: flex; align-items: center; gap: 5px;
    background: #1a1526; border: 1px solid var(--line); border-radius: 10px;
    padding: 8px 7px; color: var(--faint); font: inherit; cursor: pointer;
    text-align: left;
}
.toggle b { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle.on { background: #2a2338; color: var(--ink); border-color: var(--good); }

.profile-now { font-size: 54px; text-align: center; line-height: 1.1; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.avatar {
    aspect-ratio: 1;
    background: #1a1526; border: 2px solid var(--line); border-radius: 14px;
    font-size: 26px; line-height: 1; cursor: pointer;
    display: grid; place-items: center;
    transition: transform .07s, border-color .15s;
}
.avatar:active { transform: scale(.92); }
.avatar.on { border-color: var(--gold); background: #2a2338; }
.avatar.used { opacity: .22; cursor: not-allowed; }

.install-steps { margin: 0; padding-left: 20px; }
.install-steps li { color: var(--dim); font-size: 14px; margin: 6px 0; }

.people { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; align-items: center; gap: 8px; }
.person .face { font-size: 22px; }
.person .who { flex: 1; font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tagline { font-size: 10px; color: var(--faint); font-weight: 600; }

.rule-group { display: flex; flex-direction: column; gap: 10px; }
.rule-kind { font-size: 12px; font-weight: 800; color: var(--gold); letter-spacing: .06em; margin-top: 4px; }
.rule-item { background: #1a1526; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.rule-head { display: flex; align-items: center; gap: 7px; }
.rule-emoji { font-size: 19px; }
.rule-people { margin-left: auto; font-size: 10px; color: var(--faint); }
.rule-tag { font-size: 12px; color: var(--dim); margin: 2px 0 0; }

@media (min-width: 620px) {
    .modal { align-items: center; }
    .sheet { border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
