/* 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: seat (color) picker ── */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { margin: 0; font-size: 18px; }
.seats { display: flex; gap: 12px; margin: 14px 0; }
.seat { flex: 1; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 16px 8px;
  cursor: pointer; color: var(--fg); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.seat.mine { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,107,255,.2); }
.seat.taken { opacity: .92; }
.seat.bot { border-style: dashed; }
.seat-stone { width: 38px; height: 38px; border-radius: 50%; }
.stn-B { background: radial-gradient(circle at 34% 30%, #6b6b6b, #0a0a0a 72%); }
.stn-W { background: radial-gradient(circle at 34% 30%, #ffffff, #cfcfcf 78%); box-shadow: inset 0 0 0 1px #9a9a9a; }
.seat-mark { font-size: 17px; font-weight: 800; }
.seat-by { font-size: 12.5px; color: var(--muted); }

/* ── lobby: host options (toggles) ── */
.opts { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 2px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.opt-label { font-size: 14px; font-weight: 700; }
.opt-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { flex: none; width: 46px; height: 27px; border-radius: 999px; border: 0; background: #36404e; position: relative; cursor: pointer; padding: 0; transition: background .15s; }
.switch.on { background: var(--accent); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on .knob { left: 22px; }
.switch.ro { cursor: default; opacity: .8; }

/* ── goban (오목판) ── */
.status { text-align: center; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.status.big { font-size: 21px; }
.board-card { padding: 14px; }
.goban { width: min(94vw, 520px); aspect-ratio: 1; margin: 0 auto; box-sizing: border-box;
  background: linear-gradient(160deg, #eccd8a, #e0b86f); border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(70,46,16,.45), 0 10px 28px rgba(0,0,0,.45); padding: 0; touch-action: manipulation; }
.grid { display: grid; width: 100%; height: 100%; }
.pt { position: relative; background: transparent; border: 0; padding: 0; aspect-ratio: 1; cursor: default; -webkit-tap-highlight-color: transparent; }
.pt::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1.4px; transform: translateX(-50%); background: rgba(70,46,16,.6); }
.pt::after  { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1.4px; transform: translateY(-50%); background: rgba(70,46,16,.6); }
.pt.edge-t::before { top: 50%; } .pt.edge-b::before { bottom: 50%; }
.pt.edge-l::after  { left: 50%; } .pt.edge-r::after  { right: 50%; }
.pt.hoshi { background: radial-gradient(circle at 50% 50%, rgba(70,46,16,.85) 0 3.2px, transparent 3.4px); }
.pt.live { cursor: pointer; }
.pt.live:active { background: radial-gradient(circle at 50% 50%, rgba(47,107,255,.35) 0 42%, transparent 46%); border-radius: 50%; }
.stone { position: absolute; inset: 9%; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.45); }
.stone.stn-B { background: radial-gradient(circle at 34% 30%, #6b6b6b, #060606 72%); }
.stone.stn-W { background: radial-gradient(circle at 34% 30%, #ffffff, #c9c9c9 78%); box-shadow: 0 1px 2px rgba(0,0,0,.4), inset 0 0 0 1px #9a9a9a; }
.stone.last::after { content: ''; position: absolute; inset: 36%; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 2px rgba(0,0,0,.4); }
.stone.win { box-shadow: 0 0 0 3px #ffd24a, 0 0 12px 2px rgba(255,210,74,.8); }
.forbid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #d11f1f; font-weight: 900; font-size: min(3vw, 17px); line-height: 1; pointer-events: none; }

/* ── game meta row ── */
.gmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.gtag { font-size: 12px; color: var(--muted); background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.gtag.on { background: #2a3550; color: #bcd2ff; border-color: #36507e; }
.gmeta .btn.sm { margin-left: auto; }

/* ── rulebook ── */
.rule-sec { border-top: 1px solid var(--line); padding-top: 10px; }
.rule-sec h4 { margin: 0 0 4px; font-size: 14px; }
.rule-sec .hint { margin: 0; }

/* ── 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). Reads as "잠김": dashed +
   dimmed box (clearly not editable), a persistent lock icon, and a visible help line. */
.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; }

/* ── local 2P (pass-and-play): board fills the screen ── */
body.mode-local #app { max-width: 100%; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.local-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.goban.fill { width: min(98vw, calc(100vh - 140px)); width: min(98vw, calc(100dvh - 140px)); }
.local-bar { width: min(98vw, 560px); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px; }
.turn-ind { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 800; }
.turn-ind .stone-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.stone-dot.stn-B { background: radial-gradient(circle at 34% 30%, #6b6b6b, #060606 72%); }
.stone-dot.stn-W { background: radial-gradient(circle at 34% 30%, #fff, #c9c9c9 78%); box-shadow: 0 1px 2px rgba(0,0,0,.4), inset 0 0 0 1px #9a9a9a; }
.local-meta { display: flex; gap: 6px; align-items: center; }
.local-controls { width: min(98vw, 560px); display: flex; gap: 8px; }
.local-controls .btn { margin-top: 0; flex: 1; width: auto; }
.local-controls .btn.ghost { flex: 0 0 auto; }

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