@font-face {
  font-family: "Brush";
  src: url("fonts/brush.woff2") format("woff2");
  font-display: swap
}

:root {
  --bg: #eee5d5;
  --paper: #fffdf6;
  --paper2: #f6eddf;
  --ink: #251d18;
  --muted: #74695f;
  --red: #b83d38;
  --red2: #8f2927;
  --green: #155c4d;
  --green2: #103d34;
  --gold: #d5a43c;
  --gold2: #ffd34c;
  --line: rgba(55, 40, 28, .14);
  --shadow: 0 18px 48px rgba(38, 28, 20, .16);
  --radius: 22px;
  --cw: clamp(50px, 6.4vw, 66px);
  --ch: calc(var(--cw)*1.63);
  --pw: calc(var(--cw)*.5);
  --ph: calc(var(--ch)*.5);
  --bgimg: radial-gradient(circle at 8% 3%, rgba(21, 92, 77, .15), transparent 27rem), radial-gradient(circle at 94% 7%, rgba(184, 61, 56, .13), transparent 25rem), linear-gradient(145deg, #e9decb, #fbf7ef 52%, #e3eee8)
}

@media (prefers-color-scheme:dark) {
  :root:not([data-theme=light]) {
    --bg: #0f1420;
    --paper: #18202e;
    --paper2: #222c3c;
    --ink: #ece6dc;
    --muted: #a59c90;
    --line: rgba(255, 240, 220, .12);
    --shadow: 0 18px 48px rgba(0, 0, 0, .45);
    --red: #d65650;
    --green: #1b6a59;
    --green2: #0f3a31;
    --bgimg: radial-gradient(circle at 10% 0%, rgba(46, 90, 140, .25), transparent 30rem), radial-gradient(circle at 90% 10%, rgba(184, 61, 56, .18), transparent 26rem), linear-gradient(160deg, #0d1220, #141b2b 55%, #0f1a1c)
  }
}

* {
  box-sizing: border-box
}

html {
  min-height: 100%;
  background: var(--bg)
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bgimg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.45
}

button,
input {
  font: inherit;
  color: inherit
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #f2c94c;
  outline-offset: 3px
}

button:disabled {
  cursor: not-allowed;
  opacity: .46
}

button:not(:disabled):active {
  transform: scale(.965)
}

[hidden] {
  display: none !important
}

.app {
  width: min(100%, 1220px);
  margin: auto;
  padding: 14px clamp(12px, 3vw, 28px) 8px
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-weight: 950
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  color: #fff4c9;
  background: linear-gradient(135deg, var(--red), #df714d);
  box-shadow: 0 9px 22px rgba(184, 61, 56, .27);
  font: 1.3rem serif
}

.brand-name {
  font-family: "Brush", serif;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px
}

.conn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c9c0b4
}

.conn.on {
  background: #2fae7d;
  box-shadow: 0 0 0 4px rgba(47, 174, 125, .18)
}

.conn.off {
  background: #d65650;
  animation: blink 1s infinite alternate
}

@keyframes blink {
  to {
    opacity: .3
  }
}

.plain,
.secondary,
.tool {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 850;
  box-shadow: 0 4px 12px rgba(45, 32, 23, .06);
  transition: .16s
}

.plain:hover,
.secondary:hover,
.tool:hover {
  border-color: rgba(55, 40, 28, .3);
  background: var(--paper2)
}

.primary {
  min-height: 52px;
  padding: 13px 20px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #d45d43);
  font-weight: 950;
  box-shadow: 0 12px 27px rgba(184, 61, 56, .27);
  transition: .16s
}

.primary:hover {
  filter: brightness(1.06)
}

.primary.gold {
  color: #2b1d00;
  background: linear-gradient(135deg, #ffd34c, #f0a630);
  box-shadow: 0 12px 27px rgba(240, 166, 48, .3)
}

.primary.green {
  background: linear-gradient(135deg, #1d7a63, var(--green));
  box-shadow: 0 12px 27px rgba(21, 92, 77, .3)
}

.screen {
  display: none;
  animation: enter .28s ease backwards
}

.screen.active {
  display: block
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0)
  }
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  box-shadow: var(--shadow)
}

/* ---------- 닉네임 ---------- */
.name-card {
  max-width: 520px;
  margin: 6vh auto;
  padding: clamp(24px, 5vw, 40px);
  text-align: center;
  position: relative;
  overflow: hidden
}

.name-card:after {
  content: "花";
  position: absolute;
  right: -20px;
  bottom: -70px;
  color: rgba(213, 164, 60, .13);
  font: 13rem/1 serif;
  pointer-events: none
}

.name-card h1 {
  margin: 4px 0 6px;
  font: 400 clamp(3rem, 12vw, 4.6rem)/1 "Brush", serif
}

.name-card p {
  margin: 0 0 20px;
  color: var(--muted)
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px
}

.field-input {
  min-height: 52px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper2);
  font-size: 1.05rem
}

.name-cards {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 0 18px
}

.name-cards img {
  width: 44px;
  border-radius: 5px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .18);
  transform: rotate(var(--r))
}

/* ---------- 방 목록 ---------- */
.lobby-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: 14px;
  margin-bottom: 16px
}

.lobby-main {
  padding: clamp(20px, 4vw, 32px);
  position: relative;
  overflow: hidden
}

.lobby-main h1 {
  margin: 0 0 4px;
  font: 400 clamp(2.6rem, 7vw, 3.6rem)/1 "Brush", serif
}

.lobby-main p {
  margin: 0 0 18px;
  color: var(--muted)
}

.lobby-main .primary {
  min-width: 220px;
  font-size: 1.08rem
}

.lobby-main:after {
  content: "光";
  position: absolute;
  right: -12px;
  bottom: -60px;
  color: rgba(213, 164, 60, .12);
  font: 12rem/1 serif;
  pointer-events: none
}

.code-box {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center
}

.code-box b {
  font-size: .95rem
}

.code-box small {
  color: var(--muted)
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px
}

.code-row input {
  letter-spacing: .4em;
  text-align: center;
  font-weight: 900;
  font-size: 1.25rem
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  flex-wrap: wrap;
  align-items: center
}

.tabs button {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-weight: 850;
  color: var(--muted)
}

.tabs button[aria-pressed=true] {
  color: #fff;
  background: var(--green);
  border-color: var(--green)
}

.tabs .count {
  margin-left: auto;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800
}

.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px
}

.room-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(45, 32, 23, .08);
  transition: .16s
}

.room-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(45, 32, 23, .12)
}

.room-card.full {
  opacity: .55
}

.room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 900
}

.state:before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor
}

.state.waiting {
  color: #17845f;
  background: #dff3ea
}

.state.ai {
  color: #a5700c;
  background: #fff1cf
}

.state.full {
  color: #7d746b;
  background: #ece7df
}

.game-tag {
  font-size: .74rem;
  font-weight: 900;
  color: var(--muted)
}

.room-title {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -.02em
}

.room-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px
}

.room-seats span {
  padding: 4px 9px;
  border-radius: 10px;
  background: var(--paper2);
  font-size: .78rem;
  font-weight: 800
}

.room-seats span.ai {
  color: #a5700c
}

.room-seats span.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  background: none
}

.room-card .primary {
  min-height: 44px;
  padding: 9px;
  font-size: .92rem
}

.empty-state {
  grid-column: 1/-1;
  padding: 44px 20px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  text-align: center;
  color: var(--muted)
}

.empty-state b {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 1.1rem
}

.empty-state .mini-cards {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 12px;
  opacity: .8
}

.empty-state img {
  width: 34px;
  border-radius: 4px
}

/* ---------- 게임 머리 ---------- */
.game-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.metric {
  min-width: 96px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--paper);
  font-size: .7rem
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums
}

.head-actions {
  display: flex;
  gap: 8px
}

.progress {
  height: 7px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 30%, transparent)
}

.progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width .35s
}

.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start
}

/* ---------- 게임판 ---------- */
.board {
  position: relative;
  min-height: 640px;
  padding: 14px;
  overflow: hidden;
  border-radius: var(--radius);
  color: #fff;
  background: radial-gradient(circle at 50% 43%, rgba(255, 255, 255, .09), transparent 23rem), linear-gradient(145deg, var(--green), var(--green2));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, .08)
}

.board:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background: repeating-linear-gradient(30deg, transparent 0 23px, rgba(255, 255, 255, .07) 24px, transparent 25px)
}

.opponents {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px
}

.opponents.two {
  grid-template-columns: 1fr 1fr
}

.seat-box {
  position: relative;
  padding: 9px 10px;
  border-radius: 16px;
  background: rgba(4, 27, 22, .28);
  border: 1px solid rgba(255, 255, 255, .08);
  transition: .2s
}

.seat-box.turn {
  border-color: rgba(255, 211, 76, .75);
  box-shadow: 0 0 0 3px rgba(255, 211, 76, .18)
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  min-height: 26px;
  flex-wrap: wrap
}

.seat-head strong {
  font-size: .92rem;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.badge {
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .14);
  font-size: .66rem;
  font-weight: 900
}

.badge.turn {
  color: #2b1d00;
  background: var(--gold2)
}

.badge.ai {
  background: #7a5a17
}

.badge.off {
  background: #8f2927
}

.badge.go {
  background: #d45d43
}

.seat-score {
  margin-left: auto;
  font-weight: 950;
  font-variant-numeric: tabular-nums
}

.backs {
  display: flex;
  align-items: center;
  min-height: 40px
}

.back {
  width: 28px;
  height: 42px;
  margin-left: -15px;
  border: 2px solid #ecdcb8;
  border-radius: 6px;
  background: radial-gradient(circle, #e5bb4f 0 8%, transparent 9%), repeating-linear-gradient(45deg, #8e2928 0 4px, #bb453d 4px 8px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .25)
}

.back:first-child {
  margin-left: 0
}

.back.dummy {
  background: repeating-linear-gradient(45deg, #4b3a14 0 4px, #7a5a17 4px 8px)
}

.seat-row {
  display: flex;
  align-items: flex-start;
  gap: 12px
}

.seat-row .backs {
  flex: 0 0 auto
}

.middle {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 290px;
  margin: 10px 0;
  padding: 12px 56px 12px 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 20px;
  background: rgba(4, 27, 22, .29)
}

.field-grid {
  display: grid;
  width: min(100%, 600px);
  grid-template-columns: repeat(auto-fill, var(--cw));
  justify-content: center;
  align-items: start;
  gap: 10px 8px
}

.stack {
  position: relative;
  display: grid
}

.stack .hwatu+.hwatu {
  margin-top: calc(var(--ch)*-.8)
}

.stack-badge {
  position: absolute;
  z-index: 7;
  top: -8px;
  right: -8px;
  padding: 2px 7px;
  border-radius: 99px;
  color: #2b1d00;
  background: var(--gold2);
  font-size: .66rem;
  font-weight: 950;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .3)
}

.empty-field {
  margin: 0;
  color: rgba(255, 255, 255, .7);
  font-size: .85rem
}

.stock {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 50%;
  width: 40px;
  height: 58px;
  transform: translateY(-50%);
  border: 2px solid #ead8ad;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #8e2928 0 5px, #bd493e 5px 10px);
  box-shadow: 4px 4px 0 #702321, 8px 8px 0 rgba(0, 0, 0, .15)
}

.stock span {
  position: absolute;
  right: -8px;
  bottom: -22px;
  width: 56px;
  font-size: .68rem;
  text-align: center
}

.flip {
  position: absolute;
  z-index: 8;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  perspective: 600px
}

.flip .hwatu {
  border-color: var(--gold2);
  box-shadow: 0 0 0 4px rgba(255, 211, 76, .35), 0 16px 28px rgba(0, 0, 0, .45);
  animation: flipIn .42s ease-out both
}

.flip span {
  display: block;
  margin-top: 5px;
  color: #ffe9a6;
  font-size: .7rem;
  font-weight: 950;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5)
}

@keyframes flipIn {
  from {
    transform: rotateY(90deg) scale(.6)
  }

  to {
    transform: none
  }
}

.me-box {
  position: relative;
  z-index: 1
}

.hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--cw));
  justify-content: center;
  gap: 7px;
  margin-top: 8px
}

.hwatu {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 7px 13px rgba(0, 0, 0, .22);
  transition: transform .16s, border-color .16s, box-shadow .16s;
  user-select: none;
  -webkit-user-select: none
}

.hwatu img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none
}

.hwatu.dummy {
  display: grid;
  place-items: center;
  border-color: #ecdcb8;
  color: #fff4c9;
  background: repeating-linear-gradient(45deg, #4b3a14 0 5px, #7a5a17 5px 10px);
  font-size: .66rem;
  font-weight: 950;
  text-align: center;
  line-height: 1.3
}

button.hwatu:hover:not(:disabled) {
  z-index: 4;
  border-color: #f2ca51;
  transform: translate3d(0, -7px, 0);
  box-shadow: 0 13px 20px rgba(0, 0, 0, .3)
}

.hwatu.same {
  border-color: #9be7cf
}

.hwatu.hint {
  border-color: #5ee0b4;
  box-shadow: 0 0 0 4px rgba(94, 224, 180, .35), 0 11px 20px rgba(0, 0, 0, .28);
  transform: translate3d(0, -6px, 0)
}

.hwatu.choice {
  z-index: 3;
  border-color: var(--gold2);
  animation: choice .78s ease-in-out infinite alternate
}

.hwatu.watch {
  border-color: rgba(255, 211, 76, .6)
}

@keyframes choice {
  to {
    transform: translate3d(0, -6px, 0);
    box-shadow: 0 0 0 4px rgba(255, 211, 76, .32)
  }
}

.tag {
  position: absolute;
  z-index: 5;
  top: 3px;
  padding: 1px 4px;
  border-radius: 5px;
  color: #fff;
  background: rgba(31, 25, 20, .82);
  font-size: .52rem;
  font-weight: 950
}

.month-tag {
  left: 3px
}

.kind-tag {
  right: 3px;
  background: var(--red)
}

.key {
  position: absolute;
  z-index: 5;
  right: 3px;
  bottom: 2px;
  padding: 1px 3px;
  border-radius: 4px;
  color: #655a51;
  background: rgba(255, 250, 240, .88);
  font-size: .52rem;
  font-weight: 950
}

.hide-tags .hwatu .tag {
  display: none
}

/* 가져온 패 (손패의 1/2 크기) */
.pile {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px 14px;
  min-height: calc(var(--ph) + 18px);
  cursor: pointer
}

.pile-empty {
  align-self: center;
  color: rgba(255, 255, 255, .55);
  font-size: .74rem
}

.pile-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px 4px;
  border-radius: 9px;
  border: 1px solid transparent
}

.pile-group.near {
  border-color: rgba(255, 211, 76, .85);
  background: rgba(255, 211, 76, .1)
}

.pile-group b {
  font-size: .64rem;
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
  font-weight: 900
}

.pile-group b em {
  font-style: normal;
  color: var(--gold2)
}

.pile-cards {
  display: flex
}

.mini {
  flex: 0 0 auto;
  width: var(--pw);
  height: var(--ph);
  overflow: hidden;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .32)
}

.mini+.mini {
  margin-left: calc(var(--pw)*-.48)
}

.pile-group.dense .mini+.mini {
  margin-left: calc(var(--pw)*-.68)
}

.mini img {
  display: block;
  width: 100%;
  height: 100%
}

.mini.fresh {
  animation: fresh 1.2s ease-out
}

@keyframes fresh {
  from {
    transform: translate3d(0, -10px, 0);
    box-shadow: 0 0 0 3px var(--gold2)
  }
}

/* 덮개: 대기실 · 고/스톱 · 결과 */
.cover {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(7, 28, 23, .86);
  backdrop-filter: blur(6px);
  text-align: center;
  overflow: auto
}

.cover.show {
  display: grid
}

.cover h2 {
  margin: 0 0 6px;
  font-size: 1.6rem
}

.cover p {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, .78)
}

.cover-inner {
  width: min(100%, 520px)
}

.room-code {
  display: inline-block;
  margin: 6px 0 4px;
  padding: 6px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .1);
  font-size: 2.4rem;
  font-weight: 950;
  letter-spacing: .3em
}

.wait-seats {
  display: grid;
  gap: 8px;
  margin: 14px 0
}

.wait-seats div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  text-align: left
}

.wait-seats div.empty {
  border: 1px dashed rgba(255, 255, 255, .3);
  background: none;
  color: rgba(255, 255, 255, .6)
}

.cover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px
}

.cover-actions.one {
  grid-template-columns: 1fr
}

.gostop-score {
  margin: 0;
  color: var(--gold2);
  font: 400 4.2rem/1 "Brush", serif
}

.gostop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(100%, 380px);
  margin: auto
}

.gostop-actions small {
  display: block;
  font-size: .7rem;
  font-weight: 800;
  opacity: .85
}

.cover .result-title {
  margin: 0;
  font: 400 clamp(3.4rem, 11vw, 4.6rem)/1 "Brush", serif;
  color: var(--gold2)
}

.cover .result-title.lose {
  color: #ff9a8c
}

.cover .result-title.nagari {
  color: #cfd8d4
}

.result-table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: .88rem
}

.result-table th,
.result-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  text-align: left
}

.result-table td.num {
  text-align: right;
  font-weight: 900;
  font-variant-numeric: tabular-nums
}

.plus {
  color: #8ff0c4
}

.minus {
  color: #ff9a8c
}

.calc {
  margin: 6px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .07);
  text-align: left;
  font-size: .8rem;
  color: rgba(255, 255, 255, .82)
}

.calc ul {
  margin: 0;
  padding-left: 18px
}

.ready-row {
  margin: 6px 0 10px;
  font-size: .8rem;
  color: rgba(255, 255, 255, .7)
}

/* 붓글씨 이벤트 연출 */
.splash {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: none
}

.splash-inner {
  text-align: center;
  line-height: 1;
  animation: pop 1.35s cubic-bezier(.2, .9, .25, 1.25) both;
  pointer-events: auto;
  cursor: pointer
}

.splash-emoji {
  display: block;
  font-size: clamp(46px, 9vw, 72px);
  margin-bottom: -6px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35))
}

.splash-word {
  display: block;
  font: 400 clamp(92px, 17vw, 150px)/1 "Brush", serif;
  color: var(--c);
  -webkit-text-stroke: 5px #fff;
  paint-order: stroke fill;
  text-shadow: 5px 7px 0 rgba(0, 0, 0, .35);
  animation: brush .5s ease-out both
}

.splash-sub {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .42);
  color: #fff;
  font: 900 .95rem system-ui, sans-serif
}

.splash.out .splash-inner {
  animation: fadeout .3s ease-in both
}

@keyframes pop {
  0% {
    transform: scale(.3) rotate(-8deg);
    opacity: 0
  }

  35% {
    transform: scale(1.16) rotate(2deg);
    opacity: 1
  }

  50% {
    transform: scale(.96) rotate(-1deg)
  }

  62% {
    transform: scale(1.04)
  }

  75%,
  100% {
    transform: scale(1)
  }
}

@keyframes brush {
  from {
    clip-path: inset(0 100% 0 0)
  }

  to {
    clip-path: inset(0 -10% 0 -10%)
  }
}

@keyframes fadeout {
  to {
    opacity: 0;
    transform: scale(1.08)
  }
}

/* ---------- 옆 패널 ---------- */
.side {
  display: grid;
  gap: 12px
}

.status {
  padding: 16px
}

.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 99px;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--paper));
  font-size: .74rem;
  font-weight: 950
}

.turn-pill:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor
}

.status h2 {
  margin: 0 0 4px;
  font-size: 1.08rem;
  letter-spacing: -.02em
}

.status p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem
}

.timer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line)
}

.timer span {
  color: var(--muted);
  font-size: .73rem
}

.timer strong {
  color: var(--red);
  font-size: 1.28rem;
  font-variant-numeric: tabular-nums
}

.timer strong.urgent {
  animation: blink .6s infinite alternate
}

.score-list {
  display: grid;
  gap: 6px;
  margin-top: 11px
}

.score-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--paper2);
  font-size: .74rem;
  color: var(--muted)
}

.score-list div.me {
  outline: 2px solid color-mix(in srgb, var(--green) 40%, transparent)
}

.score-list b {
  color: var(--ink);
  font-size: .84rem
}

.score-list strong {
  color: var(--ink);
  font-size: 1rem;
  text-align: right
}

.score-list span {
  grid-column: 1/-1
}

.yak-line {
  min-height: 34px;
  margin-top: 9px !important;
  padding: 8px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 16%, var(--paper));
  color: color-mix(in srgb, var(--gold) 60%, var(--ink)) !important;
  font-size: .74rem !important
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px
}

/* 채팅 */
.chat {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 8px
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between
}

.chat-head h2 {
  margin: 0;
  font-size: 1rem
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 220px;
  overflow-y: auto;
  padding-right: 2px
}

.chat-log div {
  padding: 6px 9px;
  border-radius: 10px;
  background: var(--paper2);
  font-size: .8rem;
  word-break: break-word
}

.chat-log div b {
  margin-right: 5px
}

.chat-log div.system {
  background: none;
  color: var(--muted);
  font-size: .74rem;
  text-align: center;
  padding: 2px
}

.chat-log div.mine {
  background: color-mix(in srgb, var(--green) 16%, var(--paper))
}

.chat-log div.emote {
  font-size: .95rem
}

.emotes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px
}

.emotes button {
  min-height: 34px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: .8rem;
  font-weight: 800
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px
}

.chat-form input {
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper2)
}

.chat-form button {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 12px;
  color: #fff;
  background: var(--green);
  font-weight: 900
}

.mute {
  font-size: .7rem;
  color: var(--muted);
  background: none;
  min-height: auto;
  padding: 0;
  text-decoration: underline
}

.bubble {
  position: absolute;
  z-index: 12;
  top: 6px;
  left: 50%;
  max-width: min(240px, 80%);
  padding: 6px 11px;
  border-radius: 14px;
  background: #fff;
  color: #251d18;
  font-size: .82rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .3);
  transform: translate(-50%, 0);
  animation: bubble 2.6s ease both;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.bubble.emote {
  font-size: 1.4rem;
  padding: 4px 10px
}

@keyframes bubble {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(.8)
  }

  10%,
  85% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1)
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -6px)
  }
}

.chat-fab {
  position: fixed;
  z-index: 40;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .3);
  font-size: 1.4rem
}

.chat-fab i {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--red);
  font: 900 .7rem/20px system-ui;
  font-style: normal
}

/* 시트(아래에서 올라오는 창) · 대화상자 */
dialog {
  width: min(calc(100% - 24px), 620px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow)
}

dialog::backdrop {
  background: rgba(21, 17, 14, .6);
  backdrop-filter: blur(4px)
}

.dialog-inner {
  padding: 22px;
  overflow: auto
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.3rem
}

.opt-label {
  margin: 14px 0 7px;
  font-weight: 900;
  font-size: .9rem
}

.seg {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), 1fr);
  gap: 7px
}

.seg button {
  min-height: 48px;
  padding: 7px;
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--muted);
  background: var(--paper2);
  font-weight: 900
}

.seg button[aria-pressed=true] {
  color: #fff;
  border-color: var(--red2);
  background: var(--red)
}

.game-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px
}

.game-pick button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--paper2);
  font-weight: 950;
  font-size: 1rem
}

.game-pick button small {
  color: var(--muted);
  font-weight: 700;
  font-size: .74rem
}

.game-pick button[aria-pressed=true] {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, var(--paper));
  box-shadow: 0 8px 20px rgba(21, 92, 77, .18)
}

.game-pick .mini-cards {
  display: flex;
  gap: 3px
}

.game-pick img {
  width: 30px;
  border-radius: 3px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .2)
}

.create-go {
  width: 100%;
  margin-top: 18px
}

.rules {
  padding-left: 20px;
  color: var(--muted);
  font-size: .86rem
}

.rules li+li {
  margin-top: 5px
}

.rule-table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: .78rem
}

.rule-table th,
.rule-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top
}

.rule-table th {
  width: 26%;
  color: var(--red2);
  white-space: nowrap
}

.rule-table td {
  color: var(--muted)
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line)
}

.switch {
  flex: 0 0 56px;
  width: 56px;
  height: 32px;
  padding: 4px;
  border-radius: 99px;
  background: #a99e91
}

.switch:after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: .2s
}

.switch[aria-pressed=true] {
  background: var(--green)
}

.switch[aria-pressed=true]:after {
  transform: translateX(24px)
}

.credit {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.5
}

.credit a {
  color: var(--green)
}

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: var(--paper);
  box-shadow: 0 -14px 40px rgba(0, 0, 0, .35);
  transform: translateY(105%);
  transition: transform .28s ease
}

.sheet.show {
  transform: none
}

.sheet-grip {
  width: 44px;
  height: 5px;
  margin: 9px auto 4px;
  border-radius: 99px;
  background: var(--line)
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px
}

.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 8px;
  overflow-x: auto
}

.sheet-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--paper2);
  font-weight: 850
}

.sheet-tabs button[aria-pressed=true] {
  color: #fff;
  background: var(--green);
  border-color: var(--green)
}

.sheet-body {
  padding: 6px 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto
}

.sheet-row {
  margin-bottom: 12px
}

.sheet-row b {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem
}

.sheet-row b em {
  font-style: normal;
  color: var(--red)
}

.sheet-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px
}

.sheet-cards img {
  width: calc(var(--cw)*.85);
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, .2)
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, .4);
  display: none
}

.scrim.show {
  display: block
}

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: calc(100% - 26px);
  padding: 11px 15px;
  border-radius: 13px;
  color: #fff;
  background: #2b241f;
  box-shadow: var(--shadow);
  font-weight: 850;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .2s
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0)
}

#fx {
  position: fixed;
  inset: 0;
  z-index: 85;
  width: 100%;
  height: 100%;
  pointer-events: none
}

footer {
  padding: 20px 0 6px;
  color: var(--muted);
  text-align: center;
  font-size: .69rem
}

@media(max-width:900px) {
  .table-layout {
    grid-template-columns: 1fr
  }

  .side {
    grid-template-columns: 1fr 1fr
  }

  .lobby-hero {
    grid-template-columns: 1fr
  }
}

@media(max-width:600px) {
  :root {
    --cw: min(15.6vw, 60px)
  }

  .app {
    padding: 10px 10px 90px
  }

  .brand-name {
    font-size: 1.6rem
  }

  .topbar .plain {
    padding-inline: 10px;
    font-size: .8rem
  }

  .game-head {
    grid-template-columns: 1fr
  }

  .metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px
  }

  .metric {
    min-width: 0;
    padding: 6px 7px;
    font-size: .62rem
  }

  .metric strong {
    font-size: .86rem
  }

  .head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr
  }

  .board {
    min-height: 560px;
    padding: 9px 7px
  }

  .opponents.two {
    grid-template-columns: 1fr
  }

  .seat-row {
    flex-direction: column;
    gap: 6px
  }

  .middle {
    min-height: 240px;
    padding: 9px 44px 9px 2px
  }

  .field-grid {
    gap: 8px 4px
  }

  .hand {
    gap: 4px
  }

  .stock {
    right: 5px;
    width: 34px;
    height: 50px
  }

  .side {
    grid-template-columns: 1fr
  }

  .chat {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 58;
    border-radius: 22px 22px 0 0;
    transform: translateY(105%);
    transition: transform .28s ease;
    padding-bottom: calc(14px + env(safe-area-inset-bottom))
  }

  .chat.show {
    transform: none
  }

  .chat-log {
    height: 34dvh
  }

  .chat-fab {
    display: block
  }

  body:not([data-screen=room]) .chat-fab {
    display: none
  }

  .cover-actions {
    grid-template-columns: 1fr
  }
}

@media(prefers-reduced-motion:reduce) {

  *,
  :before,
  :after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important
  }
}

/* ---------- 위쪽 버튼 (규칙·설정 · 닉네임) ---------- */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 99px;
  color: #2b1d00;
  background: linear-gradient(135deg, #ffd76a, #f0a630);
  box-shadow: 0 8px 20px rgba(240, 166, 48, .32), inset 0 1px 0 rgba(255, 255, 255, .55);
  font-weight: 950;
  transition: .16s
}

.pill-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 11px 24px rgba(240, 166, 48, .4), inset 0 1px 0 rgba(255, 255, 255, .55)
}

.pill-btn .short {
  display: none
}

.name-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  box-shadow: 0 4px 12px rgba(45, 32, 23, .08);
  font-weight: 900;
  transition: .16s
}

.name-chip:hover {
  border-color: rgba(55, 40, 28, .3)
}

.name-chip .avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #1d7a63, var(--green));
  font-size: .92rem
}

.name-chip .nm {
  max-width: 8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.name-chip .edit {
  color: var(--muted);
  font-size: .8rem
}

/* 연결 안내 띠 */
.conn-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 12px;
  padding: 11px 14px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #8f2927, #b83d38);
  box-shadow: 0 10px 24px rgba(143, 41, 39, .25);
  font-weight: 850;
  font-size: .88rem
}

.spin {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

/* ---------- 규칙 · 설정 창 ---------- */
.rules-dialog {
  width: min(calc(100% - 20px), 760px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  padding: 0;
  border-radius: 26px
}

.rules-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dlgIn .26s cubic-bezier(.2, .9, .3, 1.1)
}

@keyframes dlgIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.98)
  }
}

.rd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  color: #fff;
  background: radial-gradient(circle at 85% -20%, rgba(255, 215, 106, .35), transparent 55%), linear-gradient(140deg, var(--green), var(--green2))
}

.rd-title {
  display: flex;
  align-items: center;
  gap: 12px
}

.rd-mark {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  color: #fff4c9;
  background: linear-gradient(135deg, var(--red), #df714d);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .25);
  font: 1.35rem serif
}

.rd-title h2 {
  margin: 0;
  font: 400 2.2rem/1 "Brush", serif;
  letter-spacing: .01em
}

.rd-title small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, .75);
  font-size: .78rem
}

.icon-btn {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  font-size: 1.05rem;
  font-weight: 900;
  transition: .16s
}

.icon-btn:hover {
  background: rgba(255, 255, 255, .26)
}

.rd-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  scrollbar-width: none
}

.rd-tabs::-webkit-scrollbar {
  display: none
}

.rd-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--paper2);
  color: var(--muted);
  font-weight: 900;
  font-size: .86rem;
  transition: .16s
}

.rd-tabs button[aria-selected=true] {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 6px 16px rgba(21, 92, 77, .28)
}

.rd-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--paper), var(--paper2) 160%)
}

.rd-panel {
  animation: enter .22s ease backwards
}

.rd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px
}

.rd-chips span {
  padding: 7px 11px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--green) 10%, var(--paper));
  color: var(--ink);
  font-size: .8rem;
  border: 1px solid color-mix(in srgb, var(--green) 18%, transparent)
}

.rd-chips b {
  color: var(--green)
}

.yak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px
}

.yak {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 6px 16px rgba(45, 32, 23, .06);
  transition: .16s
}

.yak:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(45, 32, 23, .1)
}

.yak:before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent, #c9bfb1)
}

.yak.gold {
  --accent: #e3ad2b
}

.yak.red {
  --accent: #d64a43
}

.yak.blue {
  --accent: #3d7fd6
}

.yak.green {
  --accent: #4f9e57
}

.yak.sky {
  --accent: #4fb3e8
}

.yak-cards {
  display: flex;
  flex: 0 0 auto;
  padding-left: 4px
}

.yak-cards img {
  width: 30px;
  height: 49px;
  border-radius: 4px;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .2);
  background: #fff
}

.yak-cards img+img {
  margin-left: -14px
}

.yak-text {
  min-width: 0;
  flex: 1
}

.yak-text b {
  display: block;
  font-size: .98rem;
  letter-spacing: -.02em
}

.yak-text small {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35
}

.pts {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 99px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #d45d43);
  font-size: .76rem;
  font-weight: 950;
  white-space: nowrap
}

.kind-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px
}

.kind-row div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper)
}

.kind-row img {
  width: 40px;
  height: 65px;
  border-radius: 5px;
  box-shadow: 0 4px 9px rgba(0, 0, 0, .2)
}

.kind-row b {
  font-size: .9rem
}

.kind-row span {
  color: var(--red);
  font-weight: 950;
  font-size: 1.05rem
}

.bak-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.bak {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper)
}

.bak-ico {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--paper2);
  font-size: 1.25rem
}

.bak div {
  flex: 1;
  min-width: 0
}

.bak b {
  display: block;
  font-size: .94rem
}

.bak small {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35
}

.rd-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 14%, var(--paper));
  color: var(--ink);
  font-size: .8rem
}

.set-list {
  display: grid;
  gap: 9px
}

.set {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper)
}

.set-ico {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: color-mix(in srgb, var(--green) 12%, var(--paper));
  font-size: 1.2rem
}

.set div {
  flex: 1
}

.set b {
  display: block
}

.set small {
  color: var(--muted);
  font-size: .76rem
}

.rules-dialog .credit {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line)
}

@media(max-width:600px) {
  .pill-btn {
    padding: 9px 13px
  }

  .pill-btn .long {
    display: none
  }

  .pill-btn .short {
    display: inline
  }

  .name-chip .nm {
    max-width: 4.5em
  }

  .name-chip .edit {
    display: none
  }

  .rules-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto auto 0;
    border-radius: 24px 24px 0 0
  }

  .rd-title h2 {
    font-size: 1.9rem
  }

  .yak-grid {
    grid-template-columns: 1fr
  }

  .bak-list {
    grid-template-columns: 1fr
  }

  .kind-row img {
    width: 34px;
    height: 55px
  }
}

/* ---------- 접속자 목록 ---------- */
.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  align-items: start
}

.lobby-col {
  min-width: 0
}

.users-panel {
  padding: 16px;
  position: sticky;
  top: 12px
}

.users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px
}

.users-head h2 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -.02em
}

.online-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  color: #17845f;
  background: color-mix(in srgb, #2fae7d 14%, var(--paper));
  font-size: .78rem;
  font-weight: 900
}

.online-count i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2fae7d;
  box-shadow: 0 0 0 3px rgba(47, 174, 125, .2);
  animation: pulse 1.8s ease-in-out infinite
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px rgba(47, 174, 125, .05)
  }
}

.users-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: min(62vh, 560px);
  overflow-y: auto
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 14px;
  transition: .16s
}

.user:hover {
  background: var(--paper2)
}

.user.me {
  background: color-mix(in srgb, var(--green) 9%, var(--paper))
}

.u-avatar {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  font-size: .95rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .15)
}

.u-text {
  flex: 1;
  min-width: 0
}

.u-text b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem
}

.u-text b em {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 99px;
  color: #fff;
  background: var(--green);
  font-style: normal;
  font-size: .62rem;
  vertical-align: 2px
}

.u-text small {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.u-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3a0
}

.u-dot.lobby {
  background: #2fae7d
}

.u-dot.waiting {
  background: #e3ad2b
}

.u-dot.playing {
  background: #d64a43
}

.u-dot.result {
  background: #3d7fd6
}

.u-join {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 99px;
  color: #fff;
  background: linear-gradient(135deg, #1d7a63, var(--green));
  font-size: .74rem;
  font-weight: 900;
  box-shadow: 0 5px 12px rgba(21, 92, 77, .25)
}

.users-empty {
  padding: 12px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center
}

.users-panel.compact {
  position: static;
  padding: 14px
}

.users-panel.compact .users-list {
  max-height: 236px
}

.users-panel.compact .u-avatar {
  flex-basis: 30px;
  width: 30px;
  height: 30px;
  font-size: .82rem
}

@media(max-width:900px) {
  .lobby-layout {
    grid-template-columns: 1fr
  }

  .users-panel {
    position: static
  }

  .users-list {
    max-height: none
  }
}

@media(max-width:600px) {
  .users-panel.compact {
    display: none
  }
}

/* ---------- 바닥 패 고르기 ---------- */
.stack.spread {
  display: flex;
  gap: 8px;
  justify-content: center
}

.stack.spread .hwatu+.hwatu {
  margin-top: 0
}

.choose-pop {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 20px);
  padding: 14px 18px 16px;
  border: 1px solid rgba(255, 211, 76, .55);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(16, 61, 52, .97), rgba(7, 28, 23, .97));
  box-shadow: 0 22px 50px rgba(0, 0, 0, .45), 0 0 0 4px rgba(255, 211, 76, .12);
  transform: translate(-50%, -50%);
  animation: cpIn .3s cubic-bezier(.2, .9, .3, 1.2) both
}

@keyframes cpIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(.94)
  }
}

.cp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left
}

.cp-head b {
  display: block;
  font-size: .98rem
}

.cp-head small {
  color: rgba(255, 255, 255, .7);
  font-size: .76rem
}

.cp-head em {
  font-style: normal;
  color: var(--gold2);
  font-weight: 900
}

.cp-src {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px
}

.cp-src img {
  width: 30px;
  height: 49px;
  border-radius: 4px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35)
}

.cp-src small {
  font-size: .6rem;
  color: #ffe9a6;
  font-weight: 900
}

.cp-cards {
  display: flex;
  gap: 16px
}

.cp-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  color: #fff;
  animation: cpBob 1.1s ease-in-out infinite alternate
}

.cp-card {
  display: block;
  width: calc(var(--cw)*1.35);
  height: calc(var(--ch)*1.35);
  overflow: hidden;
  border: 3px solid var(--gold2);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 211, 76, .22), 0 16px 26px rgba(0, 0, 0, .45);
  transition: .16s
}

.cp-card img {
  display: block;
  width: 100%;
  height: 100%
}

.cp-opt:hover .cp-card {
  transform: scale(1.05);
  box-shadow: 0 0 0 7px rgba(255, 211, 76, .35), 0 18px 30px rgba(0, 0, 0, .5)
}

.cp-opt b {
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .12);
  font-size: .82rem
}

.cp-opt i {
  padding: 2px 8px;
  border-radius: 99px;
  color: #2b1d00;
  background: var(--gold2);
  font-style: normal;
  font-size: .68rem;
  font-weight: 950
}

@keyframes cpBob {
  to {
    transform: translateY(-8px)
  }
}

@media(max-width:600px) {
  .cp-card {
    width: calc(var(--cw)*1.25);
    height: calc(var(--ch)*1.25)
  }

  .choose-pop {
    padding: 12px
  }

  .cp-head b {
    font-size: .88rem
  }
}

.choose-pop:before {
  content: "";
  position: fixed;
  inset: -100vmax;
  z-index: -1;
  background: rgba(10, 14, 12, .35);
  pointer-events: none
}

/* ---------- 오른쪽 패널: 게임판 높이에 맞추기 · 상태 창 압축 ---------- */
.side {
  display: block;
  min-width: 0
}

.side-inner {
  display: grid;
  gap: 10px
}

.status {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "pill timer" "title title" "text text" "scores scores" "yak yak" "actions actions";
  align-items: center;
  gap: 4px 8px;
  padding: 12px 14px
}

.status .turn-pill {
  grid-area: pill;
  justify-self: start;
  margin: 0;
  padding: 5px 10px;
  font-size: .72rem
}

.status h2 {
  grid-area: title;
  margin: 2px 0 0;
  font-size: .98rem
}

.status p {
  grid-area: text;
  font-size: .76rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden
}

.status .timer {
  grid-area: timer;
  margin: 0;
  padding: 0;
  border: 0;
  align-items: center;
  gap: 6px
}

.status .timer span {
  font-size: .66rem
}

.status .timer strong {
  font-size: 1.05rem
}

.status .score-list {
  grid-area: scores;
  gap: 5px;
  margin-top: 6px
}

.status .score-list div {
  padding: 6px 9px;
  font-size: .68rem;
  gap: 0 8px
}

.status .score-list b {
  font-size: .8rem
}

.status .score-list strong {
  font-size: .9rem
}

.status .score-list span:last-child {
  display: none
}

.status .yak-line {
  grid-area: yak;
  min-height: 0;
  margin-top: 4px !important;
  padding: 6px 8px;
  font-size: .7rem !important
}

.status .side-actions {
  grid-area: actions;
  margin-top: 4px
}

.status .side-actions .tool {
  min-height: 36px;
  padding: 6px 10px;
  font-size: .8rem;
  border-radius: 12px
}

.users-panel.compact {
  padding: 12px 14px
}

.users-panel.compact .users-head {
  margin-bottom: 6px
}

.users-panel.compact .users-list {
  max-height: 132px
}

.users-panel.compact .user {
  padding: 5px 7px
}

.chat {
  padding: 12px 14px
}

@media(min-width:901px) {
  .table-layout {
    align-items: stretch
  }

  .side {
    position: relative
  }

  .side-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 10px
  }

  .side-inner>.status,
  .side-inner>.users-panel {
    flex: 0 0 auto
  }

  .side-inner>.chat {
    flex: 1 1 auto;
    min-height: 170px;
    display: flex;
    flex-direction: column
  }

  .side-inner .chat-log {
    flex: 1 1 auto;
    height: auto;
    min-height: 0
  }
}

@media(max-width:900px) {
  .side-inner {
    grid-template-columns: 1fr 1fr
  }
}

@media(max-width:600px) {
  .side-inner {
    grid-template-columns: 1fr
  }
}

/* 고르기 창 크기 줄이기 */
.cp-card {
  width: calc(var(--cw)*1.12);
  height: calc(var(--ch)*1.12)
}

.cp-head b {
  font-size: .9rem
}

.cp-cards {
  gap: 12px
}

.choose-pop {
  gap: 10px;
  padding: 12px 16px 14px
}

.chat-form button {
  white-space: nowrap
}

/* 규칙·설정 버튼은 닉네임 버튼보다 작게 */
.pill-btn {
  min-height: 36px;
  padding: 6px 13px;
  gap: 5px;
  font-size: .8rem;
  box-shadow: 0 5px 14px rgba(240, 166, 48, .28), inset 0 1px 0 rgba(255, 255, 255, .55)
}

@media(max-width:600px) {
  .pill-btn {
    min-height: 34px;
    padding: 5px 11px;
    font-size: .78rem
  }
}