:root {
  --ink: #3c2a24;
  --paper: rgba(255, 248, 240, 0.84);
  --line: rgba(120, 72, 48, 0.28);
  --gold: #c4922a;
  --shadow: 0 18px 44px rgba(48, 18, 12, 0.28);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: url("/assets/bg.jpg?v=1") center / cover no-repeat fixed;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { font-family: "Gowun Batang", serif; font-weight: 700; margin: 0; }
.hidden { display: none !important; }

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

.panel {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid rgba(255, 236, 214, 0.55);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  backdrop-filter: blur(6px);
}
.panel.wide { width: min(720px, 100%); }
.mark {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 8px 18px rgba(60, 24, 16, 0.25);
}
.eyebrow {
  margin: 12px 0 0;
  letter-spacing: 0.22em;
  font-size: 12px;
  font-weight: 700;
  color: #9c3b45;
}
.lead, .me, .empty { color: #5a4034; line-height: 1.55; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.92);
  border-radius: 12px;
  padding: 12px 14px;
}
.primary, .ghost {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: #9c3b45; color: #fffaf3; font-weight: 700; }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: rgba(255, 250, 244, 0.55); border-color: var(--line); }
.row, .create-row, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row { justify-content: space-between; }
.create-row { margin: 12px 0 16px; }
.create-row input { flex: 1; margin: 0; min-width: 0; }
.rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rooms li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 250, 244, 0.72);
  border-radius: 14px;
  padding: 12px;
}
.rooms li div { display: grid; gap: 2px; }
.rooms button {
  border: 0;
  background: #9c3b45;
  color: #fffaf3;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.rooms button:disabled { background: rgba(90, 64, 52, 0.35); }
.wait-players, .players { display: grid; gap: 8px; margin: 14px 0; }
.person, .player {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: rgba(255, 250, 244, 0.72);
  border-radius: 14px;
  padding: 10px 12px;
}
.player.turn { outline: 2px solid var(--gold); }
.player.win { background: rgba(255, 236, 196, 0.9); }
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}
.rules { margin: 8px 0 16px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules ul { margin: 8px 0 0; padding-left: 18px; color: #5a4034; line-height: 1.6; }

.play {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 640px) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
}
.table {
  background: rgba(255, 246, 236, 0.22);
  border: 1px solid rgba(255, 236, 214, 0.38);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(2px);
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.card {
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 800px;
}
.card:disabled { cursor: default; }
.flip {
  display: grid;
  height: 100%;
  border-radius: 14px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}
.card.show .flip { transform: rotateY(180deg); }
.back, .front {
  grid-area: 1 / 1;
  border-radius: 14px;
  backface-visibility: hidden;
}
.back {
  background-color: #7a3144;
  background-image:
    radial-gradient(circle at 22% 24%, rgba(255, 220, 170, 0.7) 0 1.4px, transparent 2px),
    radial-gradient(circle at 78% 72%, rgba(255, 214, 160, 0.55) 0 1.4px, transparent 2px),
    repeating-linear-gradient(45deg, rgba(255, 206, 150, 0.18) 0 7px, rgba(92, 28, 44, 0.28) 7px 14px),
    repeating-linear-gradient(-45deg, rgba(255, 236, 210, 0.14) 0 9px, transparent 9px 18px);
  box-shadow: inset 0 0 0 3px rgba(255, 228, 196, 0.45), inset 0 0 0 7px rgba(92, 28, 44, 0.35);
}
.front {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.7), transparent 42%),
    #fffaf3;
  border: 1px solid rgba(120, 78, 48, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: inset 0 0 0 4px rgba(196, 146, 42, 0.16);
}
.card.taken .front { box-shadow: inset 0 0 0 4px rgba(156, 59, 69, 0.28); }
.front em { font-style: normal; font-size: 13px; font-weight: 700; color: #6a4e3e; }
.front small {
  min-height: 1em;
  font-size: 11px;
  color: #9c3b45;
  font-weight: 700;
}
.glyph {
  width: 46px;
  height: 46px;
  display: block;
  background: var(--c, transparent);
  filter: drop-shadow(0 2px 0 rgba(80, 40, 20, 0.12));
}
.glyph.circle { border-radius: 50%; }
.glyph.square { width: 40px; height: 40px; border-radius: 7px; }
.glyph.triangle {
  width: 48px;
  height: 42px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.glyph.star {
  width: 48px;
  height: 48px;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.glyph.heart {
  width: 26px;
  height: 26px;
  margin: 10px auto 0;
  border-radius: 4px;
  transform: rotate(45deg);
  position: relative;
  filter: none;
}
.glyph.heart::before,
.glyph.heart::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  background: var(--c);
  border-radius: 50%;
}
.glyph.heart::before { left: -13px; top: 0; }
.glyph.heart::after { left: 0; top: -13px; }
.glyph.moon {
  border-radius: 50%;
  -webkit-mask: radial-gradient(circle at 70% 42%, transparent 15px, #000 16px);
  mask: radial-gradient(circle at 70% 42%, transparent 15px, #000 16px);
}
.glyph.sun {
  width: 48px;
  height: 48px;
  background: transparent;
  position: relative;
  filter: none;
}
.glyph.sun::before,
.glyph.sun::after {
  content: "";
  position: absolute;
  inset: 0;
}
.glyph.sun::before {
  inset: 13px;
  border-radius: 50%;
  background: var(--c);
}
.glyph.sun::after {
  background: repeating-conic-gradient(from 8deg, var(--c) 0 14deg, transparent 14deg 45deg);
  -webkit-mask: radial-gradient(circle, transparent 12px, #000 13px);
  mask: radial-gradient(circle, transparent 12px, #000 13px);
}
.glyph.cloud {
  width: 52px;
  height: 34px;
  background:
    radial-gradient(circle at 14px 20px, var(--c) 9px, transparent 10px),
    radial-gradient(circle at 26px 13px, var(--c) 12px, transparent 13px),
    radial-gradient(circle at 39px 20px, var(--c) 8px, transparent 9px),
    linear-gradient(var(--c), var(--c)) 8px 20px / 36px 12px no-repeat;
}

.side {
  background: var(--paper);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 20px 18px;
  backdrop-filter: blur(6px);
}
.status { min-height: 3em; font-weight: 700; line-height: 1.45; }
.log {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  color: #5a4034;
  font-size: 14px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: rgba(60, 32, 28, 0.92);
  color: #fffaf3;
  border-radius: 999px;
  padding: 10px 16px;
  margin: 0;
}

@media (max-width: 800px) {
  .play { grid-template-columns: 1fr; }
  .grid { gap: 8px; }
  .front em { font-size: 11px; }
}
