/* ───────────────────────── 아홉 깃발 · 냥냥 낙서장 테마 ───────────────────────── */
:root {
  --paper: #fbf1df;
  --paper-2: #fffaf1;
  --paper-3: #f3e4c9;
  --ink: #3d2e28;
  --ink-soft: rgb(61 46 40 / 55%);
  --muted: #8b7768;
  --me: #ff922b;
  --me-soft: #ffe8cc;
  --opp: #748ffc;
  --opp-soft: #dbe4ff;
  --pink: #ff8fab;
  --mint: #63e6be;
  --mint-soft: #c3fae8;
  --yellow: #ffd43b;
  --wobble: 18px 14px 20px 12px / 14px 20px 12px 18px;
  --wobble-2: 12px 20px 14px 18px / 18px 12px 20px 14px;
  --top-h: 58px;
  --bar-h: 72px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --line-y: 50vh;
  --line-h: 80px;
  --field-top: 20vh;
  --field-bottom: 80vh;
  --font: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background-color: var(--paper);
  /* 모눈 점 + 여기저기 낙서한 발바닥 */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><g fill='%233d2e28' fill-opacity='.06'><g transform='translate(40 50) rotate(-20)'><ellipse cx='0' cy='5' rx='7' ry='6'/><ellipse cx='-8' cy='-4' rx='2.6' ry='3.2'/><ellipse cx='-3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='8' cy='-4' rx='2.6' ry='3.2'/></g><g transform='translate(165 150) rotate(25)'><ellipse cx='0' cy='5' rx='7' ry='6'/><ellipse cx='-8' cy='-4' rx='2.6' ry='3.2'/><ellipse cx='-3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='8' cy='-4' rx='2.6' ry='3.2'/></g></g><path d='M150 40c8-6 18-6 26 0l6-4v10l-6-4c-8 6-18 6-26-2z' fill='none' stroke='%233d2e28' stroke-opacity='.07' stroke-width='2'/></svg>"),
    radial-gradient(circle, rgb(61 46 40 / 9%) 1.2px, transparent 1.4px);
  background-size: 220px 220px, 22px 22px;
}

button { font-family: inherit; font-weight: 400; color: var(--ink); }

/* 아이콘 공통 */
.ic { width: 1.15em; height: 1.15em; display: block; flex: none; }
.ic.inl { display: inline-block; vertical-align: -0.22em; color: var(--me); }
i[data-icon] { display: inline-flex; align-items: center; justify-content: center; font-style: normal; }

/* ───────────── 놀이판 바탕 ───────────── */
#field { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.territory { position: absolute; left: 6px; right: 6px; border-radius: 26px; }
.territory.enemy {
  top: var(--field-top);
  height: calc(var(--line-y) - var(--field-top));
  background: linear-gradient(180deg, rgb(116 143 252 / 4%), rgb(116 143 252 / 16%));
}
.territory.mine {
  top: var(--line-y);
  height: calc(var(--field-bottom) - var(--line-y));
  background: linear-gradient(0deg, rgb(255 146 43 / 4%), rgb(255 146 43 / 15%));
}
.battle-line {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--line-y) - 6px);
  height: 12px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='12'><path d='M2 6c6-4 10 4 16 0' fill='none' stroke='%233d2e28' stroke-opacity='.4' stroke-width='2.5' stroke-linecap='round'/><path d='M32 6c6-4 10 4 16 0' fill='none' stroke='%233d2e28' stroke-opacity='.4' stroke-width='2.5' stroke-linecap='round'/></svg>") repeat-x center / 60px 12px;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ───────────── 판 위 글자표 ───────────── */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.board-label { position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: none; }
.board-label.badge {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 50% 46% 52% 48%;
  background: var(--paper-2);
  border: 2.2px solid var(--ink);
  font-size: 13px;
  box-shadow: 1.5px 2px 0 var(--ink);
}
.board-label.badge.tactics { background: #e5dbff; }
.board-label.badge.troop { background: #ffe8cc; }
.board-label.badge.empty { opacity: 0.5; }
.board-label.ghost { color: var(--ink-soft); }
.board-label.ghost .ic { width: 24px; height: 24px; }

.board-label.form {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px 6px 9px 5px;
  background: var(--paper-2);
  border: 1.8px solid var(--ink);
  box-shadow: 1.5px 1.5px 0 var(--ink);
}
.board-label.form.r5 { background: #ffec99; }
.board-label.form.r4 { background: #d0ebff; }
.board-label.form.r3 { background: #ffd8a8; }
.board-label.form.r2 { background: #d3f9d8; }
.board-label.form.r1, .board-label.form.r0 { background: var(--paper-2); color: var(--muted); }

.board-label.chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px 4px 7px;
  min-width: 46px;
  min-height: 32px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  font-size: 14px;
  background: var(--yellow);
  box-shadow: 2px 3px 0 var(--ink);
  animation: chipBounce 0.9s ease-in-out infinite;
  cursor: pointer;
}
.board-label.chip .ic { width: 15px; height: 15px; }
@keyframes chipBounce { 50% { background: #ffe066; box-shadow: 2px 5px 0 var(--ink); } }

.board-label.env {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  min-height: 21px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  background: var(--mint-soft);
  box-shadow: 1.5px 2px 0 var(--ink);
  cursor: pointer;
}
.board-label.env .ic { width: 13px; height: 13px; }
.board-label.env.target { animation: envPulse 0.9s ease-in-out infinite; }
@keyframes envPulse { 50% { background: var(--mint); } }

.sort-btn {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 6;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50% 46% 52% 48%;
  border: 2.5px solid var(--ink);
  background: var(--paper-2);
  font-size: 18px;
  box-shadow: 2px 3px 0 var(--ink);
}

/* ───────────── 위쪽: 두 고양이 부대 ───────────── */
#topBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: calc(var(--top-h) + var(--safe-t));
  padding: calc(7px + var(--safe-t)) 8px 7px;
  display: flex;
  gap: 6px;
  align-items: stretch;
  background: var(--paper);
  border-bottom: 2.5px solid var(--ink);
}
.seat-chip {
  flex: 1 1 0;
  min-width: 0;
  max-width: 300px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px 3px 4px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.15s;
}
.seat-chip.enemy { border-radius: var(--wobble-2); }
.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50% 46% 52% 48%;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.seat-chip.me .avatar { background: var(--me); }
.seat-chip.enemy .avatar { background: var(--opp); }
.chip-body { min-width: 0; flex: 1; }
.seat-chip .name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.stats { display: flex; gap: 7px; }
.st { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.st .ic { width: 13px; height: 13px; }
.st b { font-weight: 400; color: var(--ink); }
.seat-chip.me .st-flag { color: var(--me); }
.seat-chip.enemy .st-flag { color: var(--opp); }
.seat-chip.me.active { background: var(--me-soft); transform: rotate(-1.2deg); }
.seat-chip.enemy.active { background: var(--opp-soft); transform: rotate(1.2deg); }
.seat-chip.active .avatar { animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

.icon-btn {
  flex: none;
  width: 42px;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble-2);
  background: var(--paper-2);
  font-size: 20px;
  box-shadow: 2px 2px 0 var(--ink);
}
#rulesBtn { margin-left: auto; }

/* ───────────── 아래쪽: 차례 + 안내 + 버튼 ───────────── */
#actionBar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: calc(var(--bar-h) + var(--safe-b));
  padding: 8px 10px calc(8px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border-top: 2.5px solid var(--ink);
}
#turnBadge {
  flex: none;
  width: 54px;
  height: 54px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-size: 22px;
  background: var(--paper-2);
  color: var(--muted);
  box-shadow: 2px 2px 0 var(--ink);
}
#turnBadge span { font-size: 11px; }
#turnBadge.me { background: var(--me); color: var(--ink); }
#turnBadge.enemy { background: var(--opp); color: var(--ink); }
.prompt { flex: 1; min-width: 0; }
.prompt-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#promptTitle { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#promptSub {
  margin-top: 1px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#promptSub:empty { display: none; }
#promptSub.warn { color: #e03131; }
#steps { display: flex; align-items: center; gap: 2px; flex: none; }
.step {
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  border-radius: 9px 7px 10px 6px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--muted);
  background: var(--paper-2);
}
.step.on { background: var(--yellow); color: var(--ink); box-shadow: 1.5px 2px 0 var(--ink); }
.step.done { background: var(--paper-3); color: var(--ink-soft); }
.step-sep { width: 7px; height: 2.5px; background: var(--ink); border-radius: 2px; }
#actions { display: flex; gap: 6px; flex: none; }
#actions .btn { width: auto; margin: 0; padding: 0 14px; min-height: 46px; font-size: 16px; }

.thinking::after { content: ''; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* 카드 설명 */
#infoBubble {
  position: fixed;
  left: 12px;
  right: 12px;
  z-index: 9;
  padding: 10px 13px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  pointer-events: none;
  max-width: 520px;
  margin: 0 auto;
}
.info-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; font-size: 18px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  padding: 1px 8px 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
}
.tag .ic { width: 14px; height: 14px; }
.tag.k-environment { background: var(--mint-soft); }
.tag.k-guile { background: #e5dbff; }
#infoText { color: var(--ink); }

/* 알림 (말풍선) */
#toasts {
  position: fixed;
  top: calc(var(--top-h) + var(--safe-t) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 10px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  font-size: 15px;
  box-shadow: 2px 3px 0 var(--ink);
  animation: pop 0.25s cubic-bezier(.3,1.6,.6,1);
}
.toast .ic { width: 17px; height: 17px; }
.toast.gold { background: var(--me-soft); }
.toast.gold .ic { color: var(--me); }
.toast.enemy { background: var(--opp-soft); }
.toast.enemy .ic { color: #4c6ef5; }
.toast.warn { background: #ffe3e3; }
@keyframes pop { from { opacity: 0; transform: scale(0.7); } }

/* 내 차례 말풍선 */
#turnBanner {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--line-y);
  z-index: 8;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.tb-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 26px;
  font-size: 30px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: 4px 5px 0 var(--ink);
  animation: bannerPop 1s cubic-bezier(.3,1.6,.6,1) forwards;
}
.tb-inner .ic { width: 30px; height: 30px; color: var(--ink); }
@keyframes bannerPop {
  0% { opacity: 0; transform: scale(0.4) rotate(-8deg); }
  25% { opacity: 1; transform: scale(1) rotate(-3deg); }
  75% { opacity: 1; transform: scale(1) rotate(-3deg); }
  100% { opacity: 0; transform: scale(0.9) rotate(-3deg); }
}

/* ───────────── 겹쳐 뜨는 창 ───────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgb(61 46 40 / 38%);
}
.overlay.solid {
  background-color: var(--paper);
  background-image: inherit;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><g fill='%233d2e28' fill-opacity='.06'><g transform='translate(40 50) rotate(-20)'><ellipse cx='0' cy='5' rx='7' ry='6'/><ellipse cx='-8' cy='-4' rx='2.6' ry='3.2'/><ellipse cx='-3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='8' cy='-4' rx='2.6' ry='3.2'/></g><g transform='translate(165 150) rotate(25)'><ellipse cx='0' cy='5' rx='7' ry='6'/><ellipse cx='-8' cy='-4' rx='2.6' ry='3.2'/><ellipse cx='-3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='3' cy='-9' rx='2.6' ry='3.2'/><ellipse cx='8' cy='-4' rx='2.6' ry='3.2'/></g></g></svg>"),
    radial-gradient(circle, rgb(61 46 40 / 9%) 1.2px, transparent 1.4px);
  background-size: 220px 220px, 22px 22px;
}
.panel {
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 24px 20px 20px;
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  box-shadow: 5px 6px 0 var(--ink);
  line-height: 1.55;
}
.panel h2 { margin: 0 0 10px; font-size: 26px; font-weight: 400; }
.title-ic { display: flex; align-items: center; gap: 8px; }
.title-ic i { color: var(--me); font-size: 24px; }
.muted { color: var(--muted); font-size: 15px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  font-size: 18px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:nth-of-type(even) { border-radius: var(--wobble-2); }
.btn i { font-size: 21px; }
.btn.primary { background: var(--me); }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn small { opacity: 0.75; font-size: 13px; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* 시작 화면 */
.menu-panel { text-align: center; padding-top: 14px; }
.mascot { width: 150px; height: 115px; display: block; margin: 0 auto -4px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-2deg); } }
.menu-panel h1 {
  margin: 0;
  font-size: 44px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--me-soft);
}
.logo-sub {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 12px;
  font-size: 15px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  transform: rotate(-2deg);
}
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.tile { flex-direction: column; gap: 2px; min-height: 70px; font-size: 16px; }
.btn.tile i { font-size: 24px; color: var(--me); }
.menu-foot { display: flex; gap: 10px; }
.menu-foot .btn { min-height: 44px; font-size: 16px; }
.field-label { margin: 14px 0 6px; font-size: 14px; color: var(--muted); text-align: left; }
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble-2);
  background: var(--paper-3);
}
.segmented button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 17px;
  color: var(--muted);
}
.segmented button.on { background: var(--paper-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--wobble-2);
  text-align: left;
  font-size: 16px;
}
.toggle input { width: 22px; height: 22px; accent-color: var(--me); }
.toggle small { display: block; color: var(--muted); font-size: 13px; }

/* 규칙 */
.rules-panel { max-width: 560px; }
.rules-panel h3 { margin: 18px 0 6px; font-size: 19px; font-weight: 400; display: flex; align-items: center; gap: 6px; }
.rules-panel h3 .ic { color: var(--me); }
.rules-panel ul { margin: 0; padding-left: 18px; font-size: 15px; }
.rules-panel li { margin: 4px 0; }
.rules-panel b { color: #e8590c; font-weight: 400; }
.form-chart { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 6px; }

/* 기록 */
.log-list { margin: 0; padding: 0; list-style: none; font-size: 15px; }
.log-list li { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--opp); }
.log-list li.me { border-left-color: var(--me); }
.log-list li.turn { margin: 12px 0 2px; padding: 0; border: 0; font-size: 13px; color: var(--muted); }
.log-list:empty::after { content: '아직 기록이 없어요'; color: var(--muted); }

/* 결과 */
.result-panel { text-align: center; }
.result-emblem { width: 80px; height: 80px; margin: 0 auto 2px; color: var(--me); animation: bob 1.6s ease-in-out infinite; }
.result-emblem .ic { width: 100%; height: 100%; }
.result-panel.lose .result-emblem { color: var(--opp); }
.result-panel h2 { font-size: 38px; margin-bottom: 8px; }
.flag-strip { display: flex; justify-content: center; gap: 4px; margin: 4px 0 8px; }
.fs-flag {
  width: 32px;
  height: 40px;
  border: 2px solid var(--ink);
  border-radius: 9px 7px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--paper-2);
  color: var(--muted);
}
.fs-flag small { font-size: 11px; line-height: 1; }
.fs-flag.mine { background: var(--me); color: var(--ink); }
.fs-flag.enemy { background: var(--opp); color: var(--ink); }
.fs-flag.win { transform: translateY(-4px); box-shadow: 2px 3px 0 var(--ink); }

/* 미니 카드 (버림 더미, 규칙 표) */
.mini-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.mini {
  width: 50px;
  height: 70px;
  padding: 3px 5px;
  border: 2.2px solid var(--ink);
  border-radius: 9px 7px 10px 6px;
  font-size: 22px;
  color: #fff;
  text-shadow: -1.5px -1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px 1.5px 0 var(--ink);
  box-shadow: 1.5px 2px 0 var(--ink);
}
.mini.tactic {
  background: var(--paper-2) !important;
  color: var(--ink);
  text-shadow: none;
  font-size: 11.5px;
  line-height: 1.2;
}
.mini-list:empty::after { content: '아직 없어요'; color: var(--muted); font-size: 14px; }

#rotateHint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  place-items: center;
  align-content: center;
  text-align: center;
  background: var(--paper);
  font-size: 17px;
}
#rotateHint div { font-size: 44px; transform: rotate(90deg); }
@media (orientation: landscape) and (max-height: 500px) {
  #rotateHint { display: grid; }
}

/* ───────────── 튜토리얼 ───────────── */
#tutLayer { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
.tut-ring {
  position: absolute;
  border: 3.5px dashed var(--me);
  border-radius: 16px 12px 18px 10px;
  box-shadow: 0 0 0 4px rgb(255 146 43 / 22%);
  animation: ringPulse 0.9s ease-in-out infinite;
}
.tut-ring.round { border-radius: 50%; }
@keyframes ringPulse { 50% { transform: scale(1.06); } }

#coach {
  position: fixed;
  left: 12px;
  right: 12px;
  z-index: 15;
  max-width: 520px;
  margin: 0 auto;
  padding: 11px 14px 12px;
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--paper-2);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 16px;
  line-height: 1.55;
}
#coach.doing { background: #fff9db; }
.coach-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.coach-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 10px 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--me);
  font-size: 14px;
}
.coach-badge .ic { width: 17px; height: 17px; }
#coachProg { flex: 1; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coach-exit {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-2);
  font-size: 15px;
}
#coachText b { color: #e8590c; font-weight: 400; }
.coach-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
#coachDo { margin-right: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 15px; color: #e8590c; }
#coachDo .ic { width: 17px; height: 17px; animation: wiggle 1s ease-in-out infinite; }
#coachNext { width: auto; min-height: 42px; margin: 0; padding: 0 24px; }

.tut-panel { max-width: 460px; text-align: center; }
.tut-panel .muted { margin-top: 0; }
.tut-progress { height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-3); overflow: hidden; margin: 2px 0 10px; }
.tut-progress span { display: block; height: 100%; background: var(--me); }

.chart-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 2px dashed rgb(61 46 40 / 18%); }
.chart-label { flex: 1; display: flex; flex-direction: column; line-height: 1.3; text-align: left; font-size: 17px; }
.chart-label small { color: var(--muted); font-size: 13px; }
.chart-rank { font-size: 13px; color: #e8590c; }
.chart-row .mini-list { margin: 0; flex-wrap: nowrap; gap: 3px; }
.chart-row .mini { width: 34px; height: 48px; font-size: 17px; padding: 2px 4px; }

/* ───────────── 온라인 대기실 ───────────── */
.lobby-panel { text-align: center; }
.lobby-icon { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 40px; }
.lobby-icon .c-me { color: var(--me); }
.lobby-icon .c-opp { color: var(--opp); }
.lobby-icon .c-vs { font-size: 22px; color: var(--ink-soft); }
.seats { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; }
.seat-vs { font-size: 20px; color: var(--muted); }
.seat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 8px;
  border: 2.5px dashed var(--ink-soft);
  border-radius: var(--wobble);
  font-size: 17px;
  color: var(--muted);
}
.seat .seat-av {
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 50% 46% 52% 48%;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: var(--paper-3);
  color: var(--ink);
}
.seat.on { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--opp-soft); }
.seat.on .seat-av { background: var(--opp); }
.seat.me { background: var(--me-soft); }
.seat.me .seat-av { background: var(--me); }
.seat.waiting .seat-av { animation: wiggle 1.4s ease-in-out infinite; }
.seat-no { font-size: 13px; color: var(--muted); }
.invite-row { display: flex; gap: 6px; }
.invite-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 10px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble-2);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  user-select: text;
  -webkit-user-select: text;
}
.invite-row .btn { width: 52px; margin: 0; padding: 0; min-height: 48px; flex: none; }
.small-note { font-size: 13px; margin: 8px 0 0; color: #e8590c; }
