:root {
  --ink: #2c2118;
  --muted: #5c4636;
  --paper: rgba(255, 246, 234, 0.92);
  --line: rgba(120, 72, 40, 0.28);
  --amber: #c56a2d;
  --stamp: #b4332a;
  --pine: #2f5d45;
  --shadow: 0 18px 44px rgba(48, 24, 8, 0.28);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background:
    linear-gradient(180deg, rgba(42, 24, 14, 0.18), rgba(42, 24, 14, 0.42)),
    url("/assets/bg.jpg") center / cover no-repeat fixed;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { 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;
}

.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: 22px;
  box-shadow: 0 8px 18px rgba(48, 24, 8, 0.25);
}
.eyebrow {
  margin: 12px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
}
.lead, .me, .empty { color: var(--muted); line-height: 1.6; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.9);
  border-radius: 12px;
  padding: 12px 14px;
}
.primary, .ghost {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: var(--amber); color: #fffaf2; font-weight: 700; }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: transparent; 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; }
.create-row input { flex: 1; min-width: 160px; margin: 0; }
.rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rooms li, .person, .player {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 250, 242, 0.78);
  border-radius: 14px;
  padding: 12px;
}
.rooms button {
  border: 0;
  background: var(--amber);
  color: #fffaf2;
  border-radius: 999px;
  padding: 8px 14px;
}
.rooms button:disabled { background: #c8b6a4; }
.wait-players, .players { display: grid; gap: 8px; margin: 14px 0; }
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}
.rules { margin: 8px 0 16px; }
.rules ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

.play {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) minmax(240px, 340px);
  gap: 16px;
  align-items: start;
}
.stage, .side {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.stage { padding: 16px; }
.side { padding: 18px; }
.call {
  width: 128px;
  height: 128px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background:
    radial-gradient(circle at 38% 32%, #f6e2b8, #e39a45 42%, #a24d1c 78%);
  color: #fffaf2;
  box-shadow: inset 0 0 0 6px rgba(255, 248, 236, 0.35), 0 12px 24px rgba(90, 40, 10, 0.28);
}
.call strong {
  font-family: "Gowun Batang", serif;
  font-size: 52px;
  line-height: 1;
}
.call span { font-size: 12px; letter-spacing: 0.08em; }
.sheets { display: grid; gap: 12px; }
.sheet {
  background: rgba(255, 250, 242, 0.72);
  border-radius: 18px;
  padding: 12px;
}
.sheet h3 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 20px;
}
.sheet h3 span { margin-left: auto; color: var(--muted); font-family: "Noto Sans KR", sans-serif; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 248, 236, 0.95);
  border: 1px solid rgba(138, 75, 47, 0.2);
  font-family: "Gowun Batang", serif;
  font-size: clamp(16px, 2.4vw, 28px);
  position: relative;
}
.cell.closed { color: var(--stamp); background: rgba(180, 51, 42, 0.08); }
.cell.closed::after {
  content: "";
  position: absolute;
  inset: 14%;
  border: 3px solid var(--stamp);
  border-radius: 50%;
}
.cell.win { box-shadow: inset 0 0 0 3px var(--pine); background: rgba(47, 93, 69, 0.12); }
.mini .cell { font-size: 13px; border-radius: 8px; }
.mini .cell.closed::after { border-width: 2px; }
.mini h3 { font-size: 16px; }
.status { min-height: 1.5em; font-weight: 700; }
.player.win { outline: 2px solid var(--pine); }
.called { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin-bottom: 8px; }
.called span, .log {
  background: rgba(255, 250, 242, 0.8);
}
.called span {
  min-width: 2em;
  text-align: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-family: "Gowun Batang", serif;
}
.called .now { background: var(--stamp); color: #fffaf2; }
.log { list-style: none; margin: 12px 0 0; padding: 8px 12px; border-radius: 14px; max-height: 180px; overflow: auto; }
.log li { padding: 3px 0; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(44, 33, 24, 0.92);
  color: #fffaf2;
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}

@media (max-width: 800px) {
  .play { grid-template-columns: 1fr; }
  .call { width: 104px; height: 104px; }
  .call strong { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
