/* Generic base styles for hub-game-template. Dark, mobile-first, safe-area aware.
   Restyle freely for your game. Class names are referenced by app.js + game-ui.js. */
:root {
  --bg: #141a24; --panel: #1e2733; --panel2: #18212d; --line: #2c3848;
  --fg: #eef2f7; --muted: #aeb8c6; --accent: #2f6bff; --danger: #d64545;
  --x: #4fa3ff; --o: #ffb454; --win: #2e7d4f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--fg);
  font-family: 'Apple SD Gothic Neo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no double-tap zoom */
}
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#app { max-width: 560px; margin: 0 auto; padding: 16px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* ── buttons / inputs ── */
.btn { display: block; width: 100%; padding: 14px; margin-top: 10px; border: 0; border-radius: 12px;
  background: #28323f; color: #dbe3ee; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; margin: 0; }
.btn.disabled { opacity: .5; cursor: not-allowed; }
.in { width: 100%; padding: 13px; margin-top: 6px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--fg); font-size: 15px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-top: 12px; }

/* ── cards / layout ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-top: 14px; }
.card.err, .card .err { color: #ff9a9a; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row .btn { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.sep { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 4px; position: relative; }

/* ── home ── */
.home { padding-top: 10px; }
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 14px 0 4px; }
.brand-ic { width: 44px; height: 44px; border-radius: 12px; }
.brand h1 { font-size: 24px; margin: 0; }
.who { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }
.link { color: var(--x); margin-left: 10px; text-decoration: underline; }

/* ── room ── */
.roombar { display: flex; align-items: center; justify-content: space-between; }
.code { font-size: 15px; color: var(--muted); }
.code b { color: var(--fg); font-size: 20px; letter-spacing: 2px; margin-left: 4px; }
.players { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pl { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.pl.off { opacity: .45; }
.pl .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ecf6b; }
.pl.off .dot { background: #6b7480; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #34425a; color: #cdd9ee; }
.tag.host { background: #5a4a1e; color: #ffe39c; }
.mini { border: 0; background: #2a3340; color: #cdd6e2; border-radius: 8px; padding: 2px 7px; font-size: 12px; cursor: pointer; }
.mini.danger { background: #4a2330; color: #ffb3c0; }

/* ── lobby seats (tic-tac-toe example) ── */
.seats { display: flex; gap: 12px; margin: 14px 0; }
.seat { flex: 1; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 18px 8px;
  cursor: pointer; color: var(--fg); }
.seat.mine { border-color: var(--accent); }
.seat.taken { opacity: .85; }
.seat-mark { font-size: 34px; font-weight: 800; }
.seat-by { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ── board (tic-tac-toe example) ── */
.status { text-align: center; font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.status.big { font-size: 20px; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; aspect-ratio: 1; max-width: 360px; margin: 0 auto; }
.cell { font-size: 13vw; max-font-size: 64px; font-weight: 800; border: 0; border-radius: 12px;
  background: var(--panel2); color: var(--fg); cursor: default; display: flex; align-items: center; justify-content: center; }
@media (min-width: 420px) { .cell { font-size: 56px; } }
.cell.f-X { color: var(--x); } .cell.f-O { color: var(--o); }
.cell.live { cursor: pointer; outline: 1px dashed #3a485c; }
.cell.live:active { background: #222d3a; }
.cell.win { background: var(--win); color: #fff; }

/* ── toasts ── */
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px); z-index: 9500;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #28323f; color: #eef2f7; padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 1; transition: opacity .3s; max-width: 90vw; }
.toast.out { opacity: 0; }
.toast.error { background: #4a2330; color: #ffc4cd; }
.toast.success { background: #1f4a30; color: #b8f0cc; }

/* ── roombar actions ── */
.roombar-actions { display: flex; gap: 6px; }

/* ── match history (전적) modal — used by public/history.js ── */
.hub-overlay { position: fixed; inset: 0; z-index: 9700; background: rgba(8,12,18,.66);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.hub-modal { width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; }
.hub-modal-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; }
.hub-modal-head strong { font-size: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat-val { font-size: 20px; font-weight: 800; }
.stat-val.good { color: #5fd38a; } .stat-val.accent { color: var(--x); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.split-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.split-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.split-title { font-size: 13px; font-weight: 700; }
.split-rate { font-size: 22px; font-weight: 800; color: var(--x); }
.hub-filter { display: flex; gap: 6px; }
.hist-list { display: flex; flex-direction: column; gap: 6px; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel2); border: 1px solid var(--line); border-left-width: 3px; border-radius: 10px; padding: 8px 10px; }
.hist-row.won { border-left-color: #3ecf6b; } .hist-row.lost { border-left-color: var(--danger); }
.hist-left { display: flex; align-items: center; gap: 8px; }
.hist-badge { font-size: 12px; font-weight: 800; width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.hist-badge.good { background: #1f4a30; color: #b8f0cc; } .hist-badge.bad { background: #4a2330; color: #ffc4cd; }
.tag-ai { background: #3a2e10; color: #ffe39c; } .tag-human { background: #16324a; color: #bfe0ff; }

/* ── reward / session-expired modal (public/reward-modal.js) ── */
.reward-modal { max-width: 360px; align-items: center; text-align: center; gap: 10px; }
.reward-emoji { font-size: 48px; }
.reward-title { font-size: 19px; }
.reward-amount { font-size: 34px; font-weight: 800; color: #ffd86b; }
.reward-cur { font-size: 18px; color: var(--muted); font-weight: 700; }
.reward-modal .btn { width: 100%; }

/* ── locked / read-only field (public/locked-field.js) ──
   A value that is FIXED on the client (SSO account name, hub-registered slug).
   Styled to read as "잠김": dashed + dimmed box (clearly not an editable input), a
   persistent lock icon, and a visible help line. Reuses the .in input shape + tokens. */
.lf-wrap { position: relative; }
.in.locked {
  background: #161d27; color: var(--muted);
  border-style: dashed; cursor: not-allowed; padding-right: 40px;
  -webkit-user-select: text; user-select: text;       /* still copyable */
}
.in.locked:focus { outline: none; border-color: var(--muted); }
.lf-lock {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; line-height: 1; opacity: .85; pointer-events: none;
}
.lf-help { display: flex; align-items: flex-start; gap: 5px; margin-top: 6px; }
.lf-help-ic { flex: none; line-height: 1.5; }

/* ── version tag ── */
#verTag { position: fixed; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 6px); font-size: 11px; color: #4a5663; }

/* ══════════════════════════════════════════════════════════════════════════ */
/*  Janggi (장기)                                                               */
/* ══════════════════════════════════════════════════════════════════════════ */
:root { --cho: #2f6bff; --han: #e0483d; --wood: #e9c178; --wood2: #e3b766; --woodline: #6b4a25; }
.jg-h2 { margin: 0 0 10px; font-size: 18px; }
.jg-card { padding: 14px; }

/* lobby: mode toggle */
.jg-mode { display: flex; gap: 8px; margin: 6px 0 4px; }
.jg-modebtn { flex: 1; padding: 11px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.jg-modebtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.jg-modebtn.lock { opacity: .65; cursor: default; }

/* lobby: seats */
.jg-seats { display: flex; gap: 10px; margin: 12px 0; }
.jg-seat { flex: 1; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 14px 8px; cursor: pointer; color: var(--fg); text-align: center; }
.jg-seat.jg-cho.mine { border-color: var(--cho); }
.jg-seat.jg-han.mine { border-color: var(--han); }
.jg-seat-mark { font-size: 30px; font-weight: 900; }
.jg-seat.jg-cho .jg-seat-mark { color: var(--cho); }
.jg-seat.jg-han .jg-seat-mark { color: var(--han); }
.jg-seat-name { font-size: 12px; color: var(--muted); margin-top: 4px; }
.jg-seat-by { font-size: 13px; margin-top: 6px; font-weight: 700; }

/* lobby: 차림 */
.jg-charim { display: flex; gap: 10px; margin: 6px 0 12px; }
.jg-charim-card { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.jg-charim-title { font-size: 13px; font-weight: 800; margin-bottom: 8px; text-align: center; }
.jg-wing { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.jg-wing-ko { width: 18px; font-size: 12px; color: var(--muted); }
.jg-wing-opt { flex: 1; padding: 6px 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; cursor: pointer; }
.jg-wing-opt.on { background: #34425a; color: #fff; border-color: #4a6088; }
.jg-wing-opt.lock { opacity: .6; cursor: default; }

/* game: status */
.jg-status { text-align: center; font-size: 16px; font-weight: 800; margin-bottom: 12px; min-height: 22px; }
.jg-status.check { color: #ffcf4d; }
.jg-status.over { color: #7fe0a0; font-size: 18px; }

/* game: board */
.jg-board { position: relative; width: min(94vw, 440px); aspect-ratio: 8 / 9; margin: 0 auto;
  background: radial-gradient(circle at 50% 40%, var(--wood) 0%, var(--wood2) 100%);
  border: 3px solid var(--woodline); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  container-type: inline-size; /* piece sizes (cqw) scale with the board at ANY size */ }
.jg-gridwrap, .jg-points { position: absolute; inset: 7%; }
.jg-grid { width: 100%; height: 100%; display: block; overflow: visible; }
.jg-lines line, .jg-diag line { stroke: var(--woodline); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.jg-diag line { stroke-width: 1.2; opacity: .85; }

.jg-points { pointer-events: none; }
/* size in cqw (% of board width) so pieces stay ~1 cell on small AND fullscreen boards */
.jg-pt { position: absolute; width: 11cqw; height: 11cqw; transform: translate(-50%, -50%);
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; }
.jg-pc { width: 86%; height: 86%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 7cqw; line-height: 1; user-select: none;
  background: radial-gradient(circle at 38% 32%, #fff7e8 0%, #f3deb0 70%, #e6c98a 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,.35), inset 0 0 0 2px rgba(0,0,0,.06); }
.jg-pc.jg-cho { color: var(--cho); box-shadow: 0 2px 4px rgba(0,0,0,.35), inset 0 0 0 2.5px var(--cho); }
.jg-pc.jg-han { color: var(--han); box-shadow: 0 2px 4px rgba(0,0,0,.35), inset 0 0 0 2.5px var(--han); }
.jg-pc.live { cursor: pointer; }
.jg-pc.sel { outline: 3px solid #2ad17a; outline-offset: 1px; box-shadow: 0 0 12px rgba(42,209,122,.8), inset 0 0 0 2.5px currentColor; }
.jg-pt.last::after { content: ''; position: absolute; inset: 8%; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(80,50,10,.55); }
.jg-pt.target .jg-pc { outline: 3px dashed #2ad17a; outline-offset: 1px; } /* capturable */
.jg-dot { width: 30%; height: 30%; border-radius: 50%; background: rgba(42,160,90,.85); box-shadow: 0 0 6px rgba(42,209,122,.7); }

/* game: controls */
.jg-ctrls { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.jg-ctrls .btn { margin: 0; }
.jg-resign { color: #ffb3b3; border-color: #5a3340; }

/* ── local 2P (pass-and-play): board as large as the viewport allows ── */
.jg-localmode #app { max-width: none; padding: 4px env(safe-area-inset-right) calc(4px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
.jg-localcard { background: transparent; border: 0; padding: 2px; margin-top: 2px; }
.jg-localmode .jg-status { margin-bottom: 6px; }
.jg-localmode .jg-ctrls { margin-top: 8px; }
/* maximize within BOTH width and height (board is 8:9). dvh handles mobile URL bar. */
.jg-board.jg-big { width: min(96vw, calc((100vh - 110px) * 8 / 9)); }
.jg-board.jg-big { width: min(96vw, calc((100dvh - 110px) * 8 / 9)); }
