/* 스플렌더 — 어두운 보석함 테마
   색은 전부 아래 변수로 모아두었다. 팔레트만 갈아끼우면 테마가 바뀐다. */
:root {
  --bg:#151318;
  --panel:#1f1c25;
  --panel2:#282332;
  --line:#342e40;
  --line-2:#453d54;
  --ink:#f1ecf5;
  --dim:#a79fb4;
  --faint:#7b7288;
  --accent:#e0b64a;
  --accent-soft:#3a2f16;
  --accent-ink:#1a1409;
  --ok:#5fd1a0;
  --bad:#e0685f;

  --gem-w:#e9e4d8; --gem-w-ink:#2b2822;
  --gem-u:#4a7ede; --gem-u-ink:#f2f6ff;
  --gem-g:#35a86c; --gem-g-ink:#f0fff6;
  --gem-r:#d2454f; --gem-r-ink:#fff1f1;
  --gem-k:#4a4356; --gem-k-ink:#f3eefb;
  --gem-y:#e3b73c; --gem-y-ink:#241a05;

  --shadow: 0 6px 16px rgba(0,0,0,.35);

  /* 판 위의 물건들 — 테마를 갈아끼우면 같이 바뀐다 */
  --noble-glow:#6a5a3a; --noble-1:#40384a; --noble-2:#241f2c; --noble-line:#6a5a38;
  --medal-1:#5b5165; --medal-2:#2c2634;
  --deck-ink:#12101a; --deck-bg2:#14121b; --deck-stripe:rgba(255,255,255,.05);
  --deck-fg:rgba(255,255,255,.62); --deck-lv:#fff; --deck-art:rgba(255,255,255,.12);
  --card-line:rgba(255,255,255,.14); --card-inner:rgba(255,255,255,.16);
  --empty:#1b1822; --zero:#4b4457;
  --veil:rgba(10,8,13,.82); --toast-bg:#2c2536; --sig:#372f44;
  --title-1:#f8e0a2; --title-2:#cf9b28;
  --display:"Hahmlet","Nanum Myeongjo",Georgia,serif;   /* 고대비 세리프 — 보석상 간판의 금박 글씨 */
}

/* 밝은 테마 — 종이와 금박. 카드와 보석 색은 두 테마에서 그대로 둔다. */
:root[data-theme="light"] {
  --bg:#f2ecdf;
  --panel:#fffdf7;
  --panel2:#f5eee0;
  --line:#ddd2bc;
  --line-2:#c6b99f;
  --ink:#2f2a23;
  --dim:#6d6454;
  --faint:#94886f;
  --accent:#a9781d;
  --accent-soft:#f7e7c2;
  --accent-ink:#fffaf0;
  --ok:#2f8b5c;
  --bad:#b8452f;

  --shadow: 0 6px 16px rgba(96,74,40,.16);

  --noble-glow:#f0dcae; --noble-1:#fdf7e8; --noble-2:#efe3c9; --noble-line:#cbab63;
  --medal-1:#fffcf4; --medal-2:#efe2c6;
  --deck-ink:#ffffff; --deck-bg2:#fbf6ea; --deck-stripe:rgba(0,0,0,.045);
  --deck-fg:rgba(60,45,20,.62); --deck-lv:#3b3018; --deck-art:rgba(90,70,35,.16);
  --card-line:rgba(0,0,0,.18); --card-inner:rgba(255,255,255,.22);
  --empty:#ebe3d1; --zero:#c2b69d;
  --veil:rgba(62,50,30,.5); --toast-bg:#fff8e8; --sig:#ddd1b8;
  --title-1:#c68f22; --title-2:#7d5410;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-y: auto; user-select: none;
}

/* ---------- 공통 ---------- */
.screen { min-height: 100%; display: flex; justify-content: center; padding: 26px 16px 40px; }
.screen.wide { padding: 0 0 96px; }
.screen.hidden, .hidden { display: none !important; }
.wrap { width: 100%; max-width: 420px; }

h1 { font-family: var(--display); font-size: 23px; letter-spacing: .22em; font-weight: 700; margin-bottom: 10px; }
h2 { font-family: var(--display); font-size: 12px; letter-spacing: .16em; color: var(--dim); font-weight: 700; margin-bottom: 10px; }
h2.sub { text-align: center; }
.tag { font-size: 12.5px; line-height: 1.85; color: var(--dim); margin-bottom: 20px; word-break: keep-all; }
.fine { font-size: 11px; line-height: 1.7; color: var(--faint); margin-top: 8px; }

.block {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px; margin-bottom: 14px;
}
.row { display: flex; gap: 8px; align-items: flex-end; }
.grow { flex: 1; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 10.5px; letter-spacing: .1em; color: var(--faint); margin-bottom: 5px; }
input, select {
  width: 100%; font: inherit; font-size: 14px; padding: 10px 12px; color: var(--ink);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.code-in { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }

button {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 11px 16px; border-radius: 9px; color: var(--ink);
  background: var(--panel2); border: 1px solid var(--line); transition: .12s;
}
button:hover:not(:disabled) { border-color: var(--line-2); }
button:disabled { opacity: .38; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); width: 100%; }
button.ghost { background: none; border: none; color: var(--faint); width: 100%; font-weight: 500; font-size: 12.5px; }
button.mini { padding: 5px 10px; font-size: 11.5px; border-radius: 7px; }

.code { font-size: 34px; letter-spacing: .34em; font-weight: 800; text-align: center; color: var(--accent); margin: 4px 0 2px; }
.seats { margin: 16px 0; display: flex; flex-direction: column; gap: 7px; }
.seat {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px;
}
.seat .who { flex: 1; }
.seat .mark { font-size: 11px; color: var(--faint); }

/* ---------- 판 ---------- */
.board-wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 12px; }
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 11px 2px; background: linear-gradient(var(--bg) 74%, transparent);
  font-size: 13px; font-weight: 600;
}
.bar .spacer { flex: 1; }
.bar .fine { margin: 0; }
.bar .last { color: var(--accent); font-weight: 700; }

/* 그림 조각은 화면에서 빼두고 <use> 로만 쓴다 */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 귀족 타일 ---------- */
.nobles { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.noble {
  position: relative; overflow: hidden;
  flex: 1 1 0; min-width: 64px; max-width: 100px;
  border-radius: 9px; padding: 5px 4px 4px;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--noble-glow) 0%, transparent 60%),
    linear-gradient(165deg, var(--noble-1), var(--noble-2));
  border: 1px solid var(--noble-line);
  box-shadow: inset 0 0 0 1px rgba(224,182,74,.16), 0 2px 6px rgba(0,0,0,.3);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.noble .bust {
  position: absolute; left: 50%; top: 3px; width: 56%; height: 56%;
  transform: translateX(-50%); fill: rgba(255,255,255,.09);
}
.noble .medal {
  width: 30px; height: 30px; border-radius: 50%; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 34% 26%, var(--medal-1), var(--medal-2));
  border: 1px solid var(--accent); box-shadow: 0 0 0 2px rgba(224,182,74,.14);
  position: relative; z-index: 1;
}
.noble .np {
  position: absolute; left: 4px; top: 3px; z-index: 2;
  font-size: 11px; font-weight: 800; color: var(--accent);
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.noble .nm {
  position: relative; z-index: 1;
  font-size: 9.5px; color: var(--dim); text-align: center; line-height: 1.2;
  word-break: keep-all;
}
.noble .need { display: flex; gap: 3px; position: relative; z-index: 1; }
.noble.pick { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); cursor: pointer; }

/* ---------- 카드 줄 ---------- */
.rows { display: flex; flex-direction: column; gap: 7px; }
.tier { display: flex; gap: 6px; align-items: stretch; }

/* 단계 색 — 1단계 초록, 2단계 호박, 3단계 파랑 */
.t1 { --tier: #3f8f5f; }
.t2 { --tier: #c9942f; }
.t3 { --tier: #4470c4; }

.deck {
  position: relative; overflow: hidden;
  width: 42px; flex: none; border-radius: 9px;
  border: 1px solid var(--tier);
  background:
    repeating-linear-gradient(135deg, var(--deck-stripe) 0 5px, transparent 5px 10px),
    linear-gradient(165deg, color-mix(in srgb, var(--tier) 55%, var(--deck-ink)), var(--deck-bg2));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 9.5px; color: var(--deck-fg); cursor: pointer;
}
.deck .deckart {
  position: absolute; left: 50%; top: 50%; width: 76%; height: 76%;
  transform: translate(-50%, -50%); fill: var(--deck-art);
}
.deck .lv { position: relative; font-size: 12px; font-weight: 800; color: var(--deck-lv); letter-spacing: -.02em; }
.deck .dcount { position: relative; }
.deck.dead { opacity: .35; cursor: default; }
.deck.sel { box-shadow: 0 0 0 2px var(--accent); }

.card {
  position: relative; overflow: hidden;
  flex: 1 1 0; min-width: 0; aspect-ratio: 3 / 4; border-radius: 9px;
  border: 1px solid var(--card-line); cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.28);
  transition: transform .1s, box-shadow .1s;
}
/* 인쇄된 카드처럼 테두리와 아래쪽 그늘을 한 겹 얹는다 */
.card::after {
  content: ''; position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--card-inner), inset 0 -16px 24px rgba(0,0,0,.14);
}
.card.empty::after { display: none; }
.card.empty {
  background: var(--empty); border-style: dashed; border-color: var(--line);
  cursor: default; box-shadow: none;
}
/* 위쪽 띠 — 점수와 보석 문양 */
.card .band {
  position: relative; z-index: 2; height: 32%;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 3px 4px 0; background: linear-gradient(var(--band), transparent);
}
.card .pts {
  font-size: 17px; font-weight: 800; line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.28);
}
.card .gemicon { width: 17px; height: 17px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
/* 카드 그림 */
.card .art {
  position: absolute; left: -4%; bottom: -2%; width: 108%; height: 62%;
  fill: var(--art); pointer-events: none;
}
.card .costs {
  position: absolute; left: 4px; bottom: 4px; z-index: 2;
  display: flex; flex-direction: column-reverse; gap: 2px;
}
.card.buyable { box-shadow: 0 0 0 2px var(--ok), 0 2px 5px rgba(0,0,0,.28); }
.card.sel { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.card.mini { aspect-ratio: auto; height: 64px; width: 52px; flex: none; }
.card.mini .costs { flex-direction: row; flex-wrap: wrap; gap: 1px; right: 4px; }
.card.mini .pts { font-size: 13px; }
.card.mini .gemicon { width: 12px; height: 12px; }
.card.mini .chip { width: 12px; height: 12px; font-size: 8.5px; }

/* 보석 색 — 카드 바탕, 띠, 그림 색을 한 벌로 묶어둔다 */
.gem-w { background: linear-gradient(160deg, #fbf8f0, #ccc4b1); color: var(--gem-w-ink);
         --band: rgba(0,0,0,.13); --art: rgba(70,60,40,.17); }
.gem-u { background: linear-gradient(160deg, #6d9cf0, #23458f); color: var(--gem-u-ink);
         --band: rgba(0,0,0,.3); --art: rgba(255,255,255,.2); }
.gem-g { background: linear-gradient(160deg, #4fca8b, #16663d); color: var(--gem-g-ink);
         --band: rgba(0,0,0,.3); --art: rgba(255,255,255,.2); }
.gem-r { background: linear-gradient(160deg, #ea6d74, #8e222c); color: var(--gem-r-ink);
         --band: rgba(0,0,0,.3); --art: rgba(255,255,255,.2); }
.gem-k { background: linear-gradient(160deg, #6a6179, #241f2e); color: var(--gem-k-ink);
         --band: rgba(0,0,0,.32); --art: rgba(255,255,255,.17); }
.gem-y { background: linear-gradient(160deg, #f6d778, #b6851f); color: var(--gem-y-ink);
         --band: rgba(0,0,0,.16); --art: rgba(80,55,10,.2); }

/* 보석 문양(<use>)의 색. 바탕색과 글자색을 건드리지 않도록 문양에만 따로 준다 */
.g-w { color: #c7bda6; }
.g-u { color: #3f6fd0; }
.g-g { color: #2b9a61; }
.g-r { color: #c9414c; }
.g-k { color: #3d3650; }
.g-y { color: #d9a92e; }

/* ---------- 비용 칩 ---------- */
.chip {
  width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(0,0,0,.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -2px 3px rgba(0,0,0,.22), 0 1px 2px rgba(0,0,0,.3);
}
.chip.paid { opacity: .38; }
.chip.big { width: 20px; height: 20px; font-size: 11.5px; }

/* ---------- 은행 ---------- */
.bank { display: flex; gap: 6px; margin: 12px 0 10px; }
.pile {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 7px 2px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); cursor: default;
}
.pile.live { cursor: pointer; }
.pile.live:hover { border-color: var(--line-2); }
.tok {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(0,0,0,.4);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.45), inset 0 -5px 8px rgba(0,0,0,.3),
    0 2px 4px rgba(0,0,0,.35);
}
.tok .gemicon {
  position: absolute; width: 74%; height: 74%; opacity: .5;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}
.tok .num {
  position: relative; font-size: 12.5px; font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.pile .cnt { font-size: 9.5px; color: var(--faint); letter-spacing: -.03em; }
.pile.on { border-color: var(--accent); background: var(--accent-soft); }
.pile.on .cnt { color: var(--accent); font-weight: 800; font-size: 11px; }
.pile.dead { opacity: .32; }

/* 아래 조작 판 */
.panel {
  position: sticky; bottom: 0; z-index: 6; margin-top: 6px; padding: 10px 0 12px;
  background: linear-gradient(transparent, var(--bg) 26%);
}
.panel .inner {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.panel .msg { font-size: 12.5px; color: var(--dim); flex: 1 1 100%; min-width: 0; line-height: 1.55; }
.panel .msg b { color: var(--ink); }
.panel .picks { display: flex; gap: 4px; }
.panel button { padding: 8px 13px; font-size: 13px; }

/* 내 자리 */
.mine, .others { margin-top: 12px; }
.me-card {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px;
}
.me-card.turn { border-color: var(--accent); }
.who-line { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; margin-bottom: 9px; }
.who-line .pt { margin-left: auto; color: var(--accent); font-size: 15px; }
.who-line .sub { font-size: 10.5px; color: var(--faint); font-weight: 500; }
.stacks { display: flex; gap: 5px; }
.stack {
  position: relative; flex: 1 1 0; display: flex; flex-direction: column;
  align-items: center; gap: 3px; border-radius: 9px; padding: 4px 0 5px;
}
.stack .bn {
  width: 100%; height: 22px; border-radius: 5px; font-size: 11.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 1px solid rgba(0,0,0,.25);
}
.stack .gm { font-size: 11px; color: var(--dim); }
.stack .gm.zero { color: var(--zero); }
/* 버리기 단계 — 칸 전체가 버튼이다. 글자만 누르게 하면 손가락으로는 못 누른다. */
.stack.pickable { cursor: pointer; background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line); }
.stack.pickable:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.stack.pickable .gm { color: var(--ink); }
.stack.tip { box-shadow: inset 0 0 0 2px var(--accent); }
.stack.picked .bn { opacity: .5; }
.stack .minus {
  position: absolute; top: -5px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.stack .gm.on { color: var(--accent); font-weight: 800; }
.kept { display: flex; gap: 5px; margin-top: 9px; align-items: center; }
.kept .lbl { font-size: 10.5px; color: var(--faint); }

.others { display: flex; flex-direction: column; gap: 7px; }
.opp {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.opp.turn { border-color: var(--accent); }
.opp .line1 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.opp .line1 .pt { margin-left: auto; color: var(--accent); font-weight: 800; }
.opp .line2 { display: flex; gap: 4px; margin-top: 7px; align-items: center; flex-wrap: wrap; }
.opp .pair { display: flex; align-items: center; gap: 2px; font-size: 10.5px; color: var(--dim); }
.opp .sq { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); }
.opp .kp { font-size: 10.5px; color: var(--faint); margin-left: 2px; }

.log { margin-top: 14px; font-size: 11px; color: var(--faint); line-height: 1.75; }
.log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log b { color: var(--dim); font-weight: 600; }

/* 덮개 */
.overlay {
  position: fixed; inset: 0; background: var(--veil); z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sheet {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  padding: 22px 20px; width: 100%; max-width: 360px; text-align: center;
}
.sheet.tall { max-width: 420px; text-align: left; max-height: 84vh; overflow-y: auto; }
.sheet .big { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.doc { font-size: 12.5px; line-height: 1.85; color: var(--dim); }
.doc p { margin-bottom: 10px; }
.doc ul { margin: 0 0 10px 16px; }
.doc b { color: var(--ink); }
.scores { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.scores .rowr {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 8px 11px; background: var(--panel2); border-radius: 9px;
}
.scores .rowr.win { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.scores .rowr .pt { margin-left: auto; font-weight: 800; }
.scores .rowr .det { font-size: 10.5px; color: var(--faint); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(10px);
  background: var(--toast-bg); color: var(--ink); border: 1px solid var(--line-2);
  padding: 9px 15px; border-radius: 999px; font-size: 12.5px; z-index: 40;
  opacity: 0; pointer-events: none; transition: .18s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.sig { position: fixed; right: 10px; bottom: 6px; font-size: 10px; color: var(--sig); z-index: 1; }

@media (min-width: 520px) {
  .card .pts { font-size: 20px; }
  .chip { width: 18px; height: 18px; font-size: 11px; }
  .deck { width: 52px; }
}

/* 넓은 화면 — 판은 왼쪽, 내 자리와 기록은 오른쪽에 붙인다 */
@media (min-width: 860px) {
  .screen.wide { padding: 0 0 40px; }
  .board-wrap {
    max-width: 940px; display: grid; gap: 0 18px; align-items: start; justify-content: center;
    grid-template-columns: minmax(0, 560px) 320px;
    grid-template-areas:
      "bar    bar"
      "nobles mine"
      "rows   others"
      "rows   log"
      "bank   log"
      "panel  log";
  }
  .bar    { grid-area: bar; }
  .nobles { grid-area: nobles; }
  .rows   { grid-area: rows; }
  .bank   { grid-area: bank; }
  .panel  { grid-area: panel; position: static; background: none; padding: 0; margin-top: 4px; }
  .mine   { grid-area: mine; margin: 0 0 10px; }
  .others { grid-area: others; margin: 0 0 10px; }
  .log    { grid-area: log; margin: 0; }
  .noble  { max-width: 110px; }
}


/* ---------- 도우미와 안내 ---------- */
/* 슬라이드 스위치 — 도우미와 테마가 같이 쓴다 */
.sw { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
      font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw .track {
  position: relative; flex: none; width: 32px; height: 18px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); transition: .16s;
}
.sw .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--faint); transition: .16s;
}
.sw input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.sw input:checked + .track::after { transform: translateX(14px); background: var(--accent); }
.sw input:focus-visible + .track { box-shadow: 0 0 0 2px var(--accent-soft); }
.sw.theme { flex-direction: row-reverse; gap: 5px; }
.sw.theme .lbl { font-size: 14px; line-height: 1; }
.bar .sw.theme { margin-left: 4px; padding-left: 9px; border-left: 1px solid var(--line); }

/* 홈·대기실 맨 윗줄 */
.topline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topline .sw { margin-left: auto; }

/* 도우미가 짚어 주는 곳 */
.card.tip, .deck.tip { outline: 2px dashed var(--accent); outline-offset: -3px; }
.pile.tip { border-color: var(--accent); border-style: dashed; }
.noble.tip { outline: 2px dashed var(--accent); outline-offset: -3px; }
.panel .coach {
  display: flex; align-items: center; gap: 7px; width: 100%;
  font-size: 12.5px; line-height: 1.5; color: var(--accent);
  padding: 8px 10px; margin-bottom: 2px;
  background: var(--accent-soft); border-radius: 9px;
}
.panel .coach b { color: var(--ink); }
.panel .coach .mark { flex: none; font-size: 13px; }

/* 안내 창 */
.sheet.tour { max-width: 400px; text-align: left; }
.sheet.tour .big { text-align: center; margin-bottom: 14px; }
.tstep .doc { margin-bottom: 10px; }
.demo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 10px; margin-bottom: 14px;
  background: var(--panel2); border-radius: 12px; min-height: 92px;
}
.demo .card.sample { flex: none; width: 74px; cursor: default; padding: 0; background-color: transparent; }
.demo .noble.sample { flex: none; width: 84px; cursor: default; }
.legend .card.sample { flex: none; width: 74px; cursor: default; }
.demo .arrow { color: var(--faint); font-size: 15px; }
.demo .pay { display: flex; align-items: center; gap: 5px; }
.demo .gemicon { width: 22px; height: 22px; }
.demo .gemicon.big { width: 30px; height: 30px; }
.demo .ever { font-size: 11.5px; color: var(--dim); }
.demo .coachdemo {
  font-size: 12.5px; color: var(--accent); background: var(--accent-soft);
  padding: 8px 11px; border-radius: 9px; line-height: 1.5;
}
.dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 14px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); display: block;
}
.dots i.on { background: var(--accent); }

/* 규칙 창의 화면 설명 */
.legend { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.legend > div { flex: 1; }
.legend p { margin-bottom: 6px; font-size: 12px; }


/* ---------- 타이틀 화면 ---------- */
.kicker {
  font-size: 10.5px; letter-spacing: .16em; color: var(--faint); text-transform: uppercase;
}
/* 타이틀은 화면 가운데에 — 맨 윗줄만 위에 남긴다 */
#home .wrap { min-height: calc(100vh - 70px); display: flex; flex-direction: column; }
.hero { text-align: center; margin: auto 0; padding-bottom: 8vh; }

/* 보석 다섯 개를 부채처럼 펼쳐 놓는다 */
.fan { display: flex; align-items: flex-end; justify-content: center; gap: 2px; margin-bottom: 14px; }
.fan .gemicon {
  width: 26px; height: 26px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.35));
  /* 아래에서 떠올라 자리 잡고, 그 뒤로 천천히 둥둥 — 등장은 translate/scale, 둥둥은 margin이라 서로 안 겹친다 */
  animation: gemIn .7s cubic-bezier(.2,.9,.3,1.2) var(--d, 0s) backwards,
             gemFloat 3.8s ease-in-out calc(var(--d, 0s) + .7s) infinite;
}
.fan .gemicon:nth-child(1) { --d: .28s; }
.fan .gemicon:nth-child(2) { --d: .14s; }
.fan .gemicon:nth-child(3) { --d: 0s; }
.fan .gemicon:nth-child(4) { --d: .14s; }
.fan .gemicon:nth-child(5) { --d: .28s; }
@keyframes gemIn { from { opacity: 0; translate: 0 26px; scale: .5; } }
@keyframes gemFloat { 0%, 100% { margin-top: 0; } 50% { margin-top: -8px; } }
@media (prefers-reduced-motion: reduce) { .fan .gemicon { animation: none; } }
.fan .gemicon.big { width: 40px; height: 40px; margin: 0 2px; }
.fan .gemicon:nth-child(1) { transform: rotate(-16deg) translateY(6px); }
.fan .gemicon:nth-child(2) { transform: rotate(-8deg)  translateY(1px); }
.fan .gemicon:nth-child(4) { transform: rotate(8deg)   translateY(1px); }
.fan .gemicon:nth-child(5) { transform: rotate(16deg)  translateY(6px); }

.hero h1 {
  font-family: var(--display);
  font-size: clamp(40px, 13vw, 58px); line-height: 1.05; letter-spacing: .14em;
  font-weight: 800; margin: 0 0 12px; padding-left: .1em;
  background: linear-gradient(155deg, var(--title-1), var(--title-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--accent);
}
.hero .tag { margin: 0 auto 18px; max-width: 25em; word-break: keep-all; }
.hero-acts { display: flex; flex-direction: column; align-items: center; gap: 10px; }
button.big {
  font-size: 16px; padding: 15px 20px; border-radius: 12px;
  width: 100%; max-width: 260px; letter-spacing: .02em;
}
.back {
  width: auto; padding: 5px 11px; font-size: 12px; border-radius: 8px;
  color: var(--dim); background: none; border-color: transparent;
}
.back:hover:not(:disabled) { color: var(--ink); border-color: var(--line); }
.learn {
  width: auto; font-size: 13px; padding: 9px 18px; border-radius: 999px;
  color: var(--accent); border-color: var(--accent); background: transparent;
}
.learn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }

/* 이름은 한 줄로 — 폼처럼 보이지 않게 */
.namerow {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding: 6px 8px 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
}
.namerow > span { font-size: 11.5px; letter-spacing: .08em; color: var(--faint); flex: none; }
.namerow input {
  border: none; background: none; padding: 6px 8px; font-size: 14px;
}
.namerow input:focus { outline: none; }
.namerow:focus-within { border-color: var(--accent); }

/* 저작권 고지 — 타이틀 아래, 자세히 봐야 보일 만큼만 */
.legal{margin:26px auto 0;max-width:36em;font-size:10.5px;line-height:1.75;color:var(--faint);opacity:.7;text-align:center;word-break:keep-all}

/* ─────────── 넓은 화면 오른쪽 열 ───────────
   카드 줄이 길어서 오른쪽 아래가 500px 가까이 비어 보였다.
   상대 칸과 기록을 패널로 세우고 남은 높이를 채우게 한다. */
@media (min-width: 860px) {
  .others {
    align-self: start;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px; gap: 8px;
  }
  .others::before {
    content: '상대';
    font-size: 10px; letter-spacing: .14em; font-weight: 700;
    color: var(--faint); padding: 0 2px 2px;
  }
  .log {
    align-self: stretch;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 12px 11px;
    overflow-y: auto;
    min-height: 96px;
  }
  .log::before {
    content: '기록';
    display: block;
    font-size: 10px; letter-spacing: .14em; font-weight: 700;
    color: var(--faint); margin-bottom: 5px;
  }
  .log:empty::before { content: '기록'; }
}

/* ─────────── 방금 둔 수 ───────────
   봇이 조용히 움직이면 판이 왜 바뀌었는지 알 수 없다. 화면 위에 한 줄로 띄운다.
   판을 밀지 않도록 떠 있는 자리에 두고, 다 읽을 만큼만 머문다. */
.movebar {
  position: fixed; left: 50%; top: 10px; transform: translateX(-50%) translateY(-14px);
  z-index: 40; pointer-events: none;
  display: flex; align-items: baseline; gap: 10px;
  max-width: min(94vw, 620px);
  padding: 9px 18px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line-2);
  box-shadow: 0 14px 34px -14px rgba(0,0,0,.55);
  opacity: 0; transition: opacity .16s ease, transform .16s ease;
}
.movebar.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.mv-who { font-size: 13px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.mv-what { font-size: 13.5px; font-weight: 600; color: var(--ink); }
/* 좁은 화면에서는 상단 바(차례·도우미)를 덮지 않도록 그 아래로 내리고,
   좁은 알약 안에서 두 줄로 삐져나오지 않게 폭을 화면에 맞춘다. */
@media (max-width: 560px) {
  .movebar {
    left: 8px; right: 8px; max-width: none;
    top: 54px; transform: translateY(-10px);
    border-radius: 12px;
    padding: 8px 13px; gap: 7px;
    justify-content: center; flex-wrap: wrap;
  }
  .movebar.on { transform: translateY(0); }
  .mv-who, .mv-what { font-size: 12.5px; }
}

/* ─────────── 타이틀 아래 빈 공간 ───────────
   본문이 가운데에 서고 고지가 바닥에 붙게 한다. 둘 사이가 아니라 위아래로 나뉜다. */
#home .hero { padding-bottom: 0; }
#home .legal { margin-top: auto; padding-top: 26px; padding-bottom: 14px; }

/* ---------------- 채팅 ----------------
   같은 방 사람끼리 하는 잡담. 판을 가리지 않도록 구석에 접어 두고 열었을 때만 자리를 차지한다. */
.chat-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 45;
  width: 48px; height: 48px; border-radius: 50%; padding: 0;
  font-size: 20px; line-height: 1; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  box-shadow: 0 12px 26px -12px rgba(0,0,0,.6);
}
.chat-n {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; border-radius: 999px; padding: 0 5px;
  font-size: 11px; font-weight: 800; line-height: 18px;
  background: var(--bad); color: #fff;
}
.chat-n.pop { animation: chatPop .5s cubic-bezier(.3,1.7,.5,1); }
@keyframes chatPop { from { transform: scale(.3); } }
/* 접힌 채팅에 새 말이 오면 버튼 옆에 잠깐 띄우는 말풍선. 누르면 채팅이 열린다. */
.chat-peek {
  position: fixed; right: 74px; bottom: 21px; z-index: 45;
  max-width: min(260px, calc(100vw - 96px));
  padding: 8px 12px; border-radius: 13px 13px 4px 13px;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 12px 26px -12px rgba(0,0,0,.6);
  font-size: 13px; line-height: 1.45; cursor: pointer; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  animation: chatPeekIn .2s ease-out; transition: opacity .25s, transform .25s;
}
.chat-peek b { color: var(--dim); font-weight: 700; margin-right: 6px; }
.chat-peek.bye { opacity: 0; transform: translateX(6px); }
@keyframes chatPeekIn { from { opacity: 0; transform: translateX(8px); } }
/* 폰에서는 아래에 두면 손패·조작 판 위를 덮는다. 채팅창이 열리는 위쪽 자리에 띄운다. */
@media (max-width: 560px) {
  .chat-peek { top: 56px; bottom: auto; left: 12px; right: 12px; max-width: none; border-radius: 13px; animation-name: chatPeekDown; }
  .chat-peek.bye { transform: translateY(-6px); }
}
@keyframes chatPeekDown { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .chat-peek, .chat-n.pop { animation: none; transition: none; } }
/* hidden 속성은 브라우저 기본 display:none 이라, 아래처럼 display 를 선언한 요소에서는
   밀려서 무시된다. 그래서 채팅창이 첫 화면부터 떠 있고 ✕로도 닫히지 않았다. */
.chat[hidden], .chat-peek[hidden] { display: none; }
.chat {
  position: fixed; right: 16px; bottom: 16px; z-index: 46;
  width: min(320px, calc(100vw - 32px)); height: min(380px, 60vh);
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 24px 54px -18px rgba(0,0,0,.7);
}
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink);
}
.chat-sub { color: var(--faint); font-size: 11.5px; }
.chat-x {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  color: var(--faint); font-size: 15px; line-height: 1; padding: 2px 4px; width: auto;
}
.chat-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { font-size: 13px; line-height: 1.5; color: var(--ink); word-break: break-word; margin: 0; }
.chat-msg b { color: var(--faint); font-weight: 700; margin-right: 5px; }
.chat-msg.mine b { color: var(--accent); }
.chat-log:empty::before { content: '아직 아무 말도 없습니다'; color: var(--faint); font-size: 12px; opacity: .75; }
.chat-in { display: flex; gap: 6px; padding: 9px 10px; border-top: 1px solid var(--line); }
.chat-in input { flex: 1; min-width: 0; font-size: 13px; padding: 8px 10px; margin: 0; }
.chat-in button { width: auto; margin: 0; padding: 8px 12px; font-size: 13px; }
/* 좁은 화면에서 아래에 두면 조작 판을 덮는다. 위로 올린다. */
@media (max-width: 560px) {
  .chat { top: 56px; bottom: auto; height: min(46vh, 330px); left: 12px; right: 12px; width: auto; }
}
