/* 형세 장기 — 형세 대국(바둑·오목)과 같은 디자인 */
:root {
  --bg: #15171b;
  --bg2: #1c1f25;
  --panel: #20242b;
  --line: #2f343d;
  --text: #ece8df;
  --muted: #9a9a93;
  --accent: #d9a441;
  --accent-ink: #1b1508;
  --jade: #5fb59a;
  --red: #e0675a;
  --cho: #3f86d6;      /* 초 (파랑) */
  --han: #d8473b;      /* 한 (빨강) */
  --radius: 12px;
  --serif: 'Noto Serif KR', serif;
  --sans: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; }
body { min-height: 100vh; background:
  radial-gradient(1200px 600px at 80% -10%, rgba(217,164,65,.08), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, rgba(63,134,214,.07), transparent 60%), var(--bg); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* 상단 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; background: rgba(21,23,27,.9); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.brand-mark { position: relative; width: 36px; height: 24px; flex: none; }
.brand-mark i { position: absolute; top: 0; width: 22px; height: 22px; display: grid; place-items: center; font-style: normal;
  font: 900 12px/1 var(--serif); background: #f3e6c4; border-radius: 4px;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.brand-mark .cho { left: 0; color: var(--cho); }
.brand-mark .han { left: 14px; top: 2px; color: var(--han); }
.brand-name { font-family: var(--serif); font-weight: 800; font-size: 19px; letter-spacing: .02em; white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 12px; }
.nick { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.nick input { width: 110px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); }

/* 공통 */
.view { max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.btn { border: 1px solid var(--line); background: var(--bg2); padding: 9px 16px; border-radius: 10px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #4a515d; background: #262a32; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #e6b354; }
.btn.danger { color: var(--red); }
.btn.exit { background: rgba(224,103,90,.16); border-color: rgba(224,103,90,.6); color: #f3b3a9; font-weight: 700; }
.btn.exit:hover:not(:disabled) { background: rgba(224,103,90,.28); border-color: #e0675a; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.tiny { padding: 3px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 12px 28px; font-size: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.eyebrow b { color: var(--accent); font-family: ui-monospace, monospace; }
.side-chip { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; font: 900 12px/1 var(--serif); color: #fff; border-radius: 5px;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.side-chip.c0 { background: var(--cho); }
.side-chip.c1 { background: var(--han); }

/* 로비 */
.lobby-hero { padding: 26px 0 26px; }
.lobby-hero h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 46px); line-height: 1.2; margin: 0 0 12px; }
.lobby-hero h1 em { font-style: normal; color: var(--accent); }
.lobby-hero p { color: var(--muted); margin: 0 0 22px; max-width: 600px; line-height: 1.6; }
.create { display: flex; gap: 10px; max-width: 520px; }
.create input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); }
.room-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.room { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room .rname { font-weight: 700; margin-bottom: 4px; }
.room .rmeta { font-size: 13px; color: var(--muted); }
.pill { display: inline-block; white-space: nowrap; vertical-align: 1px; font-size: 11px; padding: 2px 8px; border-radius: 99px; margin-right: 6px; border: 1px solid var(--line); }
.pill.st-waiting { color: var(--jade); border-color: rgba(95,181,154,.5); }
.pill.st-playing, .pill.st-ended { color: var(--accent); border-color: rgba(217,164,65,.5); }
.empty { color: var(--muted); padding: 20px 0; }
.rules-card { margin-top: 26px; }
.rules-card h3 { margin: 0 0 8px; font-size: 15px; }
.rules-card ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.rules-card b { color: var(--text); }

/* AI */
.ai-panel { margin: 0 0 26px; border-color: rgba(95,181,154,.45); }
.ai-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ai-head h2 { margin: 0 0 2px; font-size: 18px; font-family: var(--serif); }
.ai-head .muted { font-size: 13px; }
.ai-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: rgba(95,181,154,.18); color: var(--jade); border: 1px solid rgba(95,181,154,.5); }
.ai-opts { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.ai-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.ai-field select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); min-width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg2); }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-size: 14px; color: var(--text); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--jade); color: #0d241d; font-weight: 700; }
.ai-desc { font-size: 13px; margin: 12px 0; line-height: 1.5; }

/* 대기실 */
.waiting { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.wait-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
.wait-head h2 { margin: 2px 0 0; font-family: var(--serif); font-size: 24px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.seat { border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px 18px; min-height: 88px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.seat.filled { border-style: solid; background: var(--bg2); }
.seat .sname { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.seat .stag { font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jade); display: inline-block; flex: none; }
.dot.off { background: #666; }
.crown { font-size: 11px; color: var(--accent); border: 1px solid rgba(217,164,65,.5); border-radius: 6px; padding: 1px 6px; }
.me-tag { font-size: 11px; color: var(--jade); border: 1px solid rgba(95,181,154,.5); border-radius: 6px; padding: 0 5px; }
.setup-box { margin-bottom: 18px; }
.setup-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.setup-head h3 { margin: 0; font-size: 15px; }
.setup-head .muted { font-size: 12px; }
.setup-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.setup-opt { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; container-type: inline-size; }
.setup-opt.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(217,164,65,.08); }
.setup-opt b { font-size: 14px; }
/* 말 9개가 카드 폭에 맞춰 줄어든다 (폰 2열에서도 넘치지 않게) */
.setup-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 2px; width: 100%; max-width: 196px; }
.setup-row i { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font: 900 10px/1 var(--serif); font-size: min(11px, 6.5cqi); font-style: normal; background: #f3e6c4; color: #333;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.setup-row i.k { color: var(--accent-ink); opacity: .45; }
.setup-row i.hl { color: var(--cho); }
.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.settings label { min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.settings select { width: 100%; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
.wait-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; text-align: right; margin: 10px 0 0; min-height: 1em; }

/* 채팅 */
.chat-panel { display: flex; flex-direction: column; min-height: 260px; }
.waiting .chat-panel { height: 560px; }
.chat-log { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.55; padding-right: 4px; min-height: 120px; }
.chat-log .sys { color: var(--muted); font-size: 12px; }
.chat-log .from { color: var(--accent); font-weight: 700; margin-right: 6px; }
.chat-log .from.me { color: var(--jade); }
/* 이모티콘 채팅 */
.emo-line { display: flex; align-items: center; gap: 2px; }
.emo-line .emo { font-size: 22px; line-height: 1.3; }
.emote-bar { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.emote-btn { aspect-ratio: 1; min-height: 36px; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; padding: 0; transition: transform .1s, border-color .15s; }
.emote-btn:hover { border-color: var(--accent); }
.emote-btn:active { transform: scale(.9); }
.emote-btn.sent { animation: emo-sent .4s ease-out; }
@keyframes emo-sent { 50% { transform: scale(1.25); border-color: var(--jade); } }
.emote-pops { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.emote-pop { position: absolute; right: 5%; display: grid; place-items: center; width: clamp(64px, 16vw, 104px); aspect-ratio: 1; border-radius: 50%; font-size: clamp(38px, 9.5vw, 62px); line-height: 1; background: rgba(21,23,27,.82); border: 2px solid rgba(217,164,65,.7); box-shadow: 0 8px 22px rgba(0,0,0,.4); animation: emo-pop 2.6s ease-out forwards; }
.emote-pop.top { top: 8%; }
.emote-pop.bottom { bottom: 8%; }
.emote-pop.spec { left: calc(50% - clamp(32px, 8vw, 52px)); right: auto; top: 40%; border-color: rgba(154,154,147,.6); }
@keyframes emo-pop { 0% { transform: scale(.3); opacity: 0; } 12% { transform: scale(1.15); opacity: 1; } 22% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: translateY(-16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .emote-pop, .emote-btn.sent { animation-duration: .01s; } }

/* 대국 */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.scorebar { display: grid; grid-template-columns: 1fr minmax(160px, 1.3fr) 1fr; gap: 12px; align-items: stretch; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; transition: border-color .2s, box-shadow .2s; min-width: 0; }
.pcard.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pcard .prow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard .pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .pmeta { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; font-size: 12px; color: var(--muted); }
.pcard .caps { font: 700 13px/1.3 var(--serif); letter-spacing: 1px; min-height: 17px; word-break: break-all; }
.caps .c0 { color: var(--cho); } .caps .c1 { color: var(--han); }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; color: var(--text); }
.clock.byo { color: var(--accent); }
.clock.low { color: var(--red); }
.clock.paused { color: var(--muted); }
.gauge { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.gauge-bar { position: relative; height: 22px; border-radius: 99px; overflow: hidden; background: linear-gradient(90deg, #a83a30, var(--han)); border: 1px solid #3a3f48; }
.gauge-cho { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(90deg, #275f9f, var(--cho)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.gauge-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--accent); opacity: .8; }
.gauge-text { display: flex; justify-content: space-between; flex-wrap: wrap; row-gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
.gauge-text .t-cho { color: #8cbcf0; font-weight: 700; }
.gauge-text .t-han { color: #f19a90; font-weight: 700; }
.gauge-text .lead { font-weight: 700; color: var(--accent); text-align: center; order: 3; flex-basis: 100%; line-height: 1.35; }
.board-wrap { position: relative; width: 100%; max-width: min(100%, calc((100vh - 250px) * 0.9)); min-width: 280px; margin: 0 auto; aspect-ratio: 9 / 10; }
#board { width: 100%; height: 100%; display: block; border-radius: 8px; box-shadow: 0 18px 40px rgba(0,0,0,.45); touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.controls .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }
.review-bar { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; background: rgba(217,164,65,.1); border: 1px solid rgba(217,164,65,.35); border-radius: 10px; padding: 6px; flex-wrap: wrap; }
.review-bar span { min-width: 140px; text-align: center; color: var(--accent); }
.offline-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  background: rgba(224,103,90,.12); border: 1px solid rgba(224,103,90,.45); color: #f1c3bc; }
.offline-bar span { flex: 1; min-width: 200px; }
.undo-pop { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(20,22,26,.95); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 5; white-space: nowrap; }
/* 장군! 멍군! 빅장! */
.call-pop { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  font: 900 clamp(34px, 9vw, 64px)/1 var(--serif); color: #fff; padding: 14px 30px; border-radius: 18px;
  background: rgba(150,30,24,.88); box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: call 1.4s ease-out forwards; letter-spacing: .1em; }
.call-pop.cho { background: rgba(30,80,150,.88); }
.call-pop.soft { background: rgba(30,32,38,.9); font-size: clamp(26px, 6vw, 44px); }
@keyframes call { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
.result-pop { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(8,10,14,.45); border-radius: 8px; animation: rp-fade .25s ease-out; }
.rp-card { position: relative; width: min(330px, 100%); text-align: center; background: rgba(24,27,33,.97); border: 1px solid var(--accent); border-radius: 16px; padding: 20px 18px 16px; box-shadow: 0 18px 50px rgba(0,0,0,.6); animation: rp-pop .3s cubic-bezier(.2,1.4,.4,1); }
.result-pop.win .rp-card { border-color: var(--jade); }
.result-pop.lose .rp-card { border-color: var(--red); }
.rp-x { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.rp-icon { font-size: 40px; line-height: 1; margin-bottom: 6px; }
.rp-head { font-size: 24px; font-weight: 800; color: var(--accent); }
.result-pop.win .rp-head { color: var(--jade); }
.result-pop.lose .rp-head { color: var(--red); }
.rp-why { margin-top: 8px; font-size: 16px; font-weight: 600; }
.rp-text { margin-top: 4px; font-size: 13px; color: var(--muted); }
.rp-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
@keyframes rp-fade { from { opacity: 0; } }
@keyframes rp-pop { from { transform: scale(.85); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .result-pop, .rp-card, .call-pop { animation: none; } .call-pop { opacity: 0; } }

.side { display: flex; flex-direction: column; gap: 14px; }
#graph { width: 100%; height: 150px; display: block; cursor: crosshair; }
.graph-legend { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.engine-tag { font-size: 11px; color: var(--muted); }
.last-eval { margin-top: 10px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--bg2); min-height: 20px; line-height: 1.5; }
.last-eval .good { color: var(--jade); font-weight: 700; }
.last-eval .bad { color: var(--red); font-weight: 700; }
.last-eval .meh { color: var(--accent); font-weight: 700; }
.move-list { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow-y: auto; font-size: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.move-list li { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.move-list li:hover { background: var(--bg2); }
.move-list li.cur { background: rgba(217,164,65,.15); }
.move-list .n { color: var(--muted); min-width: 22px; text-align: right; font-size: 11px; }
.move-list .q { margin-left: auto; font-size: 11px; }
.q-good { color: var(--jade); } .q-bad { color: var(--red); } .q-meh { color: var(--accent); }
.game-info .info-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
#gameMeta { font-size: 13px; line-height: 1.6; }
.side .chat-panel { height: 240px; }

.conn-bar { position: sticky; top: 0; z-index: 30; background: #7a2e25; color: #fff; text-align: center; font-size: 13px; padding: 8px 12px; }

.ask-dlg { width: min(380px, calc(100vw - 32px)); padding: 20px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.ask-dlg::backdrop { background: rgba(0,0,0,.6); }
.ask-dlg h3 { margin: 0 0 8px; font-size: 18px; }
.ask-dlg p { margin: 0 0 16px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── 전적 (형세 대국과 같은 모양) ── */
.side-chip.sm { width: 16px; height: 16px; font-size: 9px; vertical-align: -3px; }
.back { margin-top: 4px; }
.rec-card { display: flex; align-items: center; gap: 14px; width: 100%; margin: 0 0 18px; text-align: left; cursor: pointer; color: var(--text); transition: border-color .15s; }
.rec-card:hover { border-color: var(--accent); }
.rc-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; font: 900 20px/1 var(--serif);
  background: rgba(217,164,65,.14); color: var(--accent); border: 1px solid rgba(217,164,65,.45); }
.rc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rc-title { font-family: var(--serif); font-weight: 800; font-size: 17px; }
.rc-line { font-size: 14px; }
.rc-go { flex: none; font-size: 13px; color: var(--accent); font-weight: 700; }
.ai-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ai-rec { font-size: 13px; color: var(--muted); }
.seat .stag.rec { color: var(--text); }
.rp-rec { margin-top: 8px; font-size: 12px; color: var(--jade); }
.rp-rec.muted { color: var(--muted); }

.rec-head h1 { font-family: var(--serif); font-size: clamp(28px, 4.5vw, 40px); margin: 14px 0 6px; }
.rec-head p { margin: 0 0 18px; font-size: 13px; line-height: 1.6; }
.rec-stats { margin-bottom: 14px; }
.rec-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.rb-num { font-family: var(--serif); font-size: 32px; font-weight: 800; line-height: 1.1; }
.rb-num small { font-size: 15px; margin-left: 2px; color: var(--muted); }
.rb-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wbar { position: relative; display: flex; height: 8px; border-radius: 99px; background: rgba(224,103,90,.55); overflow: hidden; }
.wbar.empty { background: var(--line); }
.wbar i { display: block; height: 100%; background: var(--jade); }
.wbar b { display: block; height: 100%; background: #6b6f78; }
.rec-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; font-size: 14px; }
.rec-sides > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-recent { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; }
.rec-recent i { font-style: normal; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 6px; font-weight: 700; font-size: 11px; }
.dot-win { background: rgba(95,181,154,.25); color: var(--jade); }
.dot-loss { background: rgba(224,103,90,.22); color: var(--red); }
.dot-draw { background: rgba(255,255,255,.08); color: var(--muted); }
.rec-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.rec-grid > *, .rec-side > * { min-width: 0; }
.rec-side { display: flex; flex-direction: column; gap: 14px; }
.rec-games { list-style: none; margin: 0; padding: 0; }
.rec-games li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rec-games li:last-child { border-bottom: 0; }
.rg-main { flex: 1; min-width: 0; }
.rg-main > div:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rg-main > div:first-child b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-main .muted { font-size: 12px; margin-top: 2px; }
.rg-res { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-weight: 800; }
.res-win { background: rgba(95,181,154,.2); color: var(--jade); }
.res-loss { background: rgba(224,103,90,.18); color: var(--red); }
.res-draw { background: rgba(255,255,255,.08); color: var(--muted); }
.rec-games.compact li { padding: 7px 0; font-size: 13px; }
.rec-games.compact .rg-res { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.ai-row, .opp-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.ai-row { grid-template-columns: 56px minmax(0, 1fr) auto; }
.opp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-rec { font-size: 13px; color: var(--muted); white-space: nowrap; }
.code-panel h3 { margin: 0 0 6px; font-size: 15px; }
.code-panel h4 { margin: 0 0 8px; font-size: 14px; }
.code-panel p { font-size: 13px; line-height: 1.55; margin: 0 0 10px; }
.code-big { font: 800 26px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 3px; text-align: center; padding: 12px; background: rgba(217,164,65,.12); color: var(--accent); border-radius: 12px; margin-bottom: 8px; user-select: all; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: 700 16px ui-monospace, monospace; letter-spacing: 2px; text-transform: uppercase; }
.code-sep { height: 1px; background: var(--line); margin: 16px 0 14px; }

/* 기보 다시 보기 창 */
.replay-dlg { width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; padding: 14px 14px 12px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.replay-dlg::backdrop { background: rgba(0,0,0,.65); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dlg-head h3 { margin: 0; font-size: 18px; font-family: var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-x { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); cursor: pointer; font-size: 16px; }
.rp-meta { font-size: 12px; line-height: 1.6; margin: 6px 0 10px; }
.rp-board { width: 100%; max-width: min(100%, calc((100vh - 230px) * .9)); margin: 0 auto; aspect-ratio: 9 / 10; }
#rpBoard { width: 100%; height: 100%; display: block; border-radius: 8px; cursor: pointer; touch-action: manipulation; }
.rp-move { min-height: 22px; margin: 10px 0 8px; font-size: 14px; text-align: center; }
.rp-nav { display: flex; align-items: center; justify-content: center; gap: 6px; }
.rp-nav .btn { min-width: 44px; min-height: 40px; font-size: 16px; }
.rp-nav span { min-width: 92px; text-align: center; font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .game { grid-template-columns: 1fr; }
  .rec-grid { grid-template-columns: minmax(0, 1fr); }
  .waiting { grid-template-columns: 1fr; }
  .waiting .chat-panel { height: 300px; }
  .board-wrap { max-width: 100%; }
}
@media (max-width: 640px) {
  .view { padding: 14px 10px 30px; }
  .top { padding: 10px 12px; gap: 8px; }
  .top-right { gap: 6px; }
  .nick span { display: none; }
  .nick input { width: 84px; padding: 6px 8px; }
  .brand-name { font-size: 17px; }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 폰: 상차림 4개를 한 줄에 하나씩 (이름 왼쪽, 말 오른쪽) */
  .setup-pick { grid-template-columns: minmax(0, 1fr); }
  .setup-opt { flex-direction: row; justify-content: space-between; gap: 10px; padding: 10px 12px; }
  .setup-opt b { flex: none; width: 64px; text-align: left; }
  .setup-row { max-width: 270px; gap: 3px; }
  .setup-row i { font-size: min(14px, 3.3vw); }
  .scorebar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gauge { grid-column: 1 / -1; order: -1; }
  .create { flex-direction: column; }
  .clock { font-size: 14px; }
  .seats { grid-template-columns: 1fr; }
  .controls .btn { padding: 10px 14px; }
  .seg button { padding: 8px 11px; font-size: 13px; }
  #aiStart { width: 100%; }
  .wait-actions .btn.big { padding: 12px 20px; }
  .rec-big .rb-num { font-size: 26px; }
  .rec-sides { grid-template-columns: minmax(0, 1fr); }
  .rc-go { display: none; }
  #recBtnTop { padding: 6px 9px; }
}
.waiting > *, .game > * { min-width: 0; }
