/* 증강 틱택토 — 증강체스 톤: 종이 + 잉크 모노, 앰버 악센트 하나 */
:root {
  color-scheme: light;
  --bg: #eef0ec;
  --surface: #fbfaf6;
  --surface-2: #ebe8df;
  --ink: #151719;
  --muted: #65706e;
  --line: #202326;
  --line-soft: rgba(21, 23, 25, .14);
  --light-square: #f7f5ef;
  --dark-square: #e3e1d8;
  --stone: #99a2a0;
  --amber: #dfa124;
  --amber-soft: rgba(223, 161, 36, .22);
  --danger: #d62f36;
  --shadow: 6px 7px 0 rgba(21, 23, 25, .16);
  --shadow-sm: 3px 3px 0 rgba(21, 23, 25, .16);
  font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .4; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--ink); }
b { font-weight: 800; }

/* 상단 바 */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 18px; border-bottom: 2px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { white-space: nowrap; font-weight: 900; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.topbar .back { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.topbar .back:hover { color: var(--ink); }
.chip {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); font-size: 13px; color: var(--muted);
}
.chip.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .2em; color: var(--ink); font-weight: 800; }
.btn {
  white-space: nowrap; border: 2px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 14px; font-weight: 700; box-shadow: var(--shadow-sm); transition: transform .06s, box-shadow .06s;
}
.btn:hover:not(:disabled) { background: #fff; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(21, 23, 25, .16); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover:not(:disabled) { background: #2b3033; }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* 로비 */
.lobby { max-width: 980px; margin: 0 auto; padding: 40px 20px 60px; }
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: clamp(34px, 6vw, 52px); margin: 0 0 8px; letter-spacing: -.02em; line-height: 1; }
.hero h1 .x, .hero h1 .o { color: var(--ink); }
.hero p { color: var(--muted); margin: 0; }
.name-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 20px 0 26px; }
.name-row label { color: var(--muted); font-size: 14px; }
.input {
  background: var(--surface); border: 2px solid var(--line); border-radius: 8px;
  padding: 8px 12px; outline: none; min-width: 200px;
}
.input:focus { box-shadow: 0 0 0 3px var(--amber-soft); }
.input.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .25em; text-transform: uppercase; width: 130px; min-width: 0; text-align: center; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.mode {
  background: var(--surface); border: 3px solid var(--line); border-radius: 16px;
  padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.mode .icon { width: 64px; height: 64px; margin: 0 auto 4px; }
.mode h3 { margin: 0; text-align: center; font-size: 18px; font-weight: 900; }
.mode p { margin: 0; color: var(--muted); font-size: 13px; text-align: center; min-height: 40px; word-break: keep-all; }
.mode .row { display: flex; gap: 8px; justify-content: center; }
.rules { margin-top: 32px; background: var(--surface); border: 3px solid var(--line); border-radius: 16px; padding: 18px 22px; box-shadow: var(--shadow); }
.rules h3 { margin: 0 0 8px; font-size: 16px; font-weight: 900; }
.rules ol { margin: 0; padding-left: 20px; font-size: 14px; }
.rules li { margin: 4px 0; }
.codex { margin-top: 16px; }
.codex summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.status-line { text-align: center; color: var(--muted); font-size: 13px; min-height: 20px; margin-top: 14px; }

/* 게임 화면 */
.game { display: grid; grid-template-columns: 250px minmax(340px, 1fr) 290px; gap: 16px; max-width: 1240px; margin: 0 auto; padding: 18px 18px 40px; }
.panel { background: var(--surface); border: 2px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); }
.panel .head { padding: 8px 14px; border-bottom: 2px solid var(--line); font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.panel .body { padding: 12px 14px; }
.side { display: flex; flex-direction: column; gap: 14px; }

.player {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line-soft); background: var(--surface);
}
.player + .player { margin-top: 8px; }
.player.active { border-color: var(--line); background: #fff; box-shadow: var(--shadow-sm); }
.player .mark { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-weight: 900; font-size: 22px; border: 2px solid var(--line); }
.player .mark.x { background: var(--ink); color: var(--surface); }
.player .mark.o { background: var(--surface); color: var(--ink); }
.player .name { font-weight: 800; display: flex; align-items: center; gap: 6px; }
.player .name .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; }
.player .name .dot.on { background: var(--ink); }
.player .sub { font-size: 12px; color: var(--muted); }
.player .stars { color: var(--amber); font-weight: 800; font-size: 13px; text-align: right; }
.player .you { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--ink); color: var(--surface); }
.augchips { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1 / -1; }
.augchip { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface); border: 1.5px solid var(--line); }
.augchip.used { opacity: .4; text-decoration: line-through; }
.augchip.rule { border-style: dashed; }
.score { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 0 2px; }
.score .dots { display: flex; gap: 6px; }
.score .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: transparent; }
.score .dot.x { background: var(--ink); }
.score .dot.o { background: var(--surface); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 5px var(--ink); }
.score .dot.d { background: var(--stone); }
.score .dot.cur { box-shadow: 0 0 0 3px var(--amber-soft); }
.score .num { font-weight: 900; font-size: 22px; }
.spect { text-align: center; color: var(--muted); font-size: 12px; }

.center { display: flex; flex-direction: column; gap: 12px; }
.turnline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.turnline .round { font-weight: 900; letter-spacing: .06em; }
.turnline .turn { font-weight: 800; }
.turnline .chip { font-size: 12px; padding: 1px 8px; border-style: dashed; }
.boardwrap { padding: 18px; display: grid; place-items: center; }
.board {
  display: grid; gap: 0; width: min(100%, 420px); aspect-ratio: 1;
  background: var(--line); padding: 3px; border-radius: 10px; border: 3px solid var(--line);
  box-shadow: var(--shadow);
}
.board.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.board.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); }
.cell {
  position: relative; min-width: 0; min-height: 0; padding: 0; margin: 0; overflow: hidden;
  border: 1.5px solid var(--line); background: var(--light-square);
  display: grid; place-items: center; font-weight: 900; font-size: clamp(30px, 8vmin, 66px); line-height: 1;
  color: var(--ink); transition: background .1s; user-select: none;
}
.board.n3 .cell:nth-child(even) { background: var(--dark-square); }
.board.n4 .cell:nth-child(8n+2), .board.n4 .cell:nth-child(8n+4), .board.n4 .cell:nth-child(8n+5), .board.n4 .cell:nth-child(8n+7) { background: var(--dark-square); }
.board.n4 .cell { font-size: clamp(22px, 6vmin, 48px); }
.cell:disabled { opacity: 1; cursor: default; }
.cell:hover:not(:disabled) { background: #fff; }
.cell.x, .cell.o { color: var(--ink); }
.cell.block::after { content: ""; width: 44%; height: 44%; border-radius: 50%; background: var(--stone); border: 2px solid var(--line); }
.cell.hidden-mine { color: var(--muted); }
.cell.hidden-mine::before { content: "은신"; position: absolute; top: 4px; right: 6px; font-size: 10px; color: var(--muted); font-weight: 700; }
.cell.win { background: var(--amber) !important; }
.cell.last::after { content: ""; position: absolute; left: 6px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); border: 1.5px solid var(--line); }
.cell.target { box-shadow: inset 0 0 0 3px var(--amber); cursor: pointer; }
.cell.target:hover { background: var(--amber-soft) !important; }
.cell.dim { opacity: .35; }
.cell.picked { box-shadow: inset 0 0 0 4px var(--ink); }
.cell.drop { box-shadow: inset 0 0 0 3px var(--amber); }
.cell.drop::before { content: "↓"; position: absolute; font-size: 26px; color: var(--amber); font-weight: 900; }

.actionbar { padding: 12px 14px; border-top: 2px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; }
.actionbar .hint { font-size: 13px; color: var(--muted); min-height: 20px; }
.actionbar .hint b { color: var(--ink); }
.actionbar .hint .rulenote { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; background: var(--amber-soft); color: var(--ink); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.aug-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 2px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; min-width: 120px; text-align: left;
  box-shadow: var(--shadow-sm);
}
.aug-btn:hover:not(:disabled) { background: #fff; }
.aug-btn.on { background: var(--amber-soft); }
.aug-btn:disabled { box-shadow: none; }
.aug-btn .n { font-weight: 800; font-size: 14px; }
.aug-btn .s { font-size: 11px; color: var(--amber); font-weight: 700; }
.aug-btn .u { font-size: 11px; color: var(--muted); }
.dirs { display: flex; gap: 6px; }
.dirs .btn { width: 44px; text-align: center; padding: 5px 0; }

.log { font-size: 13px; max-height: 300px; overflow: auto; display: flex; flex-direction: column; }
.log .row { color: var(--muted); padding: 3px 0; border-bottom: 1px dashed var(--line-soft); }
.log .row .r { font-size: 11px; margin-right: 6px; font-family: ui-monospace, Consolas, monospace; }
.log .row:last-child { color: var(--ink); font-weight: 700; }

/* 카드 */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  position: relative; border: 2px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow-sm);
}
.card .top, .draft-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .name { font-weight: 900; font-size: 15px; }
.cat { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--ink); background: var(--surface); font-weight: 700; }
.cat.rule { border-style: dashed; }
.cat.opening { background: var(--surface-2); }
.cat.passive { background: var(--ink); color: var(--surface); }
.card .stars, .draft-card .stars { color: var(--amber); letter-spacing: .08em; font-size: 13px; font-weight: 800; }
.card .stars.zero, .draft-card .stars.zero { color: var(--muted); letter-spacing: 0; }
.card .desc { font-size: 12.5px; color: #3b4442; word-break: keep-all; }
.card.used { opacity: .45; }
.once { font-size: 11px; color: var(--muted); font-weight: 700; }

/* 오버레이 */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(21, 23, 25, .55); padding: 20px;
}
.overlay.light { background: rgba(21, 23, 25, .28); align-items: end; padding-bottom: 40px; }
.modal { width: min(100%, 860px); background: var(--surface); border: 4px solid var(--line); border-radius: 22px; box-shadow: 12px 14px 0 rgba(21, 23, 25, .22); padding: 24px 26px; }
.modal h2 { margin: 0 0 4px; font-size: 24px; font-weight: 900; letter-spacing: -.01em; }
.modal .sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; word-break: keep-all; }
.timer { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line); overflow: hidden; margin: 0 0 16px; }
.timer > i { display: block; height: 100%; background: var(--amber); transition: width .25s linear; }
.draft-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.draft-card {
  border: 2px solid var(--line); background: var(--surface); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; min-height: 190px; text-align: left; box-shadow: var(--shadow-sm);
  transition: transform .08s, box-shadow .08s;
}
.draft-card:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 8px 9px 0 rgba(21, 23, 25, .18); background: #fff; }
.draft-card.picked { background: var(--amber-soft); }
.draft-card .name { font-size: 19px; font-weight: 900; }
.draft-card .desc { color: #3b4442; font-size: 13px; flex: 1; word-break: keep-all; }
.modal .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; color: var(--muted); font-size: 13px; gap: 10px; flex-wrap: wrap; }
.result { text-align: center; }
.result .big { font-size: 34px; font-weight: 900; margin: 6px 0; letter-spacing: -.01em; }
.result .big.d { color: var(--muted); }
.result .why { color: var(--muted); margin-bottom: 18px; }
.result .row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.result hr { border: 0; border-top: 2px solid var(--line-soft); margin: 14px 0; }
.waiting { text-align: center; padding: 30px 10px; color: var(--muted); }
.waiting .code-big { font-family: ui-monospace, Consolas, monospace; font-size: 46px; letter-spacing: .3em; color: var(--ink); font-weight: 900; margin: 10px 0; }
.waiting .link { font-size: 13px; word-break: break-all; }
.pass-screen { text-align: center; padding: 20px; }
.pass-screen .big { font-size: 28px; font-weight: 900; margin-bottom: 14px; }

/* 토스트 */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); border: 2px solid var(--line); border-left: 6px solid var(--danger); padding: 8px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-sm); animation: pop .18s ease-out; }
.toast.info { border-left-color: var(--amber); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 960px) {
  .game { grid-template-columns: 1fr; }
  .side.left { order: 2; } .center { order: 1; } .side.right { order: 3; }
  .modes { grid-template-columns: 1fr; }
  .draft-cards { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
}

/* ── 가위바위보 전용 ── */
.arena { padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.arena .label { font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hands-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.hand {
  border: 2px solid var(--line); background: var(--light-square); border-radius: 14px; padding: 14px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .08s;
}
.hand svg { width: 64px; height: 64px; }
.hand .hn { font-weight: 900; font-size: 15px; }
.hand:hover:not(:disabled) { background: #fff; transform: translate(-1px, -1px); }
.hand.sel { background: var(--amber-soft); box-shadow: inset 0 0 0 3px var(--amber), var(--shadow-sm); }
.hand:disabled { box-shadow: none; }
.hand.big { pointer-events: none; opacity: 1; padding: 18px 10px; }
.hand.big svg { width: 96px; height: 96px; }
.mods { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ban-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.ban-row .btn.sel { background: var(--amber-soft); }
.commit-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.commit-row .btn.primary { font-size: 16px; padding: 10px 26px; }
.commit-row .note { color: var(--muted); font-size: 13px; }
.waitbox { text-align: center; padding: 14px; border: 2px dashed var(--line-soft); border-radius: 12px; color: var(--muted); }
.peekbox { text-align: center; padding: 14px; border: 3px solid var(--amber); border-radius: 12px; background: var(--amber-soft); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 14px; }
.peekbox svg { width: 56px; height: 56px; }
.opp-status { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.opp-status .alert { color: var(--ink); font-weight: 800; }
.reveal { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin: 8px 0 14px; }
.reveal .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reveal .side .who { font-weight: 800; }
.reveal .side .modtag { font-size: 12px; color: var(--muted); }
.reveal .vs { font-weight: 900; font-size: 22px; color: var(--muted); }
.reveal .side.winner .hand { box-shadow: inset 0 0 0 4px var(--amber), var(--shadow-sm); background: var(--amber-soft); }
.notes { text-align: left; font-size: 13px; color: #3b4442; border-top: 2px solid var(--line-soft); padding-top: 10px; margin-top: 4px; }
.notes div { padding: 2px 0; }
.score .dot.w { background: var(--ink); }
@media (max-width: 960px) { .reveal { grid-template-columns: 1fr; } .reveal .vs { text-align: center; } }

@font-face{font-family:LumiGameSans;src:url('Pretendard-Regular.woff2') format('woff2');font-display:swap}body,button,input,select{font-family:LumiGameSans,'Malgun Gothic',sans-serif}

/* 방송 방의 카드 선택에는 제한 시간이 없다. 일반 방 타이머는 유지. */
.broadcast-room .timer { display: none; }
