/* 정원 초과 테마: 출근길 회사 로비. 굵은 외곽선, 평면 채색, 베이지 벽, 스테인리스, 경고 빨강, LED 민트, 머스터드.
   카드와 패널 한쪽에 두꺼운 색 띠를 두지 않는다. */
:root {
  --wall: #efe3cc;
  --wall-2: #e6d6b8;
  --paper: #fbf6ea;
  --ink: #1d1a17;
  --ink-2: #4a4339;
  --ink-3: #85796a;
  --steel: #b9bcc0;
  --red: #e23b2e;
  --red-d: #b52a20;
  --led: #36d39a;
  --mustard: #e7b43c;
  --line: 3px solid var(--ink);
  --lift: 0 4px 0 var(--ink);
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, system-ui, sans-serif;
  color: var(--ink); background: var(--wall) url("assets/bg.webp") center / cover fixed;
  word-break: keep-all; -webkit-font-smoothing: antialiased; line-height: 1.5;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; }

.btn { border: var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--lift); padding: 10px 16px; font-weight: 800; font-size: 16px; transition: transform .08s, box-shadow .08s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--led); }
.btn.big { width: 100%; padding: 14px; font-size: 20px; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--paper); }
.link { background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 700; color: var(--ink-2); padding: 0; }
.icon { width: 40px; height: 40px; border: var(--line); border-radius: 10px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); font-weight: 900; font-size: 18px; }

.lobby { min-height: 100vh; display: flex; flex-direction: column; }

/* 첫 화면 */
.title { max-width: 1080px; margin: 0 auto; padding: 28px 18px 40px; gap: 22px; }
.title-top { text-align: center; }
.logo { width: min(440px, 86vw); height: auto; margin: 0 auto; }
.logo.sm { width: auto; height: 40px; margin: 0; }
.tag { font-size: 17px; font-weight: 700; color: var(--ink-2); margin: 12px 0 0; }
.title-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; align-items: center; }
.hero-cars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.panel { background: var(--paper); border: var(--line); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); padding: 20px; }
.setup { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: 13px; font-weight: 800; color: var(--ink-3); margin-top: 6px; }
.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.av { border: 2px solid transparent; border-radius: 50%; background: none; padding: 2px; }
.av img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.av.on { border-color: var(--ink); background: var(--mustard); }
.segs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.segs.two { grid-template-columns: 1fr 1fr; }
.seg { border: var(--line); border-radius: 10px; background: #fff; padding: 8px 6px; font-weight: 800; box-shadow: 0 3px 0 var(--ink); display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.seg span { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.seg.on { background: var(--ink); color: var(--paper); }
.seg.on span { color: #cfc4b0; }
.setup .btn.big { margin-top: 14px; }
.row-links { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 14px; }
.soon { color: var(--ink-3); font-size: 13px; }

/* 엘리베이터 */
.car { position: relative; container-type: inline-size; --led-l: 18%; --led-r: 18%; --led-t: 4.4%; --led-h: 9.6%; --in-l: 9%; --in-r: 9%; --in-t: 22%; --in-b: 4%; }
.car-img { width: 100%; height: auto; position: relative; z-index: 1; pointer-events: none; }
.car-name { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 4; background: var(--paper); border: var(--line); border-radius: 8px; padding: 0 10px; font-weight: 900; font-size: 15px; line-height: 1.5; }
.led { position: absolute; z-index: 3; left: var(--led-l, 27%); right: var(--led-r, 27%); top: var(--led-t, 3.2%); height: var(--led-h, 8%); display: flex; align-items: center; justify-content: center; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--led); font-size: 14cqw; letter-spacing: .02em; text-shadow: 0 0 8px rgba(54, 211, 154, .7); }
.led small { font-size: .55em; opacity: .75; margin-left: 2px; }
.led.warn { color: var(--mustard); text-shadow: 0 0 8px rgba(231, 180, 60, .7); }
.led.over { color: #ff5a4c; text-shadow: 0 0 10px rgba(255, 70, 60, .9); animation: blink .25s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.riders { position: absolute; z-index: 2; left: var(--in-l, 15%); right: var(--in-r, 15%); top: var(--in-t, 18%); bottom: var(--in-b, 5%); }
.rider { position: absolute; translate: -50% 0; }
.rider.new { animation: board .4s ease-out; }
.rider img { width: 100%; height: auto; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .12)); }
.rider .w { position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%); min-width: 1.6em; text-align: center; background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; font-weight: 900; font-size: clamp(10px, 6.5cqw, 16px); line-height: 1.25; }
.rider.out { animation: pushout .9s ease-in .5s forwards; }
@keyframes board { from { transform: translateY(25%); opacity: 0; } }
@keyframes pushout { to { transform: translateY(30%) scale(.85); opacity: 0; } }
.car .siren { position: absolute; z-index: 5; width: 26%; right: 4%; top: -8%; animation: wob .3s infinite alternate; }
@keyframes wob { from { transform: rotate(-8deg); } to { transform: rotate(8deg); } }
.car.crash { animation: shake .12s 8; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.pen-pop { position: absolute; z-index: 6; left: 50%; top: 40%; transform: translateX(-50%); white-space: nowrap; background: var(--red); color: #fff; border: var(--line); border-radius: 10px; padding: 4px 10px; font-weight: 900; box-shadow: var(--lift); animation: pop .3s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.5); } }
.count { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 3; text-align: center; font-size: 12px; font-weight: 800; color: var(--ink-2); margin-top: 4px; }
.car.choosable { cursor: pointer; }
.car.choosable .car-img { filter: drop-shadow(0 0 0 var(--ink)) drop-shadow(0 0 10px var(--led)); }
.car.mini .count, .car.mini .car-name { display: none; }
.car.mini .rider .w { font-size: 11px; }


/* 게임 화면 */
.game { height: 100vh; height: 100dvh; }
.gtop { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.gtop .round { margin-left: auto; background: var(--paper); border: var(--line); border-radius: 99px; padding: 3px 14px; font-weight: 700; }
.gmain { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 290px; gap: 14px; padding: 6px 14px; }
.stage { display: flex; align-items: center; justify-content: center; min-height: 0; }
.cars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.5%; width: 100%; max-width: min(940px, calc((100vh - 300px) * 2.3)); margin-top: 40px; margin-bottom: 22px; }
.side { min-height: 0; overflow: auto; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pl { display: flex; align-items: center; gap: 10px; background: var(--paper); border: var(--line); border-radius: 12px; padding: 6px 10px 6px 6px; }
.pl.me { background: #fff4d6; }
.pl.turn { outline: 3px solid var(--led); outline-offset: 2px; }
.pl.yielded { opacity: .75; }
.pav { width: 46px; height: 46px; object-fit: contain; flex: none; }
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pst { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.q { background: var(--wall-2); border-radius: 6px; padding: 0 6px; }
.chipdot { display: inline-block; border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; font-weight: 900; color: var(--ink); background: #fff; }
.chipdot.c3, .chip.c3 { background: var(--mustard); }
.cardnum { display: inline-block; min-width: 22px; text-align: center; border: 2px solid var(--ink); border-radius: 5px; background: var(--paper); color: var(--ink); }
.pen { text-align: center; line-height: 1.05; }
.pen b { display: block; font-size: 22px; color: var(--red); }
.pen span { font-size: 11px; color: var(--ink-3); font-weight: 700; }

.ctrl { padding: 10px 14px 14px; }
.hand { display: grid; grid-template-columns: 1fr auto 190px; gap: 14px; align-items: end; background: var(--paper); border: var(--line); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 12px; }
.hand-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row-lbl { font-size: 12px; font-weight: 800; color: var(--ink-3); }
.cards { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.card { position: relative; border: 0; background: none; padding: 0; transition: transform .12s; }
.card img { width: 100%; height: auto; }
.card span { position: absolute; left: 0; right: 0; top: 40%; transform: translateY(-50%); text-align: center; font-weight: 900; font-size: clamp(20px, 3.2vw, 34px); }
.card.on { transform: translateY(-8px); }
.card:disabled { opacity: .22; }
.chips { display: grid; grid-template-columns: repeat(4, 56px); gap: 6px; }
.chip { height: 56px; border: var(--line); border-radius: 12px; background: #fff; box-shadow: 0 3px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.chip b { font-size: 20px; font-weight: 900; }
.chip small { font-size: 11px; color: var(--ink-3); font-weight: 700; }
.chip.on { background: var(--mustard); transform: translateY(-4px); }
.chip.on small { color: var(--ink-2); }
.chip:disabled { opacity: .3; }
.go { height: 64px; }
.wait, .ask { background: var(--paper); border: var(--line); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 14px 16px; text-align: center; font-weight: 800; }
.ask-msg { margin: 0 0 4px; font-size: 17px; }
.ask-risk { margin: 0 0 8px; color: var(--red-d); font-size: 14px; }
.ask-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* 결과 */
.result { max-width: 560px; margin: 0 auto; padding: 30px 18px; align-items: center; gap: 14px; }
.res-title { margin: 6px 0; font-size: 28px; font-weight: 900; }
.rank { list-style: none; padding: 0; margin: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.rank li { display: flex; align-items: center; gap: 12px; background: var(--paper); border: var(--line); border-radius: 14px; padding: 6px 14px; }
.rank li.me { background: #fff4d6; }
.rank img { width: 48px; height: 64px; object-fit: contain; object-position: bottom; }
.rnum { font-size: 22px; font-weight: 900; width: 24px; }
.rname { flex: 1; font-weight: 800; }
.rpen { font-weight: 800; color: var(--red-d); }
.res-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.res-btns .btn.big { grid-column: 1 / -1; }

/* 규칙 */
.modal { position: fixed; inset: 0; background: rgba(29, 26, 23, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.sheet { background: var(--paper); border: var(--line); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); max-width: 520px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px; }
.sheet h2 { margin: 0 0 8px; }
.sheet ol { padding-left: 20px; margin: 0 0 10px; }
.sheet li { margin: 6px 0; }
.tip { background: #fff4d6; border-radius: 10px; padding: 10px 12px; font-size: 14px; }


/* 친구 초대 화면 */
.start-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.form-screen { align-items: center; justify-content: center; padding: 28px 16px; }
.panel.narrow { width: min(460px, 100%); }
.panel.wide { width: min(560px, 100%); }
.logo.mid { width: min(260px, 70%); margin-bottom: 4px; }
.form-title { margin: 6px 0 0; font-size: 22px; text-align: center; }
.form-sub { margin: 0 0 6px; color: var(--ink-2); font-weight: 600; text-align: center; }
.form-note { margin: 2px 0; color: var(--ink-3); font-size: 14px; font-weight: 600; text-align: center; }
.name-in { border: var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 17px; font-weight: 700; background: #fff; width: 100%; }
.name-in:focus { outline: 3px solid var(--mustard); outline-offset: 2px; }
.err { margin: 0; color: var(--red-d); font-weight: 700; font-size: 14px; }
.invite-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.invite-row.one { grid-template-columns: 1fr; }
.seats { list-style: none; margin: 6px 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seat { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 10px; min-height: 52px; }
.seat img { width: 38px; height: 38px; }
.seat.me { background: #fff4d6; }
.seat.empty { border-style: dashed; color: var(--ink-3); justify-content: center; }
.sname { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-s { font-size: 11px; font-weight: 800; border: 2px solid var(--ink); border-radius: 999px; padding: 0 6px; background: var(--mustard); white-space: nowrap; }
.tag-s.bot { background: var(--steel); }
.tag-s.mine { background: var(--led); }
.bot-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.bot-row .lbl { flex: 1; margin: 0; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.hand-msg { grid-column: 1 / -1; margin: 0; font-weight: 800; text-align: center; }
.timer { display: inline-block; min-width: 42px; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--ink); color: var(--led); font-size: 14px; font-variant-numeric: tabular-nums; }
.timer:empty { display: none; }
.timer.low { background: var(--red); color: #fff; }
.pl.off { opacity: .55; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; max-width: calc(100vw - 32px); background: var(--ink); color: var(--paper); border-radius: 12px; padding: 10px 16px; font-weight: 700; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.toast[hidden] { display: none; }

.embedded .title { padding-top: 16px; gap: 14px; }
.embedded .title .logo { width: min(280px, 64vw); }
.embedded .title .tag { display: none; }
@media (max-width: 860px) {
  .title-grid { grid-template-columns: 1fr; }
  .gmain { grid-template-columns: 1fr; grid-template-rows: auto auto; padding: 4px 10px; gap: 8px; overflow: auto; }
  .side { order: 2; overflow: visible; }
  .players { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .pl { padding: 5px 7px 5px 4px; gap: 5px; }
  .pav { width: 32px; height: 32px; }
  .pname { font-size: 12px; }
  .pst { font-size: 10.5px; gap: 3px; }
  .pst .q { padding: 0 3px; }
  .pen b { font-size: 17px; }
  .pen span { display: none; }
  .cars { max-width: none; margin-top: 36px; margin-bottom: 24px; }
  .car-name { font-size: 13px; padding: 0 8px; }
  .pname { font-size: 12.5px; }
  .go { height: auto; }
  .hand { grid-template-columns: 1fr; gap: 8px; padding: 10px; }
  .chips { grid-template-columns: repeat(4, 1fr); }
  .chip { height: 46px; }
  .logo.sm { height: 30px; }
  .gtop .icon:first-child { width: 36px; height: 36px; }
}
