/* 탄소마블 프로토타입 — 캐주얼 보드게임 룩 (v2) */
:root {
  --sky-1: #8ED9F0;
  --sky-2: #CDEFDC;
  --felt-1: #1F9066;
  --felt-2: #0D5C40;
  --frame: #D9B45C;
  --frame-dark: #A8823B;
  --tile: #FFFFFF;
  --tile-2: #F1F6F1;
  --tile-edge: #C7D8CB;
  --ink: #1E3328;
  --ink-2: #57705F;
  --ink-3: #8AA192;
  --green: #189A5C;
  --green-dark: #0E7A46;
  --green-deep: #0B5E3F;
  --gold: #F5C542;
  --gold-dark: #C9992B;
  --bad: #E24B3B;
  --good: #1D8348;
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --sh: 0 12px 28px rgba(20, 60, 40, .22), 0 3px 8px rgba(20, 60, 40, .12);
  --sh-sm: 0 3px 8px rgba(20, 60, 40, .15);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 380px at 15% -5%, rgba(255, 255, 255, .55) 0%, transparent 60%),
    radial-gradient(700px 300px at 90% 8%, rgba(255, 255, 255, .35) 0%, transparent 55%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 58%, #ABE0BC 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
b, strong { font-weight: 800; }
small { font-size: .68em; }

/* ================= 버튼 (입체 게임 버튼) ================= */
.btn {
  border: 1px solid #BCCDBF;
  border-bottom: 3px solid #9FB5A4;
  background: linear-gradient(180deg, #FFFFFF 0%, #EDF3EE 100%);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  transition: filter .12s, transform .06s, border-bottom-width .06s;
}
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 1px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #47CB88 0%, var(--green) 55%, var(--green-dark) 100%);
  border-color: var(--green-dark);
  border-bottom-color: #0A5A34;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 60, 30, .35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35);
}
.btn.ghost { background: linear-gradient(180deg, #FFFFFF, #F2F4F2); color: var(--ink-2); }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.btn-col .btn { width: 100%; }

/* ================= 셋업 화면 ================= */
#setup-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.setup-card {
  width: min(600px, 95vw);
  background: linear-gradient(180deg, #FFFFFF 0%, #F4FAF4 100%);
  border: 1px solid #D5E4D6;
  border-radius: 26px;
  box-shadow: var(--sh), inset 0 2px 0 #fff;
  padding: 34px 38px 28px;
}
.logo { text-align: center; margin-bottom: 4px; }
.logo .mark { font-size: 52px; filter: drop-shadow(0 4px 6px rgba(20, 60, 40, .25)); }
.logo h1 {
  font-size: 42px; font-weight: 900; letter-spacing: -1px; color: var(--green-deep); margin-top: 2px;
  text-shadow: 0 2px 0 #fff, 0 5px 12px rgba(20, 90, 55, .25);
}
.logo h1 em {
  font-style: normal; color: var(--gold);
  text-shadow: 0 2px 0 #fff, 0 1px 0 var(--gold-dark), 0 5px 12px rgba(150, 110, 20, .35);
}
.logo p { color: var(--ink-2); font-size: 13.5px; margin-top: 8px; line-height: 1.65; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.setup-sec { margin-top: 18px; }
.setup-grid .setup-sec { margin-top: 0; }
.setup-sec > label { font-size: 13px; font-weight: 800; color: var(--ink-2); display: block; margin-bottom: 8px; }
.label-sub { font-weight: 500; color: var(--ink-3); }
.chips { display: flex; gap: 8px; }
.chips-wrap { flex-wrap: wrap; }
.chips-wrap .chip { flex: 1 1 30%; font-size: 13.5px; padding: 8px 4px; }
.chip {
  flex: 1;
  border: 1px solid #C6D7C9;
  border-bottom: 3px solid #A8BFAD;
  background: linear-gradient(180deg, #fff, #EFF4EF);
  border-radius: 12px;
  padding: 9px 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-2);
  transition: all .1s;
}
.chip:active { transform: translateY(2px); border-bottom-width: 1px; }
.chip.on {
  background: linear-gradient(180deg, #47CB88, var(--green) 60%, var(--green-dark));
  color: #fff; border-color: var(--green-dark); border-bottom-color: #0A5A34;
  text-shadow: 0 1px 2px rgba(0, 60, 30, .35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35);
}
.seat { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.seat.is-ai { opacity: .92; }
.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--pc);
  box-shadow: 0 3px 6px rgba(20, 60, 40, .28);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  position: relative;
  padding: 0;
}
.av-core { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.avatar img, .pc-avatar img, .token img, .pb-av img, .mini-av img, .lb-av img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}
.avatar-btn { cursor: pointer; }
.avatar-btn:hover { box-shadow: 0 0 0 3px rgba(24, 154, 92, .35), 0 3px 6px rgba(20, 60, 40, .28); }
.avatar .cam {
  position: absolute; right: -4px; bottom: -4px;
  font-size: 11px; line-height: 1;
  background: #fff; border: 1px solid #C6D7C9; border-radius: 50%;
  padding: 2.5px; box-shadow: 0 1px 3px rgba(20, 60, 40, .25);
}
.seat-name {
  flex: 1; font-family: inherit; font-size: 15px; font-weight: 600; padding: 10px 13px;
  border: 1.5px solid #C6D7C9; border-radius: 12px; background: #fff;
}
.seat-name:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(24, 154, 92, .18); }
.role-tag {
  font-size: 12.5px; font-weight: 800; border-radius: 99px; padding: 5px 13px; flex: none;
}
.role-tag.human { background: linear-gradient(180deg, #47CB88, var(--green-dark)); color: #fff; text-shadow: 0 1px 2px rgba(0, 60, 30, .3); }
.role-tag.ai { background: #E8EEF6; color: #5B7290; border: 1px solid #C9D6E6; }
.opt-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.opt-row input { margin-top: 3px; accent-color: var(--green); width: 17px; height: 17px; }
#btn-start { width: 100%; margin-top: 22px; font-size: 18px; padding: 15px; border-radius: 14px; }
#btn-resume { width: 100%; margin-top: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #DCE7DD; border-radius: 12px;
  padding: 7px 11px; margin-bottom: 6px; font-size: 13px;
}
.lb-row.top { background: linear-gradient(180deg, #FFF6DC, #FBEBBB); border-color: #E8CF8B; }
.lb-rank { width: 22px; text-align: center; font-weight: 900; color: var(--ink-2); flex: none; }
.lb-av {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: #F0F4F0; border: 1.5px solid #D5E0D6;
  display: flex; align-items: center; justify-content: center; font-size: 14px; overflow: hidden;
}
.lb-name { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { font-size: 11px; color: var(--ink-3); flex: none; }
.lb-nw { font-weight: 900; font-variant-numeric: tabular-nums; flex: none; }
.setup-foot { margin-top: 16px; font-size: 12px; color: var(--ink-3); text-align: center; line-height: 1.7; }

/* ================= 게임 레이아웃 ================= */
#game-screen { display: flex; flex-direction: column; min-height: 100vh; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  background: linear-gradient(180deg, #128355 0%, var(--green-deep) 100%);
  border-bottom: 3px solid #06432C;
  box-shadow: 0 3px 10px rgba(10, 60, 40, .3);
  position: sticky; top: 0; z-index: 30;
}
#topbar .brand { font-weight: 900; color: #fff; font-size: 17px; text-shadow: 0 1px 3px rgba(0, 50, 30, .5); }
#topbar .brand em { font-style: normal; color: var(--gold); }
#hud-round, #hud-salary {
  font-size: 12.5px; font-weight: 700; color: #EFFCF4;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
  padding: 4px 11px; border-radius: 99px;
}
#hud-turn { font-size: 14px; font-weight: 800; color: #fff; display: flex; align-items: center; gap: 6px; text-shadow: 0 1px 2px rgba(0, 50, 30, .4); }
#topbar .spacer { flex: 1; }
#topbar .btn { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
#build-tag { font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, .55); }
#provider-top {
  font-size: 12px; font-weight: 800; text-decoration: none;
  color: rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 99px; padding: 3px 10px;
}
#provider-top:hover { background: rgba(255, 255, 255, .22); }
.provider { color: var(--green-dark); font-weight: 800; text-decoration: none; }
.provider:hover { text-decoration: underline; }
#btn-fast.on, #btn-bgm.on, #btn-sfx.on {
  background: linear-gradient(180deg, #FFD86B, var(--gold) 60%, var(--gold-dark));
  border-color: var(--gold-dark); border-bottom-color: #97721C; color: #5C4308; text-shadow: none;
}

.game-wrap { flex: 1; display: flex; gap: 20px; align-items: flex-start; justify-content: center; padding: 20px; flex-wrap: wrap; }

/* ================= 보드 ================= */
#board {
  position: relative;
  width: min(92vmin, 940px, 96vw);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  gap: 3px;
  padding: 12px;
  background:
    radial-gradient(circle at 50% 38%, var(--felt-1) 0%, var(--felt-2) 78%);
  border-radius: 24px;
  box-shadow:
    0 0 0 7px var(--frame),
    0 0 0 10px var(--frame-dark),
    var(--sh),
    inset 0 0 60px rgba(0, 40, 25, .35);
}
.tile {
  position: relative;
  background: linear-gradient(180deg, var(--tile) 0%, var(--tile-2) 100%);
  border: 1px solid var(--tile-edge);
  border-radius: 8px;
  box-shadow: inset 0 1.5px 0 #fff, 0 2px 3px rgba(0, 30, 18, .25);
  overflow: hidden;
  cursor: default;
  display: flex; flex-direction: column;
  transition: box-shadow .18s, transform .18s;
}
.tile.t-prop { cursor: pointer; }
.tile.t-prop:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px #fff, 0 4px 10px rgba(0, 30, 18, .35); z-index: 2; }
.tile.here {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(245, 197, 66, .8);
  z-index: 3;
  animation: herePulse .9s ease;
}
@keyframes herePulse { 0% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* 소유지 타일: 컬러 밴드 + 흰 면 */
.t-band {
  flex: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--zc) 68%, white) 0%, var(--zc) 85%);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.3px;
  text-align: center;
  padding: 3px 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  white-space: nowrap;
  overflow: hidden;
  min-height: 30%;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}
/* 이름 길이별 폰트 자동 축소 — 항상 한 줄 유지 */
.t-band[data-len="6"] { font-size: 10.8px; letter-spacing: -0.4px; }
.t-band[data-len="7"] { font-size: 10px; letter-spacing: -0.5px; }
.t-band[data-len="8"], .t-band[data-len="9"] { font-size: 9.2px; letter-spacing: -0.6px; }
.t-face {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 1px;
}
.t-art { height: 26px; display: flex; align-items: center; justify-content: center; }
.t-art svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 1.5px rgba(0, 30, 18, .22)); }
.tc-art { display: flex; justify-content: center; margin: 10px 0 -4px; }
.tc-art svg { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px rgba(0, 30, 18, .2)); }
.t-price { font-size: 10px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.t-price i { font-style: normal; font-size: .8em; color: var(--ink-3); margin-left: 1px; }
.tile.owned { box-shadow: inset 0 0 0 3px var(--pc), 0 2px 3px rgba(0, 30, 18, .25); }
.tile.owned .t-face { background: color-mix(in srgb, var(--pc) 16%, white); }
.tile.mono { box-shadow: inset 0 0 0 2.5px var(--pc), 0 0 12px rgba(245, 197, 66, .75), 0 2px 3px rgba(0, 30, 18, .25); }
.tile.mono .t-band::after { content: ' ★'; color: var(--gold); text-shadow: 0 1px 1px rgba(90, 60, 0, .5); }

/* 특수 타일 */
.t-body.sp {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 2px; text-align: center;
}
.t-name { font-size: 10.5px; font-weight: 800; line-height: 1.12; white-space: nowrap; letter-spacing: -0.3px; }
.t-sub { font-size: 9px; color: var(--ink-3); font-weight: 600; line-height: 1.1; }
.t-emoji { font-size: 19px; line-height: 1.1; filter: drop-shadow(0 2px 2px rgba(0, 30, 18, .25)); }
.t-quiz { background: linear-gradient(180deg, #F2F8FF, #DEEDFC); }
.t-card { background: linear-gradient(180deg, #FFF8EC, #FDEBC8); }
.t-tax { background: linear-gradient(180deg, #FFF1EF, #FBD9D3); }
.t-fund { background: linear-gradient(180deg, #EFFBF2, #D8F3E0); }
.t-rest { background: linear-gradient(180deg, #F6F7F6, #E8ECE8); }

/* 모서리 아트 */
.corner { border: none; }
.corner .t-name { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); font-size: 10.5px; white-space: nowrap; letter-spacing: -0.4px; }
.corner .t-emoji { font-size: 20px; }
.corner .t-sub { font-size: 8.5px; }
.corner .t-sub { color: rgba(255, 255, 255, .88); }
.c-go { background: linear-gradient(160deg, #FFD86B 0%, #F2A83B 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 2px 3px rgba(0,30,18,.3); }
.c-heat { background: linear-gradient(160deg, #FF9A5C 0%, #EF5E3A 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 2px 3px rgba(0,30,18,.3); }
.c-exchange { background: linear-gradient(160deg, #6BC6E8 0%, #3E86CF 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 2px 3px rgba(0,30,18,.3); }
.c-congress { background: linear-gradient(160deg, #9E8CE8 0%, #6A5ACD 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 2px 3px rgba(0,30,18,.3); }

/* 건물 (레벨별 아이콘: ♻️ 재활용센터 → ☀️ 태양광 → ⚡ 수소플랜트, ⭐ 랜드마크) */
.t-pips { display: flex; gap: 1.5px; min-height: 15px; align-items: center; justify-content: center; }
.bld {
  display: inline-block;
  font-size: 12px; line-height: 1;
  filter: drop-shadow(0 1px 1.5px rgba(0, 30, 18, .4));
}
.bld.landmark {
  font-size: 16px;
  filter: drop-shadow(0 0 5px rgba(245, 197, 66, 1));
  animation: lmGlow 1.6s ease-in-out infinite;
}
@keyframes lmGlow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(245, 197, 66, .8)); }
  50% { filter: drop-shadow(0 0 8px rgba(245, 197, 66, 1)); }
}

/* 소유자 캐릭터 칩 (타일 우상단) */
.t-owner {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #fff 0%, var(--pc) 62%);
  border: 1.5px solid #fff;
  box-shadow: 0 1.5px 3px rgba(0, 0, 0, .4);
  display: none; align-items: center; justify-content: center;
  font-size: 9.5px; line-height: 1;
}
.tile.owned .t-owner { display: flex; }

/* 중앙 */
#center {
  grid-row: 2 / 11; grid-column: 2 / 11;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 3.5% 4%;
  min-height: 0;
}
#center .title {
  font-size: clamp(22px, 3.6vmin, 38px); font-weight: 900; letter-spacing: -0.5px; color: #fff;
  text-shadow: 0 2px 0 rgba(9, 70, 47, .9), 0 6px 14px rgba(0, 40, 25, .5);
}
#center .title em { font-style: normal; color: var(--gold); text-shadow: 0 2px 0 var(--gold-dark), 0 6px 14px rgba(0, 40, 25, .5); }
#center .subtitle { font-size: clamp(9px, 1.3vmin, 12.5px); color: #CBEEDC; margin-top: -5px; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 40, 25, .4); }
#dice { display: flex; gap: 12px; margin-top: 4px; }
.die {
  width: clamp(36px, 5.6vmin, 54px); height: clamp(36px, 5.6vmin, 54px);
  background: linear-gradient(160deg, #FFFFFF 0%, #E9EFEA 100%);
  border-radius: 24%;
  box-shadow: 0 4px 8px rgba(0, 40, 25, .4), inset 0 2px 0 #fff, inset 0 -3px 0 rgba(120, 140, 125, .35);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 13%;
}
.die.rolling { animation: diceShake .35s infinite; }
@keyframes diceShake {
  0%, 100% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-10deg) translateY(-4px); }
  75% { transform: rotate(10deg) translateY(2px); }
}
.dp { border-radius: 50%; margin: 11%; }
.dp.on { background: radial-gradient(circle at 35% 30%, #4A5A70, #22303F 70%); }
#prompt { font-size: clamp(12px, 1.7vmin, 15px); min-height: 22px; color: #EAF9F0; font-weight: 700; text-align: center; text-shadow: 0 1px 2px rgba(0, 40, 25, .45); }
#btn-roll { font-size: clamp(14px, 2vmin, 18px); padding: 13px 30px; border-radius: 14px; }
.lm-lock { font-style: normal; font-size: 10.5px; font-weight: 800; color: #B4870F; margin-left: 4px; }
#log {
  width: 100%; flex: 1; min-height: 56px;
  overflow-y: auto;
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 12px;
  box-shadow: inset 0 2px 6px rgba(0, 40, 25, .12);
  padding: 8px 10px;
  font-size: clamp(9px, 1.32vmin, 12.5px);
  line-height: 1.55;
}
.log-line { color: var(--ink-2); }
.log-line .lr { color: var(--ink-3); font-size: .85em; margin-right: 6px; font-variant-numeric: tabular-nums; }
.log-line.good { color: var(--good); font-weight: 600; }
.log-line.pay { color: #A4611F; }
.log-line.warn { color: #C25A10; font-weight: 700; }
.log-line.bad { color: var(--bad); font-weight: 800; }

/* 칸 이벤트 배너 */
.event-banner {
  position: absolute; top: 13%; left: 50%; translate: -50% -8px;
  z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #FFFFFF, #F4FAF5);
  border: 2px solid var(--gold);
  border-radius: 16px;
  box-shadow: var(--sh);
  padding: 12px 18px;
  max-width: 78%;
  opacity: 0; transition: all .22s cubic-bezier(.2, .9, .3, 1.2);
  pointer-events: none;
}
.event-banner.show { opacity: 1; translate: -50% 0; }
.eb-icon { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 30, 18, .25)); flex: none; }
.eb-tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.eb-tx b { font-size: 15px; font-weight: 900; }
.eb-tx span { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.eb-delta { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; flex: none; }
.eb-delta.plus { color: var(--good); }
.eb-delta.minus { color: var(--bad); }

/* 토큰 (캐릭터 말) */
.token {
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--pc);
  box-shadow: 0 4px 7px rgba(0, 30, 18, .45);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  transition: transform .13s ease-in-out;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}
.token.hop { animation: hop .13s ease-in-out; }
@keyframes hop { 50% { margin-top: -10px; } }
.token.land { animation: squash .26s ease-out; }
@keyframes squash { 0% { scale: 1.3 .7; } 55% { scale: .88 1.12; } 100% { scale: 1 1; } }
.token.tele { animation: tele .5s ease; }
@keyframes tele { 0% { opacity: 1; scale: 1; } 40% { opacity: .1; scale: .4; } 100% { opacity: 1; scale: 1; } }

/* ================= 사이드 패널 ================= */
#side { width: min(330px, 96vw); display: flex; flex-direction: column; gap: 14px; }
#players { display: flex; flex-direction: column; gap: 14px; }
.pcard {
  background: linear-gradient(180deg, #FFFFFF 0%, #F3F9F4 100%);
  border: 1px solid #D5E4D6;
  border-left: 6px solid var(--pc);
  border-radius: 16px;
  box-shadow: var(--sh-sm), inset 0 1.5px 0 #fff;
  padding: 11px 14px 10px;
  position: relative;
  transition: box-shadow .25s, transform .25s;
}
.pcard.active {
  box-shadow: 0 0 0 3px var(--pc), 0 0 16px color-mix(in srgb, var(--pc) 55%, transparent), var(--sh-sm);
  transform: translateX(2px) scale(1.01);
}
.pcard.dead { opacity: .45; filter: grayscale(.9); }
.pc-top { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 800; }
.pc-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--pc);
  box-shadow: 0 2px 4px rgba(20, 60, 40, .3);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  overflow: hidden;
}
.pc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-b {
  flex: none; font-size: 11px; font-weight: 900; border-radius: 99px; padding: 2.5px 8px;
  background: #EDF1ED; color: var(--ink-3); border: 1px solid #D8E0D8;
}
.rank-b.r1 { background: linear-gradient(180deg, #FFE28A, #F2B93B); color: #6B4E07; border-color: #D9A62F; box-shadow: 0 1px 3px rgba(180, 130, 20, .35); }
.rank-b.r2 { background: linear-gradient(180deg, #F2F5F8, #CDD7E0); color: #4E5B68; border-color: #B9C6D1; }
.rank-b.r3 { background: linear-gradient(180deg, #F0DBC8, #D9AE85); color: #6E4A26; border-color: #C79A6F; }
.rank-b.out { opacity: .55; text-decoration: line-through; }
.pb-av {
  display: inline-flex; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; align-items: center; justify-content: center;
  font-size: 10px; margin-right: 5px; vertical-align: -3px; overflow: hidden;
}
.mini-av {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--pc);
  align-items: center; justify-content: center;
  font-size: 12px; margin-right: 7px; vertical-align: -6px; overflow: hidden;
}
.ai-tag { font-style: normal; font-size: 10px; background: #E8EEF6; color: #5B7290; border-radius: 6px; padding: 1.5px 6px; margin-left: 6px; vertical-align: 1px; }
.heat-tag { font-size: 11px; flex: none; color: #C25A10; font-weight: 800; }
.pdot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: inset 0 -1px 2px rgba(0, 0, 0, .3), 0 1px 1px rgba(255,255,255,.6); }
.pc-credit { font-size: 25px; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; display: flex; align-items: baseline; gap: 4px; }
.pc-credit .coin { font-size: 16px; filter: drop-shadow(0 1px 2px rgba(20, 60, 40, .3)); }
.pc-credit small { font-size: 14px; color: var(--ink-3); font-weight: 800; }
.pc-nw { font-size: 12px; color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-props { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; min-height: 20px; }
.pc-props .none { font-size: 11px; color: var(--ink-3); }
.prop-chip {
  font-size: 11px; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--zc) 72%, white), var(--zc));
  border-radius: 7px; padding: 2.5px 8px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 1px 2px rgba(0, 30, 18, .25);
}
.prop-chip.mono { outline: 2px solid var(--gold); box-shadow: 0 0 8px rgba(245, 197, 66, .7); }
.pc-keeps { display: flex; gap: 5px; margin-top: 5px; min-height: 14px; }
.keep { font-size: 11px; font-weight: 700; background: linear-gradient(180deg, #FFF6DC, #FBE9B7); border: 1px solid #E8CF8B; border-radius: 7px; padding: 1.5px 7px; color: #8A6A1F; }
.fdelta {
  position: absolute; right: 14px; top: 10px;
  font-size: 16px; font-weight: 900;
  animation: floatUp 1.25s ease forwards;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #fff, 0 2px 4px rgba(20, 60, 40, .2);
}
.fdelta.plus { color: var(--good); }
.fdelta.minus { color: var(--bad); }
@keyframes floatUp { 0% { opacity: 0; translate: 0 8px; } 20% { opacity: 1; } 100% { opacity: 0; translate: 0 -24px; } }

.legend {
  background: rgba(255, 255, 255, .85);
  border: 1px solid #D5E4D6; border-radius: 16px;
  box-shadow: var(--sh-sm);
  padding: 11px 14px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
}
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; box-shadow: inset 0 -1px 1px rgba(0,0,0,.2); }
.legend .wide { grid-column: 1 / -1; color: var(--ink-3); line-height: 1.55; margin-top: 3px; font-weight: 500; }

/* ================= 모달 ================= */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 45, 30, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .16s;
}
.overlay.show { opacity: 1; }
.overlay.closing { opacity: 0; }
.modal {
  width: min(450px, 94vw); max-height: 86vh; overflow-y: auto;
  background: linear-gradient(180deg, #FFFFFF 0%, #F4FAF5 100%);
  border-radius: 22px;
  box-shadow: var(--sh), inset 0 2px 0 #fff;
  padding: 22px 24px;
  transform: translateY(10px) scale(.98); transition: transform .18s cubic-bezier(.2, .9, .3, 1.2);
}
.overlay.show .modal { transform: translateY(0) scale(1); }
.modal header { font-size: 17px; font-weight: 900; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pbadge {
  font-size: 12.5px; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 75%, white), var(--pc));
  border-radius: 99px; padding: 3.5px 11px; font-weight: 800;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
}
.hint { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-top: 10px; }
.reward { font-size: 12px; font-weight: 800; color: var(--good); background: #E2F5E7; padding: 2.5px 9px; border-radius: 99px; }

.tile-card { border: 1px solid #D8E3D9; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--sh-sm); }
.tc-strip {
  color: #fff; font-weight: 900; font-size: 14px; text-align: center; padding: 9px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc, #999) 0%, transparent), transparent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.tile-card h3 { text-align: center; font-size: 20px; font-weight: 900; margin: 10px 0 2px; }
.tc-price { text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.rent-table { width: calc(100% - 28px); margin: 0 14px 12px; border-collapse: collapse; font-size: 12.5px; }
.rent-table th { color: var(--ink-3); font-weight: 700; text-align: right; padding: 3px 6px; border-bottom: 1.5px solid #DDE7DE; }
.rent-table th:first-child, .rent-table td:first-child { text-align: left; }
.rent-table td { text-align: right; padding: 3.5px 6px; font-variant-numeric: tabular-nums; font-weight: 600; }
.rent-table tr.now td { background: #FFF4D6; font-weight: 900; }
.tile-card .hint { margin: 0 14px 12px; font-size: 11.5px; }

.build-list, .pick-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-height: 44vh; overflow-y: auto; }
.build-row, .pick-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #D8E3D9; border-radius: 12px;
  padding: 9px 11px; font-size: 13.5px;
  box-shadow: 0 1px 3px rgba(20, 60, 40, .08);
}
.pick-item { cursor: pointer; text-align: left; transition: all .12s; font-family: inherit; }
.pick-item:hover { border-color: var(--green); box-shadow: 0 0 0 2px rgba(24, 154, 92, .25), var(--sh-sm); transform: translateY(-1px); }
.dot { width: 11px; height: 11px; border-radius: 3.5px; flex: none; box-shadow: inset 0 -1px 1px rgba(0,0,0,.25); }
.bname { font-weight: 800; }
.build-row .lv-now { margin-left: auto; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.pick-item .plv { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.pick-item .pprice { font-weight: 900; font-variant-numeric: tabular-nums; }
.btn.step {
  width: 34px; height: 34px; padding: 0; border-radius: 10px; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.build-row .step.up { margin-left: 4px; }
.build-total { margin-top: 12px; font-size: 14.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.build-total .neg { color: var(--bad); }

.quiz-q { font-size: 16.5px; font-weight: 800; line-height: 1.5; margin: 6px 0 4px; }
.btn.choice { text-align: left; font-weight: 700; }
.btn.choice.correct { background: linear-gradient(180deg, #E9F8EE, #D2EEDC); border-color: var(--good); border-bottom-color: #157042; color: var(--good); }
.btn.choice.wrong { background: linear-gradient(180deg, #FDEEEB, #F8D8D2); border-color: var(--bad); border-bottom-color: #B93A2C; color: var(--bad); }
.quiz-fb { font-size: 13px; margin-top: 12px; line-height: 1.55; font-weight: 700; }
.quiz-fb.ok { color: var(--good); }
.quiz-fb.no { color: var(--bad); }

.flipcard { perspective: 900px; margin: 8px auto; width: 240px; height: 300px; }
.fc-inner { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2, .7, .3, 1); }
.fc-inner.flip { transform: rotateY(180deg); }
.fc-front, .fc-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.fc-front {
  background:
    repeating-radial-gradient(circle at 50% 50%, transparent 0 22px, rgba(255, 255, 255, .07) 22px 24px),
    linear-gradient(150deg, #1FA26B, #0B5E3F);
  border: 4px solid #E7C876;
  color: #fff; font-size: 54px;
  box-shadow: var(--sh);
  text-shadow: 0 3px 6px rgba(0, 40, 25, .5);
}
.fc-front span { font-size: 17px; font-weight: 900; letter-spacing: 5px; }
.fc-back {
  background: linear-gradient(180deg, #FFFFFF, #F6FBF3);
  border: 4px solid #E7C876;
  transform: rotateY(180deg);
  text-align: center;
  box-shadow: var(--sh);
}
.fc-back h3 { font-size: 18.5px; font-weight: 900; color: var(--green-deep); }
.fc-back p { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); font-weight: 600; }
.fc-back .note { font-size: 11.5px; color: var(--ink-3); border-top: 1.5px dashed #DCE6DC; padding-top: 8px; margin-top: 4px; font-weight: 500; }

.bankrupt { font-size: 56px; text-align: center; margin: 8px 0; filter: drop-shadow(0 4px 8px rgba(180, 40, 20, .4)); }
.result-table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 6px; }
.result-table th { font-size: 12px; color: var(--ink-3); text-align: left; padding: 5px 8px; border-bottom: 1.5px solid #DDE7DE; }
.result-table td { padding: 10px 8px; border-bottom: 1px solid #E9F0E9; font-variant-numeric: tabular-nums; font-weight: 600; }
.result-table td:last-child { text-align: right; font-weight: 900; }
.result-table .pdot { margin-right: 7px; }
.result-table tr.winner td {
  background: linear-gradient(180deg, #FFF6DC, #FBE9B7);
  font-weight: 900; font-size: 16.5px;
}

/* ================= 토스트 ================= */
#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center;
  pointer-events: none;
}
.toast {
  background: linear-gradient(180deg, rgba(20, 75, 52, .96), rgba(9, 50, 34, .96));
  color: #fff; font-size: 13.5px; font-weight: 700;
  padding: 10px 20px; border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: var(--sh);
  opacity: 0; translate: 0 8px; transition: all .25s;
}
.toast.show { opacity: 1; translate: 0 0; }
.toast.good { background: linear-gradient(180deg, rgba(23, 125, 78, .97), rgba(10, 80, 50, .97)); }
.toast.bad { background: linear-gradient(180deg, rgba(190, 60, 40, .97), rgba(140, 35, 22, .97)); }

/* ================= 반응형 ================= */
@media (max-width: 1080px) {
  .game-wrap { padding: 12px; gap: 14px; }
  #side { width: min(760px, 96vw); }
  #players { flex-direction: row; flex-wrap: wrap; }
  #players .pcard { flex: 1 1 44%; }
}
@media (max-width: 560px) {
  #topbar { flex-wrap: wrap; gap: 6px; }
  #board { width: 96vw; }
  .t-price, .t-sub { display: none; }
  .setup-grid { grid-template-columns: 1fr; }
  #players .pcard { flex: 1 1 100%; }
}
