:root {
  --bg0: #140d08;
  --bg1: #1d130d;
  --bg2: #2a1b12;
  --panel: #33221a;
  --panel2: #3f2a1d;
  --line: rgba(233, 196, 140, .16);
  --line2: rgba(233, 196, 140, .32);
  --gold: #d9a95b;
  --gold2: #f3cf86;
  --cream: #f4e7d1;
  --muted: #b89d7c;
  --dim: #8a7058;
  --red: #e2453c;
  --blue: #3b7be0;
  --yellow: #f2c230;
  --good: #79c27a;
  --bad: #e2675c;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --title: 'Black Han Sans', 'Jua', sans-serif;
  --fun: 'Jua', 'Noto Sans KR', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #4a2f1c 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 100%, #2b1a10 0%, transparent 60%),
    var(--bg1);
  background-attachment: fixed;
  color: var(--cream);
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: linear-gradient(180deg, rgba(20, 13, 8, .92), rgba(20, 13, 8, .6));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; position: relative;
  background: linear-gradient(145deg, #5a3a22, #2e1d12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 8px rgba(0,0,0,.4);
}
.brand-mark i { position: absolute; width: 10px; height: 10px; border-radius: 50%; }
.brand-mark .r { background: var(--red); left: 6px; top: 6px; }
.brand-mark .b { background: var(--blue); right: 6px; top: 6px; }
.brand-mark .y { background: var(--yellow); left: 12px; bottom: 5px; }
.brand-name { white-space: nowrap; font-family: var(--title); font-size: 22px; letter-spacing: 1px; color: var(--gold2); text-shadow: 0 2px 0 #4a2c14; }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); font-family: var(--fun); font-size: 17px; color: var(--gold2);
}
.icon-btn svg { width: 18px; height: 18px; }
.online-dot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.online-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.me-chip {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: 18px;
  background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line2);
  font-family: var(--fun); font-size: 15px; white-space: nowrap; max-width: 52vw;
}
.me-chip > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.me-chip .av, .me-chip .lv { flex: none; }
@media (max-width: 430px) { .online-dot { display: none; } .top-right { gap: 6px; } .brand-name { font-size: 20px; } }
@media (max-width: 360px) { .brand-name { display: none; } }
.me-chip .av { width: 28px; height: 28px; font-size: 17px; }
.me-chip .lv { font-size: 11px; color: var(--gold2); background: rgba(0,0,0,.35); border-radius: 8px; padding: 1px 6px; }
.me-chip.login { padding: 0 14px; color: var(--bg1); background: linear-gradient(180deg, var(--gold2), var(--gold)); border: 0; font-weight: 700; }

#view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-b)); }

/* ---------- 공통 ---------- */
.av, .avatars button { overflow: hidden; }
.av svg, .avatars button svg { width: 100%; height: 100%; display: block; }
.avatars button { padding: 5px; }
.sticker {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 15px 5px 5px; border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--sb) 80%, #fff), var(--sb));
  color: #fff; font-family: var(--fun); font-size: 18px; line-height: 1; white-space: nowrap;
  border: 3px solid #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--sb) 55%, #000), 0 12px 26px rgba(0,0,0,.45);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.sticker svg { width: 32px; height: 32px; flex: none; filter: drop-shadow(0 1px 0 rgba(0,0,0,.2)); }
.sticker.mini { font-size: 14px; padding: 3px 11px 3px 3px; gap: 5px; border-width: 2px; box-shadow: 0 3px 0 color-mix(in srgb, var(--sb) 55%, #000); }
.sticker.mini svg { width: 24px; height: 24px; }
.av {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a4630, #2e1d12); border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,.4); line-height: 1;
}
.panel {
  background: linear-gradient(180deg, rgba(63, 42, 29, .92), rgba(43, 28, 19, .92));
  border: 1px solid var(--line2); border-radius: var(--radius); box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px; border-radius: 16px; font-family: var(--fun); font-size: 18px;
  background: linear-gradient(180deg, #f6d48f, #d39c47); color: #3a210e;
  box-shadow: 0 4px 0 #8a5a24, 0 8px 18px rgba(0,0,0,.35); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a5a24, 0 4px 10px rgba(0,0,0,.35); }
.btn.ghost { background: linear-gradient(180deg, #4b3221, #3a2618); color: var(--cream); box-shadow: 0 4px 0 #1f140c, 0 8px 18px rgba(0,0,0,.3); border: 1px solid var(--line2); }
.btn.ghost:active { box-shadow: 0 1px 0 #1f140c; }
.btn.red { background: linear-gradient(180deg, #f06a5f, #c7362e); color: #fff; box-shadow: 0 4px 0 #7d1f19, 0 8px 18px rgba(0,0,0,.35); }
.btn.blue { background: linear-gradient(180deg, #67a0f5, #2f68c7); color: #fff; box-shadow: 0 4px 0 #1b3f7d, 0 8px 18px rgba(0,0,0,.35); }
.btn.sm { height: 40px; font-size: 15px; padding: 0 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { filter: grayscale(.8) brightness(.7); pointer-events: none; }
.seg { display: flex; gap: 6px; padding: 5px; background: rgba(0,0,0,.3); border-radius: 14px; border: 1px solid var(--line); }
.seg button { flex: 1; height: 40px; border-radius: 10px; font-family: var(--fun); font-size: 15px; color: var(--muted); transition: .15s; }
.seg button.on { background: linear-gradient(180deg, #5c3d26, #45301f); color: var(--gold2); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 2px 6px rgba(0,0,0,.3); }
.label { font-size: 13px; color: var(--muted); margin: 18px 2px 8px; font-weight: 500; }
.field {
  width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(0,0,0,.3);
  color: var(--cream); padding: 0 16px; outline: none; font-size: 16px; transition: border-color .15s;
}
.field:focus { border-color: var(--gold); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }
.pc { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; box-shadow: inset -2px -2px 3px rgba(0,0,0,.3), inset 2px 2px 3px rgba(255,255,255,.35); }
.pc.red { background: var(--red); } .pc.blue { background: var(--blue); } .pc.yellow { background: var(--yellow); }

/* ---------- 로비 ---------- */
.lobby { display: grid; gap: 16px; grid-template-columns: 1fr; animation: rise .4s ease both; }
@media (min-width: 900px) { .lobby { grid-template-columns: 340px 1fr; align-items: start; } }

.profile-card { padding: 18px; display: grid; gap: 14px; }
.pc-top { display: flex; gap: 14px; align-items: center; }
.pc-top .av { width: 64px; height: 64px; font-size: 36px; border-width: 3px; }
.pc-name { font-family: var(--fun); font-size: 22px; }
.pc-sub { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.tier { font-family: var(--fun); font-size: 13px; padding: 2px 10px; border-radius: 10px; background: rgba(0,0,0,.35); border: 1px solid currentColor; }
.lvbadge { font-family: var(--fun); font-size: 13px; padding: 2px 10px; border-radius: 10px; background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #3a210e; }
.xpbar { height: 12px; border-radius: 8px; background: rgba(0,0,0,.4); overflow: hidden; border: 1px solid var(--line); position: relative; }
.xpbar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #c98a3b, #f6d48f); border-radius: 8px; transition: width .9s cubic-bezier(.2,.8,.2,1); box-shadow: 0 0 12px rgba(246, 212, 143, .5); }
.xptext { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 6px; text-align: center; border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--fun); font-size: 20px; font-weight: 400; }
.stat span { font-size: 11px; color: var(--muted); }

.modes { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.mode {
  position: relative; overflow: hidden; border-radius: 22px; padding: 18px; min-height: 150px; text-align: left;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 14px 28px rgba(0,0,0,.35);
  transition: transform .12s;
}
.mode:hover { transform: translateY(-2px); }
.mode:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.mode h3 { margin: 0; font-family: var(--title); font-size: 26px; font-weight: 400; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0,0,0,.3); position: relative; z-index: 1; }
.mode p { margin: 0; font-size: 13px; opacity: .85; position: relative; z-index: 1; }
.mode .art { position: absolute; right: -10px; top: -10px; width: 130px; height: 130px; opacity: .95; }
.mode.ai { background: linear-gradient(150deg, #c8463b, #7e211b); grid-column: span 2; min-height: 170px; }
.mode.online { background: linear-gradient(150deg, #3f7ad6, #1e3f80); }
.mode.local { background: linear-gradient(150deg, #e0ad2c, #9b6c10); color: #2e1c06; }
.mode.records, .mode.rank { background: linear-gradient(150deg, #5a3c27, #33221a); min-height: 110px; }
.mode .badge { position: absolute; top: 14px; left: 16px; font-family: var(--fun); font-size: 12px; padding: 3px 10px; border-radius: 10px; background: rgba(0,0,0,.28); z-index: 1; }
@media (min-width: 900px) {
  .modes { grid-template-columns: 1fr 1fr 1fr; }
  .mode.ai { grid-column: span 3; min-height: 200px; }
  .mode.records, .mode.rank { min-height: 120px; }
  .mode.records { grid-column: span 2; }
}

/* ---------- 시트 / 모달 ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 5, 3, .66); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease both;
}
@media (min-width: 700px) { .backdrop { align-items: center; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow: hidden; display: flex; flex-direction: column;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #432c1d, #2c1d13); border: 1px solid var(--line2); border-bottom: 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .28s cubic-bezier(.2,.9,.25,1.1) both;
}
@media (min-width: 700px) { .sheet { border-radius: 26px; border-bottom: 1px solid var(--line2); } }
.sheet-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 22px 20px calc(22px + var(--safe-b));
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: rgba(217, 169, 91, .4) transparent;
}
.sheet-scroll::-webkit-scrollbar { width: 6px; }
.sheet-scroll::-webkit-scrollbar-track { background: transparent; margin: 22px 0; }
.sheet-scroll::-webkit-scrollbar-thumb { background: rgba(217, 169, 91, .4); border-radius: 6px; }
body.modal-open { overflow: hidden; }
html { scrollbar-width: thin; scrollbar-color: rgba(217, 169, 91, .35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(217, 169, 91, .35); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.sheet .actions.three .btn { font-size: 16px; padding: 0 10px; }
.top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.back-btn svg { width: 20px; height: 20px; }
.sheet h2 { margin: 0 0 6px; font-family: var(--title); font-weight: 400; font-size: 26px; color: var(--gold2); }
.sheet .close { position: absolute; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.x { width: 36px; height: 36px; border-radius: 12px; background: rgba(0,0,0,.3); color: var(--muted); font-size: 20px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet .actions .btn { flex: 1; }

.levels { display: grid; gap: 8px; }
.level {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: rgba(0,0,0,.25); border: 2px solid transparent; text-align: left; transition: .15s;
}
.level.on { border-color: var(--gold); background: rgba(217, 169, 91, .14); }
.level .av { width: 46px; height: 46px; font-size: 26px; flex: none; }
.level b { font-family: var(--fun); font-weight: 400; font-size: 17px; display: block; }
.level small { color: var(--muted); font-size: 12px; }
.level .stars { margin-left: auto; color: var(--gold2); font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.level .stars i { font-style: normal; color: rgba(255,255,255,.15); }

.login-social { display: grid; gap: 10px; margin-top: 8px; }
.social { height: 52px; border-radius: 14px; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.social.kakao { background: #fee500; color: #191600; }
.social.naver { background: #03c75a; color: #fff; }
.social.google { background: #fff; color: #222; }
.social svg { width: 20px; height: 20px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; margin: 18px 0 6px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.form { display: grid; gap: 10px; margin-top: 10px; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { aspect-ratio: 1; border-radius: 14px; background: rgba(0,0,0,.28); font-size: 26px; border: 2px solid transparent; }
.avatars button.on { border-color: var(--gold); background: rgba(217,169,91,.15); }

.join-row { display: flex; gap: 8px; align-items: stretch; }
.join-row .code-field { flex: 1; min-width: 0; letter-spacing: 6px; font-family: var(--fun); font-size: 20px; text-align: center; }
.join-row .btn { flex: none; height: 50px; min-width: 88px; padding: 0 18px; white-space: nowrap; }
.btn, .act, .seg button, .tier, .lvbadge { white-space: nowrap; }
.gtag { font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 8px; padding: 0 6px; vertical-align: 2px; }
.code-box { font-family: var(--title); font-size: 46px; letter-spacing: 10px; text-align: center; color: var(--gold2); padding: 14px 0; background: rgba(0,0,0,.3); border-radius: 16px; border: 1px dashed var(--line2); margin: 12px 0; }
.searching { display: grid; place-items: center; padding: 22px 0 6px; gap: 16px; }
.radar { width: 120px; height: 120px; border-radius: 50%; position: relative; background: radial-gradient(circle, rgba(217,169,91,.25), transparent 70%); border: 2px solid var(--line2); }
.radar::before, .radar::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--gold); animation: ping 1.6s ease-out infinite; }
.radar::after { animation-delay: .8s; }
.radar .av { position: absolute; inset: 26px; font-size: 38px; }
.timer-txt { font-family: var(--fun); color: var(--muted); }

.rules { font-size: 15px; line-height: 1.7; color: var(--cream); }
.rules ol { padding-left: 20px; margin: 8px 0 0; }
.rules li { margin-bottom: 8px; }
.rules b { color: var(--gold2); font-weight: 500; }

/* ---------- 게임 화면 ---------- */
/* 고정 요소 높이: 상단바 56 + HUD 58 + 단계표시 32 + 액션바 54 + 간격/여백 52 */
.game {
  --chrome: calc(252px + env(safe-area-inset-top, 0px) + var(--safe-b));
  --bsize: min(calc(100vw - 20px), calc(100dvh - var(--chrome)), 760px);
  display: grid; gap: 10px; justify-items: center; align-content: center; animation: fade .3s ease both;
}
.game.replaying { --chrome: calc(310px + env(safe-area-inset-top, 0px) + var(--safe-b)); }
body[data-view="game"] #app { height: 100dvh; overflow: hidden; }
#view.full { padding: 8px 10px calc(8px + var(--safe-b)); max-width: none; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
@media (max-width: 999px) {
  .topbar { padding-top: calc(env(safe-area-inset-top, 0px) + 10px); padding-bottom: 10px; }
  .pcard { padding: 6px 8px; border-radius: 14px; min-height: 58px; }
  .pcard .av { width: 36px; height: 36px; }
  .pcard .nm { font-size: 14px; }
  .pcard .sc { font-size: 24px; }
  .phase-tag { font-size: 14px; padding: 4px 14px; min-height: 32px; }
  .act { height: 54px; }
}
@media (max-height: 640px) and (max-width: 999px) {
  .game { --chrome: calc(228px + env(safe-area-inset-top, 0px) + var(--safe-b)); gap: 8px; }
  .pcard .meta { display: none; }
  .act { height: 48px; font-size: 0; gap: 0; padding-top: 0; }
  .act .cnt { font-size: 11px; }
}
.hud { width: 100%; max-width: var(--bsize); display: flex; gap: 8px; }
.pcard {
  flex: 1; min-width: 0; position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(63,42,29,.95), rgba(40,26,17,.95)); border: 2px solid var(--line);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.pcard.active { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 8px 22px rgba(0,0,0,.4); transform: translateY(-2px); }
.pcard.out { opacity: .55; }
.pcard .av { width: 40px; height: 40px; font-size: 22px; flex: none; border-color: var(--c); }
.pcard .nm { font-family: var(--fun); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.pcard .info { min-width: 0; flex: 1; }
.pcard .sc { font-family: var(--title); font-size: 26px; color: var(--c); text-shadow: 0 2px 0 rgba(0,0,0,.4); min-width: 30px; text-align: right; }
.pcard .ring { position: absolute; inset: -2px; border-radius: 16px; pointer-events: none; }
.pcard .tbar { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 3px; border-radius: 3px; background: rgba(0,0,0,.4); overflow: hidden; }
.pcard .tbar i { position: absolute; inset: 0 auto 0 0; background: var(--c); width: 100%; }
.pcard .tbar.warn i { background: var(--bad); animation: blink .5s steps(2) infinite; }
.pcard .think { position: absolute; top: -9px; right: 10px; background: var(--c); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 8px; font-family: var(--fun); display: none; }
.pcard.thinking .think { display: block; animation: bob .8s ease-in-out infinite; }
.pcard .emote-pop { position: absolute; left: 50%; top: -4px; transform: translate(-50%, -100%); animation: emote 2.4s cubic-bezier(.2,1.4,.4,1) both; pointer-events: none; z-index: 5; }
.pcard.yellow .sc { color: var(--yellow); }

.phase-tag {
  font-family: var(--fun); font-size: 15px; padding: 6px 16px; border-radius: 20px; background: rgba(0,0,0,.35); border: 1px solid var(--line2);
  display: flex; align-items: center; gap: 8px; min-height: 34px;
}
.phase-tag .pc { width: 12px; height: 12px; }
.phase-tag .ph-n { font-weight: 400; font-variant-numeric: tabular-nums; }
.phase-tag .ph-n small { font-size: .8em; color: var(--muted); }
.phase-tag .ph-sep { width: 1px; height: 14px; background: var(--line2); }
.phase-tag .ph-mv { display: inline-flex; align-items: center; gap: 4px; font-family: 'Noto Sans KR'; font-size: .92em; white-space: nowrap; }
.phase-tag .mt-wall { margin-left: 4px; }

.board-wrap { position: relative; width: var(--bsize); height: var(--bsize); }
.board-wrap svg { width: 100%; height: 100%; display: block; touch-action: manipulation; filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)); }
.board-wrap .banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 3;
  font-family: var(--title); font-size: clamp(30px, 9vw, 64px); color: #fff; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(0,0,0,.45), 0 0 30px rgba(0,0,0,.6); animation: banner 1.3s cubic-bezier(.2,.9,.3,1.2) both;
}

.actionbar { width: 100%; max-width: var(--bsize); display: flex; gap: 8px; justify-content: center; }
.act {
  flex: 1; max-width: 120px; height: 56px; border-radius: 16px; display: grid; place-items: center; gap: 0; padding-top: 4px;
  background: linear-gradient(180deg, #4b3221, #362317); border: 1px solid var(--line2); box-shadow: 0 3px 0 #1f140c;
  font-family: var(--fun); font-size: 12px; color: var(--muted); position: relative;
}
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 #1f140c; }
.act svg { width: 22px; height: 22px; color: var(--gold2); }
.act:disabled { opacity: .4; pointer-events: none; }
.act .cnt { position: absolute; top: 4px; right: 8px; font-size: 11px; background: var(--red); color: #fff; border-radius: 8px; padding: 0 6px; }
.emote-tray {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b));
  width: min(calc(100vw - 24px), 420px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px;
  background: linear-gradient(180deg, #4a3020, #2e1e13); border: 1px solid var(--line2); border-radius: 20px; box-shadow: var(--shadow);
  animation: up .2s ease both;
}
.emote-tray button { display: grid; place-items: center; padding: 4px 0; border-radius: 12px; transition: transform .1s; }
.emote-tray button:active { transform: scale(.9); }
.emote-tray .sticker.mini { font-size: 12px; padding-right: 8px; }

.side { display: none; }
/* 데스크탑: [플레이어] [단계·판] [버튼·기보] 3단, 양옆 패널은 판 높이에 맞춤 */
@media (min-width: 1000px) and (min-height: 600px) {
  .game {
    /* 상단바 57 + 여백 16 + 단계표시 36 + 간격 12 + 여유 */
    --bsize: min(calc(100dvh - 140px), 840px);
    --top: 48px;
    grid-template-columns: minmax(220px, 270px) var(--bsize) minmax(250px, 300px); grid-template-rows: auto auto minmax(0, 1fr);
    align-items: start; align-content: center; justify-content: center; column-gap: 28px; row-gap: 12px;
  }
  .game.replaying { --bsize: min(calc(100dvh - 196px), 840px); }
  .game .hud { grid-column: 1; grid-row: 1 / span 3; flex-direction: column; max-width: none; gap: 10px; margin-top: var(--top); }
  .game .hud .pcard { flex: none; padding: 14px 16px 14px 14px; gap: 12px; }
  .game .hud .pcard.active { transform: translateX(4px); }
  .game .hud .pcard .av { width: 52px; height: 52px; font-size: 28px; }
  .game .hud .pcard .nm { font-size: 18px; }
  .game .hud .pcard .meta { font-size: 12px; margin-top: 2px; }
  .game .hud .pcard .sc { font-size: 36px; }
  .game .center { grid-column: 2; grid-row: 1 / span 3; display: grid; gap: 12px; justify-items: center; }
  .game .actionbar { grid-column: 3; grid-row: 1; margin-top: var(--top); flex-wrap: wrap; justify-content: stretch; max-width: none; justify-self: stretch; }
  .game .actionbar .act { max-width: none; flex: 1 1 28%; height: 62px; font-size: 13px; }
  .game .emote-tray { grid-column: 3; grid-row: 2; justify-self: stretch; position: static; transform: none; width: auto; grid-template-columns: repeat(4, 1fr); animation: none; box-shadow: none; }
  /* 기보는 남은 높이를 채우고 안에서 스크롤 (height:0 + min-height:100% 로 내용이 행 높이를 늘리지 않게) */
  .game .side { display: flex; grid-column: 3; grid-row: 3; justify-self: stretch; align-self: stretch; height: 0; min-height: 100%; max-height: none; }
}
.game .center { display: grid; gap: 10px; justify-items: center; }
/* 기보 목록 */
.movelog { position: relative; flex-direction: column; padding: 0; overflow: auto; overscroll-behavior: contain; box-shadow: none; scrollbar-width: thin; scrollbar-color: rgba(233,196,140,.25) transparent; }
.movelog h4 {
  position: sticky; top: 0; z-index: 1; margin: 0; padding: 12px 16px 10px; display: flex; align-items: baseline; justify-content: space-between;
  font-family: var(--fun); font-weight: 400; color: var(--gold2); font-size: 17px; background: #3a271b; border-bottom: 1px solid var(--line);
}
.movelog h4 small { font-family: 'Noto Sans KR'; font-size: 12px; color: var(--dim); }
.movelog ol { list-style: none; margin: 0; padding: 6px; display: grid; gap: 1px; align-content: start; }
.movelog li {
  display: grid; grid-template-columns: 26px 12px 1fr; align-items: center; gap: 8px; padding: 6px 10px 6px 4px; border-radius: 10px;
  font-size: 14px; color: var(--cream); font-variant-numeric: tabular-nums; transition: background .15s, opacity .15s;
}
.movelog li:nth-child(even):not(.cur) { background: rgba(0,0,0,.12); }
.movelog li .n { font-size: 12px; color: var(--dim); text-align: right; }
.movelog li .pc { width: 12px; height: 12px; }
.movelog li .t { display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
.movelog li.place .t { color: var(--muted); }
.movelog li.cur { background: rgba(243,207,134,.16); box-shadow: inset 0 0 0 1px rgba(243,207,134,.5); }
.movelog li.cur .n { color: var(--gold2); font-weight: 700; }
.movelog li.future { opacity: .35; }
.movelog ol.jump li { cursor: pointer; }
.movelog ol.jump li:hover { background: rgba(255,255,255,.07); }
.mt-kind { font-size: 12px; color: var(--muted); margin: 0 2px; }
.mt-arrow { color: var(--dim); margin: 0 2px; }
.mt-wall { margin-left: auto; font-size: 12px; padding: 1px 8px; border-radius: 8px; background: rgba(0,0,0,.3); color: var(--gold2); }

/* SVG 보드 요소 */
.cell { transition: fill .35s; }
.cell.hit { cursor: pointer; }
.dot { pointer-events: none; animation: pop .25s ease both; }
.piece { transition: transform .34s cubic-bezier(.45,.05,.35,1); }
.piece.sel .halo { opacity: 1; }
.piece .halo { opacity: 0; transition: opacity .2s; }
.piece.can { cursor: pointer; }
.piece.can .pulse { animation: pulse 1.4s ease-in-out infinite; }
.piece.ghost { opacity: .45; }
.wall { transform-box: fill-box; transform-origin: center; }
.wall.fresh.h { animation: wallGrowH .34s cubic-bezier(.25,.8,.35,1) .3s both; }
.wall.fresh.v { animation: wallGrowV .34s cubic-bezier(.25,.8,.35,1) .3s both; }
.wall.fresh.now { animation-delay: 0s; }
.piece .body, .piece .pshadow { transform-box: fill-box; transform-origin: center; }
.piece.sel .body { transform: translateY(-6px) scale(1.08); transition: transform .18s; }
.piece.sel .pshadow { transform: scale(1.12); opacity: .6; transition: transform .18s; }
.piece.drop .body { animation: stoneDrop .26s cubic-bezier(.5,0,.75,0) both, squash .3s ease-out .2s; }
.piece.drop .pshadow { animation: shadowDrop .26s ease-in both; }
.piece.hop .body { animation: hop .34s ease-in-out both; }
.piece.hop .pshadow { animation: hopShadow .34s ease-in-out both; }
.ripple { transform-box: fill-box; transform-origin: center; animation: ripple .6s cubic-bezier(.2,.7,.3,1) both; }
.dust { animation: dust .5s cubic-bezier(.2,.7,.3,1) both; }
@keyframes stoneDrop { from { transform: translateY(-70px) scale(1.25); opacity: .2; } 70% { opacity: 1; } to { transform: none; } }
@keyframes squash { 0% { transform: scale(1.1, .88); } 45% { transform: scale(.96, 1.05); } 100% { transform: none; } }
@keyframes shadowDrop { from { transform: scale(.4); opacity: 0; } }
@keyframes hop { 0% { transform: none; } 45% { transform: translateY(-16px) scale(1.12); } 85% { transform: scale(1.06, .92); } 100% { transform: none; } }
@keyframes hopShadow { 45% { transform: scale(1.2) translateY(8px); opacity: .35; } }
/* 벽: 홈을 따라 가운데에서 양쪽으로 뻗어나가며 살짝 튕기고 정착 */
@keyframes wallGrowH { 0% { transform: scale(.05, .6); opacity: 0; } 25% { opacity: 1; } 60% { transform: scale(1.03, 1.12); } 100% { transform: none; } }
@keyframes wallGrowV { 0% { transform: scale(.6, .05); opacity: 0; } 25% { opacity: 1; } 60% { transform: scale(1.12, 1.03); } 100% { transform: none; } }
@keyframes ripple { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }
@keyframes dust { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
.wall.last { filter: drop-shadow(0 0 3px rgba(255,238,200,.85)); }
.wopt { cursor: pointer; }
.wopt .bar { animation: glow 1s ease-in-out infinite; }
.wopt:hover .bar { opacity: 1; }
.wopt.stay .bar { animation: none; opacity: .4; }
.wopt.stay:hover .bar { opacity: .85; }
.territory { transition: opacity .5s; }
.hint-mark { animation: pulse 1s ease-in-out infinite; pointer-events: none; }

/* ---------- 결과 ---------- */
.result { text-align: center; padding-top: 30px !important; overflow: visible; }
.result .big { font-family: var(--title); font-size: 64px; line-height: 1; margin: 0 0 8px; letter-spacing: 2px; animation: stamp .6s cubic-bezier(.2,1.6,.4,1) both; }
.result .big.win { color: var(--gold2); text-shadow: 0 4px 0 #8a5a24, 0 0 40px rgba(246,212,143,.5); }
.result .big.lose { color: #c9b9a6; text-shadow: 0 4px 0 #3a2618; }
.result .big.draw { color: #e7d6bd; text-shadow: 0 4px 0 #3a2618; }
.scorebars { display: grid; gap: 8px; margin: 18px 0; text-align: left; }
.sbar { display: grid; grid-template-columns: 34px 1fr 40px; align-items: center; gap: 10px; }
.sbar .av { width: 34px; height: 34px; font-size: 19px; }
.sbar .track { height: 18px; border-radius: 10px; background: rgba(0,0,0,.35); overflow: hidden; }
.sbar .track i { display: block; height: 100%; width: 0; border-radius: 10px; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.sbar b { font-family: var(--title); font-weight: 400; font-size: 22px; text-align: right; }
.rewards { display: grid; gap: 10px; background: rgba(0,0,0,.25); border-radius: 16px; padding: 14px; border: 1px solid var(--line); }
.rew-row { display: flex; justify-content: space-between; align-items: center; font-family: var(--fun); }
.rew-row .plus { color: var(--gold2); font-size: 20px; }
.rew-row .minus { color: var(--bad); font-size: 20px; }
.levelup { font-family: var(--title); color: var(--gold2); font-size: 28px; animation: stamp .6s cubic-bezier(.2,1.6,.4,1) .9s both; }

/* ---------- 기록 / 랭킹 ---------- */
.page { display: grid; gap: 14px; animation: rise .35s ease both; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.page-head h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 28px; color: var(--gold2); }
.rec-list { display: grid; gap: 8px; }
.rec {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; text-align: left;
  background: linear-gradient(180deg, rgba(63,42,29,.9), rgba(43,28,19,.9)); border: 1px solid var(--line);
}
.rec .res { font-family: var(--title); font-size: 18px; width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; }
.rec .res.win { background: linear-gradient(180deg, #f6d48f, #c98a3b); color: #3a210e; }
.rec .res.loss { background: rgba(0,0,0,.35); color: var(--muted); }
.rec .res.draw { background: #5a4636; color: var(--cream); }
.rec .t1 { font-family: var(--fun); font-size: 16px; display: flex; align-items: center; gap: 6px; }
.rec .t2 { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rec .sc { font-family: var(--title); font-size: 20px; text-align: right; }
.rec .sc small { display: block; font-family: 'Noto Sans KR'; font-size: 11px; color: var(--gold2); }
.empty { text-align: center; color: var(--dim); padding: 50px 0; font-family: var(--fun); font-size: 18px; }
.rank-row { display: grid; grid-template-columns: 40px 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; background: rgba(0,0,0,.2); border: 1px solid var(--line); }
.rank-row .n { font-family: var(--title); font-size: 20px; text-align: center; color: var(--muted); }
.rank-row:nth-child(1) .n { color: #f3cf86; font-size: 26px; }
.rank-row:nth-child(2) .n { color: #d6d9e0; font-size: 24px; }
.rank-row:nth-child(3) .n { color: #d39461; font-size: 22px; }
.rank-row .av { width: 40px; height: 40px; font-size: 22px; }
.rank-row.me { border-color: var(--gold); background: rgba(217,169,91,.1); }

.replay-ctl { display: flex; gap: 8px; align-items: center; width: var(--bsize); max-width: 100%; }
.replay-ctl input[type=range] { flex: 1; min-width: 0; accent-color: var(--gold); height: 30px; margin: 0 6px; }
.replay-ctl .btn { width: 48px; padding: 0; flex: none; }
.replay-ctl .btn svg { width: 20px; height: 20px; }
.btn.tog { color: var(--dim); }
.btn.tog.on { color: var(--gold2); border-color: var(--gold); background: linear-gradient(180deg, #5a3c24, #432c1a); }
.act.tog:not(.on) svg { color: var(--dim); }
.act.tog.on { border-color: var(--gold); }

/* ---------- 토스트 / 이펙트 ---------- */
#toastRoot { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 70px); z-index: 90; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { font-family: var(--fun); font-size: 16px; padding: 10px 18px; border-radius: 16px; background: rgba(28, 18, 11, .95); border: 1px solid var(--line2); box-shadow: var(--shadow); animation: toast 2.4s ease both; display: flex; align-items: center; gap: 8px; }
.toast.gold { background: linear-gradient(180deg, #f6d48f, #d39c47); color: #3a210e; border: 0; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(0); opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes ping { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes wallIn { from { transform: scale(.2, .2); opacity: 0; } }
@keyframes tfade { from { opacity: 0; } }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 75% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -60%) scale(1); opacity: 0; } }
@keyframes stamp { from { transform: scale(2.4); opacity: 0; } }
@keyframes toast { 0% { transform: translateY(-16px); opacity: 0; } 12%, 85% { transform: none; opacity: 1; } 100% { transform: translateY(-10px); opacity: 0; } }
@keyframes emote { 0% { transform: translate(-50%, -60%) scale(.2) rotate(-12deg); opacity: 0; } 14% { transform: translate(-50%, -112%) scale(1.15) rotate(4deg); opacity: 1; } 24% { transform: translate(-50%, -105%) scale(1) rotate(-3deg); } 82% { transform: translate(-50%, -110%) scale(1) rotate(-3deg); opacity: 1; } 100% { transform: translate(-50%, -140%) scale(.85) rotate(-3deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* 좁은 화면: 뒤로 버튼이 보일 땐 로고 글자를 숨겨 겹침 방지 */
.brand { min-width: 0; }
@media (max-width: 430px) {
  body:not([data-view="lobby"]) .brand-name { display: none; }
}

/* =====================================================================
   모바일 대국 레이아웃 — 판은 최대한 크게, 나머지는 작고 단단하게
   ===================================================================== */
.mode h3 { white-space: nowrap; }
@media (max-width: 400px) {
  .modes { gap: 10px; }
  .mode { padding: 14px; min-height: 132px; border-radius: 18px; }
  .mode h3 { font-size: clamp(19px, 6vw, 24px); }
  .mode p { font-size: 12px; }
  .mode .art { width: 96px; height: 96px; right: -14px; top: -14px; opacity: .7; }
  .mode.ai { min-height: 150px; }
  .mode.ai .art { width: 120px; height: 120px; opacity: .95; }
  .mode .badge { top: 10px; left: 12px; font-size: 11px; }
  .profile-card { padding: 14px; gap: 12px; }
  .pc-top .av { width: 54px; height: 54px; }
  .pc-name { font-size: 19px; }
  .stat { padding: 8px 4px; }
  .stat b { font-size: 17px; }
}

@media (max-width: 999px), (max-height: 599px) {
  /* 대국 중 상단바는 얇게 */
  body[data-view="game"] .topbar { padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 6px; }
  body[data-view="game"] .topbar .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
  body[data-view="game"] .brand-mark { width: 30px; height: 30px; }
  body[data-view="game"] .brand-name, body[data-view="game"] .online-dot { display: none; }
  body[data-view="game"] .me-chip { height: 34px; padding: 0 3px; }
  body[data-view="game"] .me-chip > span:not(.av) { display: none; }

  #view.full { padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + var(--safe-b)) max(6px, env(safe-area-inset-left, 0px)); justify-content: stretch; }
  .game {
    --chrome: calc(214px + env(safe-area-inset-top, 0px) + var(--safe-b));
    --bsize: min(calc(100vw - 12px), calc(100dvh - var(--chrome)), 760px);
    height: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0;
  }
  .game.replaying { --chrome: calc(268px + env(safe-area-inset-top, 0px) + var(--safe-b)); }
  .game .center { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
  .game .hud, .game .actionbar { flex: none; }

  .hud { gap: 6px; }
  .pcard { padding: 5px 8px 5px 5px; min-height: 50px; gap: 7px; border-radius: 14px; border-width: 2px; }
  .pcard.active { transform: none; }
  .pcard .av { width: 34px; height: 34px; border-width: 2px; }
  .pcard .nm { font-size: 13.5px; }
  .pcard .meta { font-size: 10.5px; gap: 4px; }
  .pcard .meta .pc { width: 10px; height: 10px; }
  .pcard .sc { font-size: 23px; min-width: 22px; }
  .pcard .think { top: -8px; font-size: 10px; }
  .hud:has(.pcard:nth-child(3)) .pcard .meta { display: none; }
  .hud:has(.pcard:nth-child(3)) .pcard .av { width: 28px; height: 28px; }
  .hud:has(.pcard:nth-child(3)) .pcard .sc { font-size: 20px; }

  .phase-tag { font-size: 13px; padding: 3px 12px; min-height: 28px; }
  .board-wrap svg { filter: drop-shadow(0 10px 18px rgba(0,0,0,.5)); }

  .actionbar { gap: 6px; }
  .act { height: 50px; max-width: none; border-radius: 14px; font-size: 11px; padding-top: 2px; }
  .act svg { width: 20px; height: 20px; }
  .act .cnt { top: 3px; right: 6px; }
  .replay-ctl .btn { height: 42px; width: 44px; }
}

/* 가로로 눕힌 휴대폰: [플레이어] [판] [버튼] 3단 */
@media (orientation: landscape) and (max-height: 599px) {
  .game {
    --side: clamp(128px, calc((100vw - (100dvh - 70px) - 48px) / 2), 210px);
    --bsize: min(calc(100dvh - 66px - env(safe-area-inset-top, 0px) - var(--safe-b)), calc(100vw - var(--side) * 2 - 40px));
    display: grid; grid-template-columns: var(--side) var(--bsize) var(--side); grid-template-rows: auto auto 1fr;
    justify-content: center; align-content: center; column-gap: 14px; row-gap: 8px; height: 100%;
  }
  .game.replaying { --bsize: min(calc(100dvh - 66px - env(safe-area-inset-top, 0px) - var(--safe-b)), calc(100vw - var(--side) * 2 - 40px)); }
  .game .center { display: contents; }
  .game .hud { grid-column: 1; grid-row: 1; flex-direction: column; max-width: none; width: 100%; }
  .game #phase { grid-column: 1; grid-row: 2; justify-self: stretch; justify-content: center; font-size: 12px; white-space: nowrap; overflow: hidden; }
  .game #bw { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .game .actionbar { grid-column: 3; grid-row: 1 / span 3; flex-direction: column; align-self: center; max-width: none; width: 100%; }
  .game .replay-ctl { grid-column: 1; grid-row: 3; flex-wrap: wrap; max-width: none; align-self: start; }
  .game .replay-ctl input[type=range] { flex-basis: 100%; order: 5; }
  .game .act { flex: none; height: 46px; }
  .pcard .meta { display: flex; }
}

/* 세로 폰: 플레이어·판을 한 덩어리로 가운데, 버튼은 엄지 닿는 하단 */
@media (max-width: 999px) and (orientation: portrait), (max-width: 999px) and (min-height: 600px) {
  .game .hud { margin-top: auto; }
  .game .center { flex: none; }
  .game .actionbar { margin-top: auto; }
}
/* 키 큰 폰은 남는 높이만큼 카드·버튼을 조금 키움 */
@media (max-width: 999px) and (min-height: 760px) {
  .pcard { min-height: 58px; padding: 6px 10px 6px 6px; }
  .pcard .av { width: 40px; height: 40px; }
  .pcard .nm { font-size: 15px; }
  .pcard .sc { font-size: 26px; }
  .phase-tag { font-size: 14px; min-height: 32px; }
  .act { height: 58px; font-size: 12px; }
  .act svg { width: 22px; height: 22px; }
  .game { gap: 10px; }
}

/* 팝업 하단 주 버튼은 항상 보이게 */
.sheet .actions.sticky-go {
  position: sticky; bottom: calc(-22px - var(--safe-b)); z-index: 2; margin: 18px -20px calc(-22px - var(--safe-b));
  padding: 14px 20px calc(16px + var(--safe-b));
  background: linear-gradient(180deg, rgba(44, 29, 19, 0), #2c1d13 30%);
}
@media (max-width: 400px), (max-height: 760px) {
  .levels { gap: 6px; }
  .level { padding: 7px 10px; gap: 10px; border-radius: 14px; }
  .level .av { width: 38px; height: 38px; }
  .level b { font-size: 15px; }
  .level small { font-size: 11px; }
  .level .stars { font-size: 11px; }
  .sheet .label { margin: 14px 2px 6px; }
  .sheet h2 { font-size: 23px; }
}

/* 3인 + 좁은 화면: 이름은 숨기고 캐릭터·점수만 크게 */
@media (max-width: 480px) {
  .hud:has(.pcard:nth-child(3)) .pcard { justify-content: center; gap: 8px; padding: 5px 8px; }
  .hud:has(.pcard:nth-child(3)) .pcard .info { display: none; }
  .hud:has(.pcard:nth-child(3)) .pcard .av { width: 34px; height: 34px; }
  .hud:has(.pcard:nth-child(3)) .pcard .sc { font-size: 24px; min-width: 0; }
}
@media (max-height: 500px) {
  .result { padding-top: 8px !important; }
  .result .big { font-size: 46px; }
  .scorebars { margin: 10px 0; }
}

/* 랭킹 */
.rank-page .page-head { align-items: baseline; flex-wrap: wrap; }
.rank-sub { font-size: 12px; color: var(--muted); }
.rank-row { grid-template-columns: 34px 40px 1fr auto; }
.rk-info { min-width: 0; display: grid; gap: 2px; }
.rk-info .t1 { font-family: var(--fun); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-info small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pts { font-family: var(--fun); color: var(--gold2); font-size: 13px; white-space: nowrap; }
.pts b { font-family: var(--title); font-weight: 400; font-size: 20px; margin-right: 2px; }
.gtag.me { color: var(--bg1); background: var(--gold); border-color: var(--gold); }
.my-rank {
  position: sticky; bottom: calc(10px + var(--safe-b)); margin-top: 12px; z-index: 5;
  border-radius: 16px; box-shadow: 0 -6px 24px rgba(0,0,0,.45);
}
.my-rank .rank-row { background: linear-gradient(180deg, #4d3322, #36241a); border: 2px solid var(--gold); }
.my-rank .btn.sm { height: 36px; font-size: 14px; }
@media (max-width: 400px) {
  .rank-row { grid-template-columns: 28px 34px 1fr auto; gap: 8px; padding: 9px 10px; }
  .rank-row .av { width: 34px; height: 34px; }
  .rk-info .t1 { font-size: 14px; }
  .tier { font-size: 12px; padding: 2px 8px; }
}

/* 로비 카드 그림: 잘리지 않게 카드 안쪽 우상단에 */
.mode .art { right: 12px; top: 12px; width: 104px; height: 104px; opacity: .95; }
.mode.ai .art { width: 124px; height: 124px; }
@media (max-width: 400px) {
  .mode .art { right: 8px; top: 8px; width: 80px; height: 80px; opacity: .9; }
  .mode.ai .art { width: 104px; height: 104px; }
}

/* 데스크탑 로비: 2열 정렬 (빈칸 없음) */
@media (min-width: 900px) {
  .modes { grid-template-columns: 1fr 1fr; }
  .mode.ai { grid-column: span 2; }
  .mode.records, .mode.rank { grid-column: auto; }
}

/* 세로 폰 · 남는 높이가 있으면 판 아래에 기보를 작게 (최근 수가 보이도록 자동 스크롤) */
@media (max-width: 999px) and (orientation: portrait) and (min-height: 760px) {
  .game .side { display: flex; order: 2; flex: 1 1 0; min-height: 0; max-height: 196px; width: 100%; max-width: var(--bsize); border-radius: 14px; }
  .game .actionbar { order: 3; }
  .movelog h4 { padding: 7px 12px 6px; font-size: 14px; }
  .movelog ol { padding: 4px; }
  .movelog li { padding: 4px 8px 4px 2px; font-size: 13px; gap: 6px; }
  .movelog li .pc { width: 10px; height: 10px; }
}
