:root {
  --ink: #2c2118;
  --paper: rgba(255, 246, 234, 0.9);
  --line: rgba(90, 52, 28, 0.28);
  --seal: #8c2f24;
  --brass: #c4922a;
  --shadow: 0 18px 48px rgba(28, 14, 6, 0.38);
  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") center / cover no-repeat fixed;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, .status, .last-score { font-family: "Gowun Batang", serif; font-weight: 700; margin: 0; }
h1 { font-size: 48px; letter-spacing: -0.03em; }
.hidden { display: none !important; }

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

.panel, .side {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.panel { width: min(440px, 100%); 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(28, 14, 6, 0.35);
}
.eyebrow {
  margin: 12px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 700;
  color: var(--seal);
}
.lead, .me, .empty, .hint, .legend { color: #5c4636; 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: #6b2b22; color: #fff8ef; font-weight: 700; }
.primary:hover { filter: brightness(1.12); }
.primary:disabled { opacity: 0.45; cursor: default; filter: none; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.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: 0; margin: 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, 252, 247, 0.78);
  border-radius: 14px;
  padding: 12px;
}
.rooms li div { display: grid; gap: 2px; }
.rooms button {
  border: 0;
  background: #6b2b22;
  color: #fff8ef;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.rooms button:disabled { opacity: 0.45; }
.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, 252, 247, 0.78);
  border-radius: 14px;
  padding: 10px 12px;
}
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 236, 0.4);
}
.score-bits {
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.score-bits strong { font-size: 18px; }
.player.turn { box-shadow: inset 0 0 0 2px var(--seal); }
.player.you { background: rgba(255, 244, 226, 0.96); }
.player.win { box-shadow: inset 0 0 0 2px var(--brass); }
.rules { margin: 8px 0 16px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules ul { margin: 8px 0 0; padding-left: 18px; color: #5c4636; }

.play {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 680px) minmax(240px, 340px);
  gap: 16px;
  align-items: start;
}
.board-col { display: grid; gap: 8px; justify-items: center; }
.status {
  width: 100%;
  min-height: 1.4em;
  font-size: 32px;
  line-height: 1.35;
  color: #fff6ea;
  text-shadow: 0 2px 10px rgba(20, 10, 4, 0.65);
}
.board-wrap { width: min(100%, 640px); }
canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  background: transparent;
  touch-action: none;
}
canvas.live { cursor: crosshair; }
.hint, .legend { margin: 0; }
.hint {
  color: #fff4e4;
  text-shadow: 0 1px 6px rgba(20, 10, 4, 0.7);
}
.side { padding: 18px; }
.side-head { margin-bottom: 8px; }
.last-score {
  min-height: 1.2em;
  font-size: 30px;
  line-height: 1.35;
  color: var(--seal);
  margin-top: 8px;
}
.legend { font-size: 13px; margin-top: 6px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(42, 28, 20, 0.94);
  color: #fff6ea;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 5;
}

@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; }
  #app { padding: 12px; }
  h1 { font-size: 38px; }
  .status { font-size: 26px; }
  .last-score { font-size: 26px; }
}
