:root {
  --ink: #2c2118;
  --paper: rgba(255, 248, 236, 0.92);
  --line: rgba(92, 58, 32, 0.22);
  --red: #b4332a;
  --shadow: 0 18px 40px rgba(48, 24, 8, 0.28);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background: url("/assets/bg.jpg?v=1") center / cover fixed;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, .card .center, .card .corner {
  font-family: "Gowun Batang", serif;
  font-weight: 700;
}
h1, h2 { margin: 0; }
.hidden { display: none !important; }

#app { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.panel {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.panel.wide { width: min(720px, 100%); }
.mark { width: 84px; height: 84px; object-fit: cover; border-radius: 18px; }
.eyebrow {
  margin: 10px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--red);
  font-weight: 700;
}
.lead, .me, .empty { color: #5c4636; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.96);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
}
.primary, .ghost {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: var(--red); color: #fffaf2; font-weight: 700; }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: rgba(255, 250, 242, 0.72); border-color: var(--line); color: var(--ink); }
.row, .create-row, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row { justify-content: space-between; }
.create-row { margin: 12px 0; }
.create-row input { flex: 1; margin: 0; min-width: 180px; }
.rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.rooms li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 250, 242, 0.8);
  border-radius: 14px;
  padding: 12px;
}
.rooms li div { display: grid; gap: 2px; }
.rooms button { border: 0; background: var(--red); color: #fffaf2; border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.rooms button:disabled { background: #b7a394; }
.wait-players, .players { display: grid; gap: 8px; margin: 14px 0; }
.person, .seat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: rgba(255, 250, 242, 0.76);
  border-radius: 14px;
  padding: 10px 12px;
}
.rules { margin: 8px 0 16px; }
.rules li { margin: 6px 0; }

.table {
  width: min(1080px, 100%);
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  place-items: stretch;
}
.bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 248, 236, 0.88);
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.status { margin: 0; font-weight: 700; }
.players { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.seat { align-items: flex-start; flex-wrap: wrap; }
.seat.on { outline: 3px solid #f0d78a; }
.seat.win { outline: 3px solid #2c7a45; }
.seat .who { display: grid; }
.backs { display: flex; min-height: 36px; }
.back {
  width: 28px;
  height: 40px;
  margin-left: -12px;
  border-radius: 5px;
  border: 2px solid #f3e6c8;
  background:
    radial-gradient(circle at 50% 45%, #f0d78a 0 2px, transparent 3px),
    repeating-linear-gradient(45deg, #1d3f86 0 4px, #163472 4px 8px);
  box-shadow: 0 4px 8px rgba(20, 12, 4, 0.28);
}
.backs .back:first-child { margin-left: 0; }
.back.lg {
  width: 92px;
  height: 132px;
  margin: 0;
  border-width: 4px;
  border-radius: 12px;
}

.felt { display: grid; place-items: center; align-content: center; gap: 12px; }
.pile { display: flex; gap: 28px; align-items: flex-end; }
.stack { display: grid; justify-items: center; gap: 8px; }
.deck-count, .color-now {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.9);
  font-weight: 700;
}
.top-pile { min-width: 104px; min-height: 148px; display: grid; place-items: center; }
.empty-top {
  width: 104px;
  height: 148px;
  border: 2px dashed rgba(255, 248, 236, 0.8);
  border-radius: 14px;
  color: #fff8ee;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.dock {
  background: rgba(255, 248, 236, 0.9);
  border-radius: 24px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 4px 12px;
  min-height: 128px;
}
.colors { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.colors p { margin: 0; font-weight: 700; }
.swatch-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: #fffaf2;
  font-weight: 700;
}
.tone-red { --tone: #b4332a; --ink-card: #8d241d; }
.tone-yellow { --tone: #c89212; --ink-card: #7a5a08; }
.tone-green { --tone: #2c7a45; --ink-card: #1e5a32; }
.tone-blue { --tone: #2457a6; --ink-card: #1a3f78; }
.tone-wild { --tone: #6b4a8a; --ink-card: #4a3560; }
.swatch-btn.tone-red { background: #b4332a; }
.swatch-btn.tone-yellow { background: #c89212; }
.swatch-btn.tone-green { background: #2c7a45; }
.swatch-btn.tone-blue { background: #2457a6; }

.card {
  --tone: #6b4a8a;
  --ink-card: #4a3560;
  position: relative;
  width: 76px;
  height: 108px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 12px;
  padding: 0;
  background:
    linear-gradient(#f7f1e4, #f7f1e4) padding-box,
    linear-gradient(160deg, #fff, var(--tone)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 8px 16px rgba(40, 24, 8, 0.25);
  color: var(--ink-card);
}
.card.lg { width: 104px; height: 148px; }
.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid var(--tone);
  border-radius: 8px;
  pointer-events: none;
}
.card .corner {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 14px;
}
.card.lg .corner { font-size: 18px; }
.card .center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
}
.card.lg .center { font-size: 36px; }
.card.kind-wild .center { font-size: 16px; letter-spacing: -0.04em; }
.card.lg.kind-wild .center { font-size: 22px; }
.card .mark-shape {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 14px;
  height: 14px;
  background: var(--tone);
}
.tone-red .mark-shape { border-radius: 50%; }
.tone-yellow .mark-shape { transform: rotate(45deg) scale(0.8); }
.tone-green .mark-shape {
  border-radius: 0 70% 0 70%;
  transform: rotate(-20deg);
}
.tone-blue .mark-shape {
  height: 8px;
  border-radius: 8px;
  box-shadow: 0 -6px 0 var(--tone);
  background: var(--tone);
}
.tone-wild .mark-shape {
  border-radius: 50%;
  background: conic-gradient(#b4332a, #c89212, #2c7a45, #2457a6, #b4332a);
}
.card.hot { transform: translateY(-8px); box-shadow: 0 14px 20px rgba(180, 51, 42, 0.28); }
.card.picked { outline: 3px solid #f0d78a; transform: translateY(-10px); }
.card:disabled { opacity: 0.55; transform: none; cursor: default; }

.log {
  margin: 10px 0 0;
  padding: 0 0 0 18px;
  max-height: 96px;
  overflow: auto;
  color: #5c4636;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #2c2118;
  color: #fff8ee;
  border-radius: 999px;
  padding: 10px 16px;
  margin: 0;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  #app { padding: 12px; }
  .bar { align-items: flex-start; flex-direction: column; }
  .pile { gap: 16px; }
}
