/* =========================================================================
   그랜드투어 디자인 시스템
   - 색·크기·모서리·그림자는 아래 토큰만 쓴다
   - 패널은 모두 .glass(반투명 유리) 한 가지
   ========================================================================= */
:root {
  --bg: #05070c;
  --surface: rgba(13, 17, 24, 0.74);
  --surface-solid: #111720;
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eaeef3;
  --muted: #8f9bab;
  --faint: #5b6675;
  --accent: #f5c84c;
  --accent-soft: rgba(245, 200, 76, 0.14);
  --accent-ink: #1b1505;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;

  --fs-1: 12px;
  --fs-2: 13.5px;
  --fs-3: 15px;
  --fs-4: 18px;
  --fs-5: 24px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  --blur: blur(16px) saturate(1.35);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans KR', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs-3)/1.5 var(--sans); min-height: 100vh; -webkit-font-smoothing: antialiased; }
body.in-game { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: var(--fs-4); font-weight: 700; letter-spacing: -0.2px; }
h3 { font-size: var(--fs-1); font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-1); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.ic { flex: none; display: block; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text);
}

.glass {
  background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}

/* ---------- 버튼·입력 ---------- */
button, input, select { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--r-sm);
  padding: 8px 14px; font-size: var(--fs-2); font-weight: 500;
  transition: background .15s var(--ease), border-color .15s, transform .08s, opacity .15s;
}
button:hover:not(:disabled) { background: var(--surface-3); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .38; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
button.primary:hover:not(:disabled) { background: #ffd666; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: var(--fs-1); }
button.with-ic { display: inline-flex; align-items: center; gap: 6px; }
button.link { background: none; border: 0; padding: 2px 4px; color: var(--muted); font-size: var(--fs-1); text-decoration: underline; }
.ibtn {
  width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 10px;
  background: transparent; border-color: transparent; color: var(--muted); position: relative;
}
.ibtn:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.ibtn.on { color: var(--accent); background: var(--accent-soft); }
.badge-dot {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--bad); color: #fff; font-size: 10px; font-style: normal; font-weight: 700; line-height: 16px;
}
input[type=text] {
  width: 100%; background: rgba(0,0,0,.35); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: var(--fs-3);
}
input[type=text]:focus { outline: none; border-color: var(--accent); }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: rgba(0,0,0,.3); border-radius: 10px; border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 6px 12px; font-size: var(--fs-2); color: var(--muted); }
.seg button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.badge { font-size: var(--fs-1); padding: 1px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.gold { color: var(--accent); border-color: rgba(245,200,76,.35); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.off { background: var(--faint); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; }

/* =========================================================================
   홈·로비
   ========================================================================= */
body:not(.in-game) {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 33% 72%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 64%, rgba(200,220,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 35%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 88%, rgba(255,230,200,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 48%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 30%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(ellipse 60% 50% at 80% 10%, rgba(88,60,160,.25), transparent 70%),
    radial-gradient(ellipse 50% 45% at 10% 90%, rgba(20,110,140,.18), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.center { max-width: 460px; margin: 0 auto; padding: 56px 16px 40px; }
.logo { font-size: 56px; font-weight: 700; letter-spacing: -2px; line-height: 1.1; text-shadow: 0 0 40px rgba(245,200,76,.25); }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin: 8px 0 28px; }
.card {
  background: rgba(16, 21, 29, .82); backdrop-filter: var(--blur); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px;
}
.card + .card { margin-top: 12px; }
.card h3 { margin-bottom: 12px; }
.tut-card { border-color: rgba(245,200,76,.3); }
.code-big { font-family: var(--mono); font-size: 40px; letter-spacing: 8px; color: var(--accent); }
.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.members li:last-child { border-bottom: 0; }
.rules-mini { font-size: var(--fs-2); color: var(--muted); padding-left: 18px; margin: 0; }
.rules-mini li { margin: 3px 0; }

/* =========================================================================
   게임 화면 틀
   ========================================================================= */
.gs { --right: 262px; }
.gs.drawer-open { --right: 612px; }

/* 3D 캔버스 / 2D 보드 */
.gs3d .stage { position: fixed; inset: 0; z-index: 0; }
.stage-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 45% 45%, transparent 55%, rgba(0,0,0,.55) 100%); }
.loading3d {
  position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  color: var(--muted); background: radial-gradient(ellipse at center, #0b1020 0%, var(--bg) 70%);
}
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 위: 주식 시세판 ---------- */
.ticker {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 10px 0 16px; border-radius: 0; border-width: 0 0 1px; box-shadow: none;
}
.brand { font-weight: 700; font-size: var(--fs-4); letter-spacing: -0.5px; flex: none; }
.brand span { color: var(--accent); }
.tk-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.pool { font-size: var(--fs-1); color: var(--muted); margin-right: 6px; white-space: nowrap; }
.pool b { color: var(--text); font-size: var(--fs-2); }

/* ---------- 가운데 위: 차례 표시 ---------- */
.turnbar {
  position: fixed; top: 68px; left: calc((100vw - var(--right)) / 2); transform: translateX(-50%); z-index: 9;
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: var(--r-pill); max-width: calc(100vw - var(--right) - 32px);
  transition: border-color .3s, box-shadow .3s;
}
.turnbar.mine { border-color: rgba(245,200,76,.55); box-shadow: var(--shadow), 0 0 30px rgba(245,200,76,.18); }
.tb-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tb-text b { font-size: var(--fs-3); }
.turnbar.mine .tb-text b { color: var(--accent); }
.tb-text span { font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.tb-text em { font-style: normal; color: var(--warn); }
.turn-timer { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); margin-left: 6px; }
.tt-bar { width: 72px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; }
.tt-bar i { display: block; height: 100%; background: var(--accent); transition: width .25s linear; }
.tt-sec { font-size: var(--fs-1); min-width: 30px; text-align: right; }
.turn-timer.urgent { color: var(--bad); }
.turn-timer.urgent .tt-bar i { background: var(--bad); }
.turn-timer.urgent .tt-sec { animation: pulse .8s infinite; }

/* ---------- 오른쪽: 플레이어 알약 ---------- */
.pills { position: fixed; top: 68px; right: calc(var(--right) - 246px); width: 230px; z-index: 8; display: flex; flex-direction: column; gap: 6px; transition: right .25s var(--ease); }
.pill { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 14px; box-shadow: none; transition: border-color .2s, background .2s; }
.pill.acting { border-color: rgba(245,200,76,.6); background: rgba(40,32,10,.78); }
.pill-main { flex: 1; min-width: 0; }
.pill-top { display: flex; align-items: baseline; gap: 8px; }
.pill-name { font-size: var(--fs-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.pill-name em { font-style: normal; font-size: 11px; color: var(--accent); }
.pill-cash { font-size: var(--fs-2); font-weight: 600; }
.pill-shares { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.pill-sub { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.pill-sub.warn { color: var(--warn); }
.sq {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 5px; background: var(--c); color: #fff; font: 600 11px var(--mono); text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.sq.wide { font-family: var(--sans); padding: 0 7px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  font-weight: 700; font-size: var(--fs-2); color: #0b0f14; background: var(--ac); box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
}
.avatar::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--good); border: 2px solid var(--surface-solid); }
.avatar.ai { background: #cbd5e1; }
.avatar.ai::after, .avatar.sm::after { display: none; }
.avatar.off { filter: grayscale(1) brightness(.7); }
.avatar.off::after { background: var(--faint); }
.avatar.sm { width: 22px; height: 22px; }

/* ---------- 오른쪽: 채팅·기록 서랍 ---------- */
.drawer {
  position: fixed; top: 68px; bottom: 16px; right: 16px; width: 334px; z-index: 8; display: flex; flex-direction: column;
  padding: 10px 12px 12px;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }
.tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.tabs > button:not(.ibtn) { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.tabs > button.on { color: var(--text); background: var(--surface-3); }
.tabs .ibtn { width: 30px; height: 30px; }
.drawer .chatbox { flex: 1; display: flex; flex-direction: column; min-height: 0; background: none; border: 0; padding: 0; }
.drawer .chatbox h3 { display: none; }
.chat-log { flex: 1; min-height: 120px; overflow-y: auto; font-size: var(--fs-2); display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
.chat-log .msg { line-height: 1.45; word-break: break-word; }
.chat-log .msg b { color: var(--accent); font-weight: 600; margin-right: 2px; }
.emoji-bar { display: flex; gap: 2px; margin: 8px 0 6px; flex-wrap: wrap; }
.emoji-bar .emoji { padding: 3px 6px; font-size: 17px; background: transparent; border-color: transparent; line-height: 1.2; }
.emoji-bar .emoji:hover { background: var(--surface-3); transform: scale(1.12); }
.chat-form { display: flex; gap: 6px; }
.chat-form input { padding: 7px 10px; font-size: var(--fs-2); }
.log { flex: 1; overflow-y: auto; font-size: var(--fs-2); display: flex; flex-direction: column-reverse; }
.log div { padding: 4px 0; border-bottom: 1px solid var(--line); color: #cfd6df; }
.log .big { color: var(--accent); }
.log .money { color: var(--good); }

/* ---------- 설정 메뉴 ---------- */
.menu {
  position: fixed; top: 62px; right: 12px; z-index: 30; width: 300px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(15, 20, 28, .96);
}
.menu-title { font-size: 11px; color: var(--muted); letter-spacing: .05em; margin: 4px 2px 0; }
.menu .seg { width: 100%; }
.menu .seg button { flex: 1; padding: 6px 6px; font-size: var(--fs-1); }
.menu-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 8px; text-align: left; border-radius: 8px; color: var(--text); }
.menu-row:hover { background: var(--surface-3); }
.menu-row .ic { color: var(--muted); }
.sw-track { width: 34px; height: 20px; border-radius: 10px; background: var(--surface-3); position: relative; flex: none; transition: background .2s; }
.sw-track i { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #cbd5e1; transition: transform .2s var(--ease); }
.switch.on .sw-track { background: var(--accent); }
.switch.on .sw-track i { transform: translateX(14px); background: var(--accent-ink); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu-keys { font-size: 11px; color: var(--muted); line-height: 2; padding: 0 2px; }
.menu-foot { font-size: 11px; color: var(--faint); padding: 0 2px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- 아래: 행동 시트 + 타일 받침대 ---------- */
.bottom {
  position: fixed; bottom: 14px; left: 16px; right: var(--right); z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }

.sheet { width: min(640px, 100%); padding: 16px 18px; max-height: calc(100vh - 330px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.sheet-head h2 { margin-bottom: 2px; }
.sheet-head p { font-size: var(--fs-2); color: var(--muted); }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-2); color: var(--muted); }
.sheet-foot b { color: var(--text); }
.plus { color: var(--good) !important; }
.minus { color: #fca5a5 !important; }


/* 자리 비움 */
.away-box { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35); color: var(--warn); }
.away-box b { display: block; color: var(--text); }
.away-box small { color: var(--muted); }

/* 결과 */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-top: 12px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; }
.pod b { font-size: var(--fs-2); }
.pod .mono { font-size: var(--fs-2); color: var(--muted); }
.pod .step { display: grid; place-items: center; width: 100%; border-radius: 10px 10px 0 0; background: var(--surface-3); font: 700 var(--fs-4) var(--mono); font-style: normal; color: var(--muted); }
.pod.p1 .step { height: 70px; background: linear-gradient(180deg, rgba(245,200,76,.35), rgba(245,200,76,.08)); color: var(--accent); }
.pod.p2 .step { height: 48px; }
.pod.p3 .step { height: 32px; }
.pod.win .mono { color: var(--accent); font-weight: 700; }
.result .rest { margin: 6px 0 0; padding-left: 24px; font-size: var(--fs-2); }
.result .rest li { display: flex; justify-content: space-between; }

/* ---------- 튜토리얼 ---------- */
.tut {
  position: fixed; top: 124px; left: calc((100vw - var(--right)) / 2); transform: translateX(-50%); z-index: 20; width: min(500px, calc(100vw - 32px));
  padding: 14px 18px 16px; border-color: rgba(245,200,76,.45); background: rgba(26, 22, 12, .92);
  box-shadow: var(--shadow), 0 0 40px rgba(245,200,76,.12);
}
.tut-head { display: flex; align-items: center; gap: 10px; }
.tut-step { font-size: 11px; color: var(--accent); }
.tut-prog { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.tut-prog i { display: block; height: 100%; background: var(--accent); transition: width .3s var(--ease); }
.tut h2 { color: var(--accent); margin: 8px 0 4px; }
.tut p { font-size: var(--fs-2); line-height: 1.65; color: #ece4d0; }
.tut .tut-do { margin-top: 8px; color: #fff; }
.tut .tut-do b { color: var(--accent); font-family: var(--mono); }
.tut-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- 주가표 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(2,4,10,.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.modal-card { width: min(820px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 20px; background: rgba(15,20,28,.97); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-2); }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); font-size: var(--fs-1); vertical-align: bottom; }
td { padding: 6px; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-family: var(--mono); }
.modal-card .small { margin-top: 12px; }

/* ---------- 알림 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 200px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 50;
  background: #3b1f22; border: 1px solid #6b2c31; color: #ffd9dc; padding: 10px 16px; border-radius: var(--r-md);
  transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); font-size: var(--fs-2); box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.info { background: #16303a; border-color: #23566a; color: #d6f1fb; }
#banner {
  position: fixed; left: calc((100vw - 262px) / 2); top: 26vh; transform: translate(-50%, -10px); z-index: 30; pointer-events: none; text-align: center; opacity: 0;
  padding: 18px 44px 16px; border-radius: var(--r-lg); background: rgba(12,16,24,.9); backdrop-filter: var(--blur);
  border: 1px solid color-mix(in srgb, var(--bc, #f5c84c) 55%, transparent);
  box-shadow: var(--shadow), 0 0 60px color-mix(in srgb, var(--bc, #f5c84c) 30%, transparent); max-width: calc(100vw - 32px);
}
#banner.show { animation: bannerIn 1.85s cubic-bezier(.2,.9,.3,1.2) forwards; }
#banner .b-title { font-size: 34px; font-weight: 700; letter-spacing: -.5px; color: var(--bc, #f5c84c); line-height: 1.15; }
#banner .b-sub { font-size: var(--fs-3); color: #d7dee6; margin-top: 4px; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.92); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(.98); }
}
#tip {
  position: fixed; left: 0; top: 0; z-index: 25; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(10,14,20,.94); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px 10px;
  font-size: var(--fs-2); display: flex; flex-direction: column; min-width: 120px; box-shadow: var(--shadow);
}
#tip.show { opacity: 1; }
#tip span { color: var(--muted); font-size: var(--fs-1); }
.float-emoji { position: fixed; z-index: 35; font-size: 34px; pointer-events: none; transform: translate(-50%, 0); animation: emojiUp 1.5s ease-out forwards; filter: drop-shadow(0 4px 8px rgba(0,0,0,.5)); }
@keyframes emojiUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1); }
}
.float-money { position: fixed; z-index: 35; pointer-events: none; font: 700 var(--fs-3) var(--mono); transform: translate(-100%, 0); animation: moneyUp 1.6s ease-out forwards; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.float-money.up { color: var(--good); }
.float-money.down { color: #fca5a5; }
@keyframes moneyUp {
  0% { opacity: 0; transform: translate(-100%, 6px); }
  15% { opacity: 1; transform: translate(-100%, -4px); }
  100% { opacity: 0; transform: translate(-100%, -40px); }
}

/* =========================================================================
   좁은 화면(폰·작은 태블릿): 위에서 아래로 쌓기
   ========================================================================= */
@media (max-width: 900px) {
  body.in-game { overflow: auto; }
  .gs { --right: 0px; display: flex; flex-direction: column; min-height: 100vh; }
  .ticker { position: sticky; order: -3; height: auto; padding: 8px 10px; flex-wrap: wrap; }
  .tk-list { order: 3; flex-basis: 100%; }
  .tk { min-width: 86px; }
  .tk-tools { margin-left: auto; }
  .turnbar { position: static; order: -2; transform: none; margin: 8px 10px 0; align-self: center; max-width: calc(100vw - 20px); }
  .gs3d .stage { position: relative; height: 52vh; order: -1; }
  .vignette { display: none; }
  .sheet { max-height: none; }
  .pills { position: static; order: 1; width: auto; margin: 10px; flex-direction: row; flex-wrap: wrap; }
  .pill { flex: 1 1 200px; }
  .drawer { position: static; order: 2; width: auto; margin: 0 10px 10px; height: 360px; }
  .menu { position: fixed; top: 56px; right: 8px; left: 8px; width: auto; }
  .tut { position: sticky; top: 8px; left: auto; transform: none; margin: 10px auto; order: -1; }
  #banner { left: 50%; }
  #toast { bottom: 24px; }
}


/* 등장 애니메이션은 새로 열릴 때만 */
.sheet.enter { animation: rise .25s var(--ease); }
.drawer.enter { animation: slideIn .25s var(--ease); }
.menu.enter { animation: fadeIn .15s var(--ease); }
.tut.enter { animation: tutIn .25s var(--ease); }
@keyframes tutIn { from { opacity: 0; transform: translate(-50%, -6px); } }
/* 넓은 화면: 튜토리얼 카드는 보드를 가리지 않게 왼쪽에 */
@media (min-width: 1200px) {
  .tut { left: 16px; top: 124px; transform: none; width: 340px; }
  .tut.enter { animation: fadeIn .25s var(--ease); }
}
@media (min-width: 1200px) {
  .gs.tut-on .board-wrap, .gs.tut-on .bottom { left: 372px; }
}

/* ---------- 공통 보조 ---------- */
.avatar { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.3); }
.avatar.ai { color: #1b2430; text-shadow: none; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; background: rgba(74,222,128,.15); color: var(--good); }
.sizebar { position: relative; height: 4px; background: rgba(255,255,255,.08); border-radius: 2px; }
.sizebar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--c); }
.sizebar b { position: absolute; top: -2px; width: 2px; height: 8px; background: rgba(255,255,255,.5); }

/* ---------- 로비: AI·하우스 룰 ---------- */
.add-ai { margin-top: 12px; gap: 6px; color: var(--muted); }
button.level { color: var(--accent); border-color: rgba(245,200,76,.35); background: var(--accent-soft); }
details.house { border-top: 1px solid var(--line); padding-top: 10px; }
details.house summary { cursor: pointer; font-size: var(--fs-2); color: var(--muted); display: flex; gap: 8px; align-items: center; list-style: none; }
details.house summary::before { content: '▸'; transition: transform .15s; }
details.house[open] summary::before { transform: rotate(90deg); }
.rule-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: var(--fs-2); flex-wrap: wrap; }
.rule-row .seg button { padding: 4px 9px; font-size: var(--fs-1); }


/* ---------- 결과: 그래프·통계 ---------- */
.chart-box { margin-top: 8px; }
.chart-head { display: flex; align-items: baseline; gap: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-1); color: var(--muted); margin: 6px 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw, .stats .sw, .chart-tip .sw { border-radius: 50%; width: 9px; height: 9px; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.chart .axis { fill: var(--faint); font: 11px var(--mono); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end { stroke: var(--surface-solid); stroke-width: 2; }
.chart .lbl { fill: var(--muted); font: 600 11px var(--sans); }
.chart .cross { stroke: rgba(255,255,255,.35); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; top: 4px; z-index: 2; min-width: 160px; padding: 8px 10px; border-radius: var(--r-sm); pointer-events: none; opacity: 0;
  background: rgba(10,14,20,.96); border: 1px solid var(--line-strong); font-size: var(--fs-1); box-shadow: var(--shadow); transition: opacity .1s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 500; }
.chart-tip div { display: flex; align-items: center; gap: 6px; }
.stats { margin-top: 8px; }
.highlight { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-2); margin-bottom: 8px; }
.highlight span { color: var(--text); }
.stats-table td { white-space: nowrap; }

/* ---------- 홈·로비 배경 3D ---------- */
.home-stage { position: fixed; inset: 0; z-index: 0; }
.home-shade { position: fixed; inset: 0; z-index: 1; pointer-events: none; display: none;
  background: radial-gradient(ellipse 50% 70% at 50% 50%, rgba(5,7,12,.72), rgba(5,7,12,.25) 70%, rgba(5,7,12,.55)); }
body.home-3d .home-shade { display: block; }
body.home-3d .center { position: relative; z-index: 2; }

/* ---------- 폰: 회사 목록·아래 탭 ---------- */
.market, .mtabs { display: none; }
@media (max-width: 900px) {
  .gs { padding-bottom: 72px; }
  .tk-list { display: none; }
  .market { display: flex; flex-direction: column; gap: 10px; margin: 10px; padding: 14px; order: 1; }
  .mk { padding: 8px 0 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
  .mk:last-child { border-bottom: 0; }
  .mk.off { opacity: .45; }
  .mk-top { display: flex; align-items: center; gap: 8px; }
  .mk-top b:first-child { border-left: 3px solid var(--c); padding-left: 8px; }
  .mk-meta { font-size: var(--fs-1); color: var(--muted); }
  .mk-meta b { color: var(--accent); }
  .mtabs {
    display: flex; position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 20; padding: 4px; border-radius: 18px; gap: 2px;
  }
  .mtabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: transparent;
    color: var(--muted); font-size: 11px; border-radius: 14px; position: relative; }
  .mtabs button.on { color: var(--accent); background: var(--accent-soft); }
  .mtabs .badge-dot { top: 2px; right: calc(50% - 22px); }
  /* 탭마다 보이는 것 */
  .gs:not([data-mtab="board"]) :is(.stage, .board-wrap, .bottom, .turnbar, .tut) { display: none; }
  .gs:not([data-mtab="market"]) .market { display: none; }
  .gs:not([data-mtab="players"]) .pills { display: none; }
  .gs:not([data-mtab="chat"]) .drawer { display: none; }
  .gs[data-mtab="chat"] .drawer { height: calc(100vh - 150px); }
  .pills { flex-direction: column; }
  #announce { left: 50%; top: 64px; }
}
/* 결과 화면은 받침대가 없으니 더 높게 */
.gs .sheet:has(.result) { max-height: calc(100vh - 150px); }
