/* ============================================================
   가로세로 낱말퀴즈 · FaCer World  -  밝은 보드게임 룩
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Jua&family=Noto+Sans+KR:wght@400;500;700;900&display=swap');

:root {
  --bg: #eaf5ff;
  --panel: #ffffff;
  --panel-2: #f2f6ff;
  --ink: #1f2a44;
  --muted: #6b7a99;
  --line: #dde6f6;
  --shadow: #c9d6ef;
  --blue: #3d7bff;
  --blue-d: #2755c7;
  --yellow: #ffc83d;
  --yellow-d: #dd9a00;
  --orange: #ff8a3d;
  --pink: #ff5c93;
  --pink-d: #cf3a6e;
  --green: #20c77a;
  --green-d: #12995a;
  --red: #f0483e;
  --purple: #9b6bff;
  --cell: #fffdf4;
  --cell-ink: #1f2a44;
  --cell-black: #2b4db8;
  --cell-active: #ffe57a;
  --cell-word: #d9ecff;
  --p0: #ff5c93; --p1: #2fa8f5; --p2: #20c77a; --p3: #9b6bff;
  --radius: 20px;
  --cell-size: 48px;
  --font-title: "Jua", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(800px 480px at 0% 0%, rgba(255, 200, 61, .28), transparent 60%),
    radial-gradient(800px 520px at 100% 0%, rgba(255, 92, 147, .20), transparent 60%),
    radial-gradient(1000px 600px at 50% 110%, rgba(32, 199, 122, .18), transparent 60%),
    linear-gradient(rgba(61, 123, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 123, 255, .06) 1px, transparent 1px);
  background-size: auto, auto, auto, 40px 40px, 40px 40px;
  background-attachment: fixed;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--font-title); font-weight: 400; letter-spacing: .3px; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: screenIn .35s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- 둥둥 떠다니는 배경 글자 ---------- */
.bg-letters { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-letters span { position: absolute; bottom: -80px; font-family: var(--font-title); font-size: 46px; color: var(--blue); opacity: 0; animation: floatUp linear infinite; }
@keyframes floatUp { 0% { transform: translateY(0) rotate(-8deg); opacity: 0; } 10% { opacity: .09; } 90% { opacity: .09; } 100% { transform: translateY(-110vh) rotate(10deg); opacity: 0; } }
#app { position: relative; z-index: 1; }

/* ---------- 상단바 ---------- */
.topbar, .playbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 38px; height: 38px; padding: 4px; background: linear-gradient(145deg, #5a93ff, var(--blue)); border-radius: 10px; box-shadow: 0 4px 0 var(--blue-d); }
.brand-mark i { background: #fff; border-radius: 3px; animation: tileBlink 3s infinite; }
.brand-mark i:nth-child(2) { animation-delay: .4s; } .brand-mark i:nth-child(3) { animation-delay: .8s; }
.brand-mark i.y { background: var(--yellow); animation-delay: 1.2s; }
@keyframes tileBlink { 0%, 90%, 100% { transform: scale(1); } 95% { transform: scale(.75); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--font-title); font-weight: 400; font-size: 20px; }
.brand-text small { color: var(--muted); font-size: 11px; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.userchip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 2px solid var(--line); background: #fff; border-radius: 999px; transition: transform .1s; }
.userchip:hover { transform: translateY(-1px); border-color: var(--blue); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(145deg, var(--pink), var(--orange)); color: #fff; display: grid; place-items: center; font-weight: 900; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.uinfo { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.uinfo b { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uinfo small { font-size: 11px; color: var(--blue); font-weight: 700; }
.iconbtn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-size: 14px; font-weight: 700; transition: transform .1s, border-color .15s; }
.iconbtn:hover { border-color: var(--blue); transform: translateY(-1px); }

/* ---------- 3D 게임 버튼 ---------- */
.btn {
  position: relative; padding: 10px 16px; border-radius: 14px; border: 0; font-weight: 800; font-size: 14px; color: var(--ink);
  background: #fff; box-shadow: 0 4px 0 var(--shadow), 0 6px 14px rgba(40, 70, 140, .12);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); }
.btn.primary { color: #4a3000; background: linear-gradient(180deg, #ffe07a, var(--yellow)); box-shadow: 0 4px 0 var(--yellow-d), 0 6px 14px rgba(255, 191, 31, .35); }
.btn.primary:active { box-shadow: 0 0 0 var(--yellow-d); }
.btn.vs { color: #fff; background: linear-gradient(180deg, #ff7fab, var(--pink)); box-shadow: 0 4px 0 var(--pink-d), 0 6px 14px rgba(255, 92, 147, .35); }
.btn.vs:active { box-shadow: 0 0 0 var(--pink-d); }
.btn.blue { color: #fff; background: linear-gradient(180deg, #6a9bff, var(--blue)); box-shadow: 0 4px 0 var(--blue-d), 0 6px 14px rgba(61, 123, 255, .35); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); color: var(--muted); }
.btn.ghost:active { transform: translateY(1px); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.big { padding: 14px 24px; font-size: 17px; border-radius: 18px; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
.btn.big small { font-weight: 500; opacity: .8; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- 공통 레이아웃 ---------- */
.lobby-body { max-width: 1120px; margin: 0 auto; padding: 22px 16px 60px; }
.card { background: var(--panel); border-radius: 22px; padding: 18px 20px; box-shadow: 0 6px 0 var(--shadow), 0 14px 30px rgba(40, 70, 140, .10); animation: cardIn .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.card h2 { margin: 0 0 12px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
@keyframes cardIn { from { transform: translateY(26px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.section-title { font-size: 22px; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 2px; background: linear-gradient(90deg, var(--line), transparent); margin-left: 8px; }

/* ---------- 메인 화면 ---------- */
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 30px; padding: 30px; border-radius: 30px; overflow: clip;
  background: linear-gradient(135deg, #ffffff 0%, #e8f2ff 55%, #fff3d6 100%); border: 3px solid #fff; box-shadow: 0 8px 0 var(--shadow), 0 24px 50px rgba(40, 70, 140, .16); }
.hero::before { content: ""; position: absolute; right: -120px; top: -160px; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 61, .45), transparent 65%); pointer-events: none; }
.hero-text { position: relative; min-width: 0; }
.title-tiles { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; }
.title-tiles .t { font-family: var(--font-title); font-size: 38px; line-height: 1; width: 54px; height: 54px; display: grid; place-items: center; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 5px 0 var(--shadow), 0 10px 18px rgba(40, 70, 140, .18);
  animation: tileIn .6s cubic-bezier(.2, 1.6, .4, 1) both, bob 3s ease-in-out infinite; animation-delay: calc(var(--i) * 70ms), calc(var(--i) * 150ms + .6s); }
.title-tiles .t.gap { width: 14px; background: transparent; box-shadow: none; animation: none; }
.title-tiles .t.y { background: var(--yellow); box-shadow: 0 5px 0 var(--yellow-d), 0 10px 18px rgba(40, 70, 140, .18); }
.title-tiles .t.b { background: var(--blue); color: #fff; box-shadow: 0 5px 0 var(--blue-d), 0 10px 18px rgba(40, 70, 140, .18); }
.title-tiles .t.p { background: var(--pink); color: #fff; box-shadow: 0 5px 0 var(--pink-d), 0 10px 18px rgba(40, 70, 140, .18); }
.title-tiles .t.g { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-d), 0 10px 18px rgba(40, 70, 140, .18); }
@keyframes tileIn { from { transform: translateY(-40px) rotate(-12deg) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.tagline { margin: 0 0 18px; color: var(--muted); font-size: 15px; font-weight: 500; }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 560px; }
.mode-card { --c: var(--blue); --d: var(--blue-d); position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 18px 18px 16px; border: 0; border-radius: 22px; color: #fff; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c)); box-shadow: 0 7px 0 var(--d), 0 16px 28px color-mix(in srgb, var(--c) 40%, transparent);
  transition: transform .15s cubic-bezier(.2, 1.4, .4, 1), box-shadow .15s; animation: cardIn .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.mode-card.versus { --c: var(--pink); --d: var(--pink-d); animation-delay: .1s; }
.mode-card::after { content: ""; position: absolute; right: -34px; bottom: -34px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, .2); transition: transform .3s; }
.mode-card:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 13px 0 var(--d), 0 24px 36px color-mix(in srgb, var(--c) 45%, transparent); }
.mode-card:hover::after { transform: scale(1.5); }
.mode-card:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--d); }
.mode-card .mi { font-size: 40px; line-height: 1; margin-bottom: 6px; transition: transform .3s cubic-bezier(.2, 1.6, .4, 1); }
.mode-card:hover .mi { transform: scale(1.2) rotate(-10deg); }
.mode-card b { font-family: var(--font-title); font-weight: 400; font-size: 26px; position: relative; z-index: 1; }
.mode-card small { font-size: 13px; opacity: .92; position: relative; z-index: 1; }
.mode-card em { margin-top: 10px; font-style: normal; font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, .25); padding: 3px 10px; border-radius: 99px; position: relative; z-index: 1; }
.hero .btn.big { margin-top: 16px; flex-direction: row; gap: 8px; align-items: baseline; }

/* 데모 보드 */
.demo { --dc: 40px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.demo-tag { position: absolute; top: -12px; left: -10px; z-index: 2; font-family: var(--font-title); font-size: 13px; letter-spacing: 1px; color: #fff; background: var(--red); padding: 3px 12px; border-radius: 99px; transform: rotate(-6deg); box-shadow: 0 3px 0 #b02c24; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.demo-board { display: grid; grid-template-columns: repeat(7, var(--dc)); grid-auto-rows: var(--dc); gap: 3px; padding: 10px; border-radius: 18px; background: linear-gradient(160deg, #5a8dff, var(--blue)); box-shadow: 0 8px 0 var(--blue-d), 0 20px 40px rgba(61, 123, 255, .35); transform: rotate(2deg); animation: demoFloat 5s ease-in-out infinite; perspective: 600px; }
@keyframes demoFloat { 0%, 100% { transform: rotate(2deg) translateY(0); } 50% { transform: rotate(1deg) translateY(-8px); } }
.dcell { position: relative; background: var(--cell); border-radius: 5px; display: grid; place-items: center; font-weight: 900; font-size: calc(var(--dc) * .52); color: var(--cell-ink); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1); transition: background .15s; }
.dcell.black { background: var(--cell-black); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25); }
.dcell .num { position: absolute; top: 1px; left: 3px; font-size: 9px; font-weight: 700; color: #8a93ad; }
.dcell.word { background: var(--cell-word); }
.dcell.cur { background: var(--cell-active); box-shadow: inset 0 0 0 3px var(--orange); }
.dcell.pop span.ch { display: inline-block; animation: pop .25s cubic-bezier(.2, 1.8, .4, 1); }
.dcell.done { color: #fff; animation: flip .6s cubic-bezier(.3, 1.2, .4, 1) both; animation-delay: var(--d, 0ms); }
.dcell.done .num { color: rgba(255, 255, 255, .8); }
.dcell.c0 { background: var(--p0); } .dcell.c1 { background: var(--p1); } .dcell.c2 { background: var(--p2); } .dcell.c3 { background: var(--p3); }
.demo-clue { width: calc(7 * var(--dc) + 38px); display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 14px; padding: 9px 12px; min-height: 46px; font-size: 13px; font-weight: 700; box-shadow: 0 4px 0 var(--shadow); }
.demo-clue #demo-num { font-family: var(--font-title); color: #fff; background: var(--orange); padding: 1px 9px; border-radius: 8px; white-space: nowrap; font-size: 14px; }

.home-grid { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 16px; margin-top: 22px; align-items: start; }
.me-card .me-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.me-card .me-top .avatar { width: 52px; height: 52px; font-size: 24px; font-family: var(--font-title); }
.me-card .me-top b { display: block; font-size: 17px; }
.me-card .me-top small { color: var(--blue); font-weight: 700; font-size: 12px; }
.statrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 10px; }
.statrow div { background: var(--panel-2); border-radius: 14px; padding: 10px; text-align: center; }
.statrow small { display: block; color: var(--muted); font-size: 12px; }
.statrow b { font-family: var(--font-title); font-weight: 400; font-size: 24px; color: var(--blue); }
.expbar { position: relative; height: 16px; background: #e3eaf8; border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 3px rgba(40, 70, 140, .15); }
.expbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--yellow), var(--orange), var(--yellow)); transition: width .8s cubic-bezier(.2, .9, .3, 1.2); background-size: 200% 100%; animation: shimmer 2s linear infinite; border-radius: 999px; }
@keyframes shimmer { from { background-position: 0 0; } to { background-position: 200% 0; } }
.expbar em { position: absolute; right: 10px; top: 0; font-size: 11px; line-height: 16px; font-style: normal; color: var(--ink); font-weight: 700; }
.me-card .note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.me-card .note a { font-weight: 700; }
.rank-card h2 .rank-mini-tabs { margin-left: auto; display: flex; gap: 4px; }
.rank-mini-tabs button { font-family: "Noto Sans KR", sans-serif; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; border: 0; background: var(--panel-2); color: var(--muted); }
.rank-mini-tabs button.active { background: var(--blue); color: #fff; }
.home-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.home-rank li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: var(--panel-2); font-size: 14px; animation: cardIn .4s both; animation-delay: calc(var(--i) * 50ms); }
.home-rank li:nth-child(1) { background: linear-gradient(90deg, #fff1bf, #fff8e0); }
.home-rank li:nth-child(2) { background: linear-gradient(90deg, #e9eef7, #f6f8fc); }
.home-rank li:nth-child(3) { background: linear-gradient(90deg, #ffe3cf, #fff3ea); }
.home-rank li.me { box-shadow: inset 0 0 0 2px var(--blue); }
.home-rank .rk { width: 28px; text-align: center; font-family: var(--font-title); font-size: 17px; color: var(--muted); }
.home-rank .nm { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-rank .lv { font-size: 11px; font-weight: 800; color: #fff; background: var(--blue); padding: 1px 7px; border-radius: 99px; }
.home-rank .val { font-family: var(--font-title); font-size: 17px; color: var(--orange); }
.home-rank li.empty { background: transparent; color: var(--muted); justify-content: center; padding: 34px 0; text-align: center; }
.rank-card .btn { margin-top: 12px; }
.how-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.how-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.how-list .hi { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; background: var(--panel-2); }
.how-list b { display: block; font-size: 14px; }
.how-list span { color: var(--muted); }
.foot { margin-top: 36px; display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ad-box { margin-top: 26px; min-height: 90px; display: flex; justify-content: center; }

/* ---------- 싱글: 주제 / 퍼즐 고르기 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; }
.cat-card { --c: var(--blue); position: relative; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; border: 0; border-radius: 20px; overflow: hidden; color: var(--ink);
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 30%, #fff) 0%, #fff 70%); box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 45%, var(--shadow)), 0 12px 24px rgba(40, 70, 140, .10);
  transition: transform .15s cubic-bezier(.2, 1.4, .4, 1), box-shadow .15s; animation: cardIn .5s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * 45ms); }
.cat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--c); opacity: .22; transition: transform .3s; }
.cat-card:hover { transform: translateY(-6px) rotate(-1deg); }
.cat-card:hover::after { transform: scale(1.6); }
.cat-card:active { transform: translateY(3px); }
.cat-card.active { outline: 4px solid var(--c); outline-offset: -4px; }
.cat-card .ic { font-size: 38px; width: 60px; height: 60px; display: grid; place-items: center; background: #fff; border-radius: 16px; position: relative; z-index: 1; box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 40%, #fff); transition: transform .3s cubic-bezier(.2, 1.6, .4, 1); }
.cat-card:hover .ic { transform: scale(1.15) rotate(-8deg); }
.cat-card b { display: block; font-family: var(--font-title); font-weight: 400; font-size: 20px; position: relative; z-index: 1; }
.cat-card small { display: block; color: var(--muted); font-size: 12px; position: relative; z-index: 1; }
.cat-card .prog { margin-top: 6px; height: 8px; background: #e3eaf8; border-radius: 99px; overflow: hidden; position: relative; z-index: 1; }
.cat-card .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #7be8b4); width: 0; transition: width .8s; }
.cat-card .cnt { font-weight: 800; color: var(--green-d); }
.puzzle-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.level-tabs { display: flex; gap: 8px; }
.level-tabs button { padding: 8px 16px; border-radius: 999px; border: 0; background: #fff; font-weight: 800; color: var(--muted); box-shadow: 0 3px 0 var(--shadow); transition: transform .1s; }
.level-tabs button:hover { transform: translateY(-2px); }
.level-tabs button.active { background: linear-gradient(180deg, #6a9bff, var(--blue)); color: #fff; box-shadow: 0 3px 0 var(--blue-d); }
.level-tabs button .stars { color: var(--yellow-d); margin-right: 4px; letter-spacing: -2px; }
.level-tabs button.active .stars { color: #ffe9a0; }
.puzzle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pz-card { position: relative; text-align: left; padding: 14px 14px 12px; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: 0 5px 0 var(--shadow), 0 10px 20px rgba(40, 70, 140, .08);
  display: flex; flex-direction: column; gap: 3px; transition: transform .15s cubic-bezier(.2, 1.4, .4, 1); animation: cardIn .45s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * 40ms); overflow: hidden; }
.pz-card:hover { transform: translateY(-5px) scale(1.03); }
.pz-card:active { transform: translateY(3px); }
.pz-card .no { font-family: var(--font-title); font-size: 34px; line-height: 1; color: var(--blue); }
.pz-card small { color: var(--muted); font-size: 12px; }
.pz-card .mark { position: absolute; top: 10px; right: 10px; font-size: 12px; font-weight: 800; color: #fff; background: var(--green); padding: 3px 9px; border-radius: 99px; box-shadow: 0 2px 0 var(--green-d); animation: stamp .4s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes stamp { from { transform: scale(2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.pz-card .mark.prog { color: #4a3000; background: var(--yellow); box-shadow: 0 2px 0 var(--yellow-d); }
.pz-card.done { background: linear-gradient(180deg, #e8fbf1, #fff); box-shadow: 0 5px 0 #b5e8cf, 0 10px 20px rgba(40, 70, 140, .08); }
.pz-card.done .no { color: var(--green-d); }
.pz-card .stars { color: var(--yellow); font-size: 14px; letter-spacing: 1px; }
.pz-card .stars .off { color: #dfe5f1; }

/* ---------- 플레이 ---------- */
.playbar .play-title { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; flex: 1; }
.playbar .play-title b { font-family: var(--font-title); font-weight: 400; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playbar .play-title small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-right { display: flex; align-items: center; gap: 8px; }
.timer { font-family: var(--font-title); font-variant-numeric: tabular-nums; font-size: 22px; background: var(--ink); color: var(--yellow); padding: 3px 12px; border-radius: 10px; letter-spacing: 2px; box-shadow: 0 3px 0 #0e1630; }
.timer.hurry { color: #fff; background: var(--red); box-shadow: 0 3px 0 #b02c24; animation: bump .6s infinite; }
.chip { font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: #fff; border: 2px solid var(--line); transition: transform .2s; }
.chip.bump { animation: bump .4s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes bump { 50% { transform: scale(1.25); } }
.chip.exp { background: #fff6d6; border-color: #f3d98a; color: #8a5a00; }
.chip.code b { color: var(--blue); letter-spacing: 2px; }

.play-body { display: grid; grid-template-columns: minmax(0, auto) minmax(260px, 370px); gap: 20px; max-width: 1100px; margin: 0 auto; padding: 18px 16px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 12px; align-items: center; min-width: 0; }
.board-wrap { position: relative; animation: boardIn .5s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes boardIn { from { transform: scale(.85) rotateX(20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.board {
  display: grid; gap: 3px; padding: 10px; border-radius: 18px;
  background: linear-gradient(160deg, #5a8dff, var(--blue)); box-shadow: 0 8px 0 var(--blue-d), 0 20px 40px rgba(61, 123, 255, .30), inset 0 2px 0 rgba(255, 255, 255, .35);
  grid-template-columns: repeat(var(--n), var(--cell-size)); grid-auto-rows: var(--cell-size); touch-action: manipulation; perspective: 600px;
}
.cell { position: relative; background: var(--cell); color: var(--cell-ink); border-radius: 5px; display: grid; place-items: center; font-size: calc(var(--cell-size) * .52); font-weight: 900; user-select: none; -webkit-user-select: none; cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .10); transition: background .12s, transform .12s; transform-style: preserve-3d; animation: cellIn .4s both; animation-delay: calc(var(--i) * 6ms); }
@keyframes cellIn { from { transform: scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
.cell.black { background: var(--cell-black); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25); cursor: default; }
.cell .num { position: absolute; top: 1px; left: 3px; font-size: calc(var(--cell-size) * .24); font-weight: 700; color: #8a93ad; line-height: 1; }
.cell .ch { display: inline-block; }
.cell.word { background: var(--cell-word); }
.cell.active { background: var(--cell-active); box-shadow: inset 0 0 0 3px var(--orange), 0 0 14px rgba(255, 138, 61, .7); animation: activePulse 1.2s ease-in-out infinite; z-index: 2; }
@keyframes activePulse { 0%, 100% { box-shadow: inset 0 0 0 3px var(--orange), 0 0 8px rgba(255, 138, 61, .5); } 50% { box-shadow: inset 0 0 0 3px var(--orange), 0 0 20px rgba(255, 138, 61, .95); } }
.cell.locked { background: #b9f2d2; color: #0b6b3b; }
.cell.locked .num { color: #4d9a70; }
.cell.locked.word { background: #8fe6b6; }
.cell.locked.active { box-shadow: inset 0 0 0 3px var(--green-d); }
.cell.wrong { background: #ffd4d1; color: var(--red); animation: shake .4s; }
.cell.hint { color: #b06a00; }
.cell.composing { color: var(--blue); }
.cell.pop .ch { animation: pop .25s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pop { 0% { transform: scale(.3); } 100% { transform: scale(1); } }
.cell.flip { animation: flip .6s cubic-bezier(.3, 1.2, .4, 1) both; animation-delay: var(--d, 0ms); }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px) rotate(-3deg); } 40% { transform: translateX(5px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
#kbd { position: absolute; width: 2px; height: 2px; opacity: 0.01; border: 0; padding: 0; margin: 0; left: 0; top: 0; font-size: 16px; }

.current-clue { width: 100%; max-width: calc(var(--n) * (var(--cell-size) + 3px) + 20px); display: flex; align-items: center; gap: 12px; background: #fff; color: var(--ink); border-radius: 16px; padding: 12px 14px; min-height: 56px;
  box-shadow: 0 5px 0 var(--shadow), 0 10px 20px rgba(40, 70, 140, .10); }
.current-clue.swap { animation: clueSwap .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes clueSwap { 0% { transform: translateX(-14px); opacity: .3; } 100% { transform: none; opacity: 1; } }
.cc-num { font-family: var(--font-title); font-size: 18px; color: #fff; background: var(--orange); padding: 2px 10px; border-radius: 8px; white-space: nowrap; box-shadow: 0 3px 0 #c9621f; }
.cc-text { flex: 1; font-size: 16px; font-weight: 700; }
.cc-dir { border: 0; background: var(--blue); color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 18px; box-shadow: 0 3px 0 var(--blue-d); }
.cc-dir:active { transform: translateY(3px); box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.clues-col { background: var(--panel); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 120px); position: sticky; top: 74px; box-shadow: 0 6px 0 var(--shadow), 0 14px 30px rgba(40, 70, 140, .10); animation: cardIn .5s .15s both; }
.clue-tabs { display: flex; background: var(--panel-2); padding: 6px; gap: 6px; }
.clue-tabs button { flex: 1; padding: 10px; border: 0; border-radius: 12px; background: transparent; font-family: var(--font-title); font-size: 17px; color: var(--muted); transition: background .15s, color .15s; }
.clue-tabs button.active { background: #fff; color: var(--blue); box-shadow: 0 3px 0 var(--shadow); }
.clue-lists { overflow: auto; flex: 1; min-height: 120px; }
.clue-list { list-style: none; margin: 0; padding: 8px; }
.clue-list[hidden] { display: none; }
.clue-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 12px; cursor: pointer; font-size: 14px; transition: background .12s, transform .12s; }
.clue-list li:hover { background: var(--panel-2); transform: translateX(3px); }
.clue-list li b { font-family: var(--font-title); font-weight: 400; color: #4a3000; background: var(--yellow); min-width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.clue-list li em { font-style: normal; color: var(--muted); font-size: 12px; }
.clue-list li.active { background: #fff1dc; box-shadow: inset 0 0 0 2px var(--orange); }
.clue-list li.done { color: var(--muted); }
.clue-list li.done b { background: var(--green); color: #fff; }
.clue-list li.done span { text-decoration: line-through; }
.clue-list li.done::after { content: "✔"; color: var(--green-d); margin-left: auto; animation: stamp .4s both; }
.clue-list li .owner { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 99px; color: #fff; white-space: nowrap; display: none; }
/* 좌우 광고 레일 (폭 300). body.rails 일 때만 보이고, 본문은 그만큼 안쪽으로 */
.ad-rail { display: none; position: fixed; top: 0; bottom: 0; width: 300px; z-index: 5; overflow: hidden; padding-top: 76px; }
.ad-rail.left { left: 12px; } .ad-rail.right { right: 12px; }
.ad-rail .adsbygoogle { display: block; width: 300px; }
.ad-rail .ad-ph { height: min(1000px, calc(100vh - 100px)); border: 2px dashed var(--shadow); border-radius: 16px; display: grid; place-items: center; color: var(--muted); font-weight: 700; background: rgba(255, 255, 255, .5); }
body.rails .ad-rail { display: block; }
body.rails #app { margin: 0 324px; }
body.rails .bg-letters { left: 324px; right: 324px; }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; background: rgba(31, 42, 68, .45); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
#modal-ranking, #modal-nick, #modal-confirm, #modal-help { z-index: 60; }
.modal-card { background: #fff; border-radius: 26px; width: min(540px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 8px 0 var(--shadow), 0 30px 80px rgba(31, 42, 68, .35); position: relative; animation: modalPop .4s cubic-bezier(.2, 1.5, .4, 1); }
.modal-card.small { width: min(400px, 100%); }
@keyframes modalPop { from { transform: scale(.6) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2, .modal-card h2 { margin: 0; font-size: 24px; }
.close { border: 0; background: var(--panel-2); width: 34px; height: 34px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--muted); }
.close:hover { background: var(--line); color: var(--ink); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; justify-content: center; }
.modal-card input[type=text], .vs-join input { padding: 12px 14px; border: 0; border-radius: 12px; font-size: 16px; background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.modal-card input[type=text] { width: 100%; margin-top: 8px; }
.modal-card input[type=text]:focus, .vs-join input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }
.result { text-align: center; overflow: hidden; }
.result h2 { font-size: 34px; margin-top: 10px; animation: bounceIn .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.result .trophy { font-size: 64px; line-height: 1; display: block; animation: trophy 1.2s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes trophy { 0% { transform: scale(0) rotate(-30deg); } 60% { transform: scale(1.3) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes bounceIn { from { transform: scale(.5); opacity: 0; } }
.result-title { font-weight: 700; margin: 4px 0 16px; color: var(--muted); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-stats div { background: var(--panel-2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; animation: cardIn .5s both; animation-delay: calc(var(--i) * 120ms + .3s); }
.result-stats small { color: var(--muted); font-size: 12px; }
.result-stats b { font-family: var(--font-title); font-weight: 400; font-size: 28px; color: var(--blue); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 3px; animation: fall 2.2s cubic-bezier(.3, .1, .6, 1) forwards; }
@keyframes fall { to { transform: translateY(520px) rotate(720deg); opacity: 0; } }
.rank-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.rank-tabs button { padding: 7px 14px; border-radius: 999px; border: 0; background: var(--panel-2); color: var(--muted); font-weight: 700; }
.rank-tabs button.active { background: var(--blue); color: #fff; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank-table th, .rank-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rank-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.rank-table tr { animation: cardIn .4s both; }
.rank-table tr.me { background: #eaf1ff; font-weight: 800; color: var(--blue-d); }
.rank-table td.r { text-align: right; font-variant-numeric: tabular-nums; }
.rank-table td.medal { font-size: 18px; }
.help-body ol { padding-left: 20px; }
.help-body li { margin-bottom: 10px; font-size: 14px; }
.help-body b { color: var(--blue-d); }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 800; z-index: 70; box-shadow: 0 4px 0 #0e1630, 0 10px 24px rgba(31, 42, 68, .35); animation: toastIn .35s cubic-bezier(.2, 1.6, .4, 1); max-width: 90vw; text-align: center; }
@keyframes toastIn { from { transform: translateX(-50%) translateY(30px) scale(.8); opacity: 0; } }

/* ---------- 대전 로비 ---------- */
.vs-panel { padding: 22px 24px; border-radius: 24px; background: linear-gradient(135deg, #fff0f5, #eef5ff); border: 3px solid #fff; box-shadow: 0 6px 0 var(--shadow), 0 14px 30px rgba(40, 70, 140, .10); animation: cardIn .4s cubic-bezier(.2, 1.4, .4, 1); }
.vs-panel .section-title { margin-top: 0; }
.vs-rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.vs-rules div { background: #fff; border-radius: 16px; padding: 12px; font-size: 13px; color: var(--muted); box-shadow: 0 3px 0 var(--shadow); }
.vs-rules b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.vs-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.vs-join { display: flex; gap: 6px; margin-left: auto; }
.vs-join input { width: 130px; padding: 9px 12px; font-size: 15px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; background: #fff; }
.vs-sub { font-family: var(--font-title); font-weight: 400; font-size: 18px; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.room-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.room-item { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border: 0; border-radius: 16px; background: #fff; color: var(--ink); box-shadow: 0 4px 0 var(--shadow); transition: transform .12s; animation: cardIn .4s both; animation-delay: calc(var(--i) * 40ms); }
.room-item:hover { transform: translateY(-3px); }
.room-item .ic { font-size: 26px; }
.room-item .ri { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-item .ri b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .ri small { color: var(--muted); font-size: 12px; }
.room-item .rp { font-family: var(--font-title); color: var(--pink); font-size: 17px; }
.room-item .btn.small { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--pink-d); }
.fld { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.fld select { padding: 8px 10px; border: 0; border-radius: 10px; background: var(--panel-2); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--line); }
.fld.chk { justify-content: flex-start; border: 0; }
.fld input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); }

/* 대기실 */
.room-body { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.room-card { background: #fff; border-radius: 26px; padding: 26px; text-align: center; box-shadow: 0 8px 0 var(--shadow), 0 20px 40px rgba(40, 70, 140, .14); animation: cardIn .5s both; }
.room-code-big { font-family: var(--font-title); font-size: 56px; letter-spacing: 10px; color: var(--blue); text-shadow: 0 4px 0 #d5e3ff; animation: bob 3s ease-in-out infinite; }
.room-tools { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 18px; }
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.slot { --c: var(--p0); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; border-radius: 18px; background: var(--panel-2); border: 2px dashed var(--line); }
.slot.own-0 { --c: var(--p0); } .slot.own-1 { --c: var(--p1); } .slot.own-2 { --c: var(--p2); } .slot.own-3 { --c: var(--p3); }
.slot.filled { border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); animation: slotIn .5s cubic-bezier(.2, 1.6, .4, 1); }
.slot.me { box-shadow: 0 0 0 4px rgba(255, 200, 61, .7); }
@keyframes slotIn { from { transform: scale(.6); opacity: 0; } }
.slot .av { width: 46px; height: 46px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-family: var(--font-title); font-size: 22px; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 70%, #000); }
.slot .av.empty { background: #dfe6f3; color: var(--muted); box-shadow: none; animation: pulse 1.5s infinite; }
.slot b { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot small { color: var(--muted); font-size: 11px; }
.room-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.room-actions p { margin: 0; font-size: 13px; }

/* 대전 플레이 */
.vs-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: calc(var(--n) * (var(--cell-size) + 3px) + 20px); }
.vp { --c: var(--p0); display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px; border-radius: 999px; background: #fff; border: 3px solid var(--c); font-size: 13px; transition: transform .2s; box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 45%, #fff); }
.vp.own-0 { --c: var(--p0); } .vp.own-1 { --c: var(--p1); } .vp.own-2 { --c: var(--p2); } .vp.own-3 { --c: var(--p3); }
.vp.me { background: color-mix(in srgb, var(--c) 14%, #fff); }
.vp.lead { transform: scale(1.06); }
.vp.lead .sc::after { content: " 👑"; }
.vp .av { width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 13px; }
.vp .nm { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.vp .sc { font-family: var(--font-title); font-size: 19px; color: var(--c); }
.vp small { color: var(--muted); font-size: 11px; }
.screen.vs .actions #btn-check, .screen.vs .actions #btn-hint-letter, .screen.vs .actions #btn-hint-word, .screen.vs .actions #btn-clear, .screen.vs .actions #btn-prank, .screen.vs #hint-chip, .screen.vs #exp-chip { display: none; }
.cell.own-0, .cell.own-1, .cell.own-2, .cell.own-3 { color: #fff; }
.cell.own-0 { background: var(--p0); } .cell.own-1 { background: var(--p1); } .cell.own-2 { background: var(--p2); } .cell.own-3 { background: var(--p3); }
.cell.own-0 .num, .cell.own-1 .num, .cell.own-2 .num, .cell.own-3 .num { color: rgba(255, 255, 255, .8); }
.cell.mine { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8), inset 0 -3px 0 rgba(0, 0, 0, .12); }
.cell.own-0.active, .cell.own-1.active, .cell.own-2.active, .cell.own-3.active { animation: none; }
.clue-list li.own-0 .owner, .clue-list li.own-1 .owner, .clue-list li.own-2 .owner, .clue-list li.own-3 .owner { display: inline-block; }
.clue-list li.own-0 .owner { background: var(--p0); } .clue-list li.own-1 .owner { background: var(--p1); } .clue-list li.own-2 .owner { background: var(--p2); } .clue-list li.own-3 .owner { background: var(--p3); }
.screen.vs .clue-list li.done::after { content: none; }
.screen.vs .clue-list li.own-0 b { background: var(--p0); color: #fff; } .screen.vs .clue-list li.own-1 b { background: var(--p1); color: #fff; } .screen.vs .clue-list li.own-2 b { background: var(--p2); color: #fff; } .screen.vs .clue-list li.own-3 b { background: var(--p3); color: #fff; }

/* 대전 결과 */
.vs-rank { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.vs-rank li { --c: var(--p0); display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--panel-2); border-left: 6px solid var(--c); animation: cardIn .45s both; }
.vs-rank li:nth-child(1) { animation-delay: .2s; } .vs-rank li:nth-child(2) { animation-delay: .35s; } .vs-rank li:nth-child(3) { animation-delay: .5s; } .vs-rank li:nth-child(4) { animation-delay: .65s; }
.vs-rank li.own-0 { --c: var(--p0); } .vs-rank li.own-1 { --c: var(--p1); } .vs-rank li.own-2 { --c: var(--p2); } .vs-rank li.own-3 { --c: var(--p3); }
.vs-rank li.me { background: #fff6d6; }
.vs-rank .rk { font-size: 22px; width: 32px; text-align: center; font-family: var(--font-title); }
.vs-rank .av { width: 32px; height: 32px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 900; }
.vs-rank .nm { flex: 1; font-weight: 700; }
.vs-rank b { font-family: var(--font-title); font-weight: 400; font-size: 20px; color: var(--blue); }
.vs-rank small { color: var(--muted); }

/* ---------- 반응형 ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; justify-items: center; }
  .hero-text { width: 100%; }
  .home-grid { grid-template-columns: 1fr 1fr; }
  .home-grid .rank-card { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 860px) {
  .play-body { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .clues-col { position: static; max-height: 45vh; }
  :root { --cell-size: min(48px, calc((100vw - 40px - (var(--n) - 1) * 3px) / var(--n))); }
  .current-clue { position: sticky; top: 60px; z-index: 10; max-width: none; }
}
@media (max-width: 600px) {
  .topbar-right .iconbtn span, .playbar .iconbtn span { display: none; }
  .uinfo small { display: none; }
  .hero { padding: 20px 16px; border-radius: 24px; gap: 22px; }
  .title-tiles { gap: 4px; flex-wrap: nowrap; }
  .title-tiles .t { font-size: min(23px, 6vw); width: min(32px, 8.2vw); height: min(32px, 8.2vw); border-radius: 7px; box-shadow: 0 3px 0 var(--shadow); }
  .title-tiles .t.y { box-shadow: 0 3px 0 var(--yellow-d); } .title-tiles .t.b { box-shadow: 0 3px 0 var(--blue-d); } .title-tiles .t.p { box-shadow: 0 3px 0 var(--pink-d); } .title-tiles .t.g { box-shadow: 0 3px 0 var(--green-d); }
  .title-tiles .t.gap { width: 4px; }
  .brand-text b { font-size: 16px; white-space: nowrap; }
  .brand-mark { width: 32px; height: 32px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .uinfo b { max-width: 64px; }
  .demo { --dc: min(36px, calc((100vw - 110px) / 7)); }
  .mode-card { padding: 14px; }
  .mode-card b { font-size: 20px; }
  .mode-card .mi { font-size: 32px; }
  .mode-card small { font-size: 12px; }
  .home-grid { grid-template-columns: 1fr; }
  .btn { padding: 9px 11px; font-size: 13px; }
  .btn.big { padding: 12px 18px; font-size: 16px; }
  .chip { font-size: 12px; padding: 4px 8px; }
  .timer { font-size: 17px; }
  .playbar .play-title small { display: none; }
  .playbar .play-title b { font-size: 16px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { padding: 12px; }
  .cat-card .ic { font-size: 30px; width: 46px; height: 46px; }
  .cat-card b { font-size: 17px; }
  .puzzle-grid { grid-template-columns: repeat(2, 1fr); }
  .section-title { font-size: 19px; }
  .vs-panel { padding: 16px; }
  .vs-rules { grid-template-columns: 1fr; }
  .vs-join { margin-left: 0; width: 100%; }
  .vs-join input { flex: 1; }
  .room-code-big { font-size: 40px; letter-spacing: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---------- 아바타 그림 ---------- */
.av { overflow: hidden; flex-shrink: 0; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.av.img { background: #fff !important; }
.av.rav { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(145deg, var(--pink), var(--orange)); color: #fff; font-weight: 900; font-size: 13px; }
.rank-table td.who { display: flex; align-items: center; gap: 8px; }
.room-item .av.rav { width: 38px; height: 38px; font-size: 16px; }
.slot .av.img { box-shadow: 0 0 0 3px var(--c), 0 4px 0 color-mix(in srgb, var(--c) 70%, #000); }
.vp .av.img, .vs-rank .av.img { box-shadow: 0 0 0 2px var(--c); }

/* ---------- 대전 채팅 ---------- */
.chat-box { display: flex; flex-direction: column; gap: 6px; text-align: left; }
#room-chat-slot .chat-box { margin: 0 0 18px; background: var(--panel-2); border-radius: 16px; padding: 10px; }
#play-chat-slot .chat-box { border-top: 2px solid var(--line); padding: 8px; background: var(--panel-2); }
.chat-log { height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; font-size: 13px; padding: 2px 4px; overscroll-behavior: contain; }
#room-chat-slot .chat-log { height: 150px; }
.chat-log:empty::before { content: "채팅으로 인사해 보세요 👋"; color: var(--muted); margin: auto; }
.chat-log p { margin: 0; word-break: break-word; animation: clueSwap .25s; }
.chat-log p b { --c: var(--p0); color: var(--c); margin-right: 5px; }
.chat-log p.own-0 b { --c: var(--p0); } .chat-log p.own-1 b { --c: var(--p1); } .chat-log p.own-2 b { --c: var(--p2); } .chat-log p.own-3 b { --c: var(--p3); }
.chat-log p.sys { color: var(--muted); font-size: 12px; text-align: center; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; padding: 8px 12px; border: 0; border-radius: 10px; font-size: 16px; background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.chat-form input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }
.chat-form .btn { flex-shrink: 0; }

/* ---------- 대기실: 방 설정 표시 / 방 목록의 게임 중 방 ---------- */
.room-settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 16px; }
.room-settings span { font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 99px; background: var(--panel-2); border: 2px solid var(--line); }
.room-settings span.flash { animation: bump .5s cubic-bezier(.2, 1.8, .4, 1); border-color: var(--blue); }
.room-item.playing { opacity: .78; cursor: default; background: var(--panel-2); box-shadow: 0 4px 0 var(--line); }
.room-item.playing:hover { transform: none; }
.room-item .tag { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; color: #fff; background: var(--orange); white-space: nowrap; }
.room-item .tag.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #fff; margin-right: 5px; animation: pulse 1s infinite; }
@media (max-width: 600px) { .room-list { grid-template-columns: 1fr; } }

/* ---------- 전체 채팅 ---------- */
.chat-card { display: flex; flex-direction: column; }
.chat-card h2 .chat-online { margin-left: auto; font-family: "Noto Sans KR", sans-serif; font-size: 12px; font-weight: 700; color: var(--muted); }
.gchat .chat-log { height: 232px; background: var(--panel-2); border-radius: 14px; padding: 8px 10px; }
.gchat .chat-log:empty::before { content: "아직 조용해요. 먼저 인사해 보세요 👋"; }
.gchat .chat-log p b { color: var(--c, var(--blue)); }
.gchat .chat-log p.me { background: #eaf1ff; border-radius: 8px; padding: 1px 6px; margin: 0 -6px; }
.gchat .chat-log p .g { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 5px; margin-right: 4px; vertical-align: 1px; }
.gchat .chat-log p time { float: right; font-size: 10px; color: #a9b4cc; margin-left: 6px; }
.how-strip { margin-top: 16px; }
.how-strip .how-list { flex-direction: row; gap: 18px; }
.how-strip .how-list li { flex: 1; }
.versus-chat { margin-top: 16px; }
.versus-chat .chat-log { height: 180px; }
/* 싱글 화면: 떠 있는 채팅 */
.gdock { position: fixed; right: 18px; bottom: 18px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
body.rails .gdock { right: 342px; }
.gdock-btn { position: relative; border-radius: 999px; padding: 12px 18px; font-size: 15px; }
.gdock-btn .badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-style: normal; font-size: 12px; line-height: 20px; text-align: center; animation: bump .4s; }
.gdock-panel { width: min(340px, calc(100vw - 36px)); padding: 14px; animation: modalPop .25s cubic-bezier(.2, 1.4, .4, 1); }
.gdock-panel h2 { font-size: 18px; margin-bottom: 8px; }
.gdock-panel h2 .close { margin-left: auto; width: 28px; height: 28px; font-size: 20px; }
@media (max-width: 980px) { .how-strip .how-list { flex-direction: column; gap: 10px; } }

/* 채팅 이름 옆 레벨 */
.chat-log p b { margin-right: 6px; }
.chat-log .lvb { display: inline-block; font-style: normal; font-size: 10px; font-weight: 800; line-height: 15px; padding: 0 6px; margin-right: 4px; border-radius: 99px; color: #fff; background: var(--blue); vertical-align: 1px; }

/* ---------- 메인 카드 줄 맞춤: 세 카드 높이를 같게, 랭킹의 레벨·점수는 세로로 줄 맞춤 ---------- */
.home-grid { align-items: stretch; }
.home-grid > .card { display: flex; flex-direction: column; }
.rank-card .home-rank { flex: 1; }
.rank-card .btn { margin-top: 12px; align-self: flex-start; }
.home-rank .lv { flex: 0 0 46px; text-align: center; padding: 1px 0; }
.home-rank .val { flex: 0 0 auto; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.home-rank .rk { flex: 0 0 28px; }
.me-card .note { margin-top: auto; padding-top: 10px; }
/* 채팅 카드는 옆 카드 높이를 따라가되, 글이 쌓여도 카드가 늘어나지 않고 안에서 스크롤 */
#home-chat-slot { flex: 1; position: relative; min-height: 270px; }
#home-chat-slot .gchat { position: absolute; inset: 0; }
#home-chat-slot .chat-log { flex: 1; height: auto; min-height: 0; }
