:root {
  --ink: #2c2118;
  --muted: #6d5848;
  --paper: rgba(255, 247, 236, 0.94);
  --line: rgba(92, 58, 36, 0.16);
  --terra: #b55233;
  --gold: #c8922a;
  --shadow: 0 18px 44px rgba(42, 22, 10, 0.28);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background:
    linear-gradient(180deg, rgba(48, 26, 12, 0.18), rgba(32, 16, 8, 0.38)),
    url("/assets/bg.jpg") center / cover no-repeat fixed;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, .banner, .sheet td.total {
  font-family: "Gowun Batang", serif;
  font-weight: 700;
}
h1, h2 { margin: 0; }
h1 { font-size: 52px; letter-spacing: -0.04em; }
.hidden { display: none !important; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 28px 16px 56px;
}

.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(42, 22, 10, 0.25);
}
.eyebrow {
  margin: 12px 0 0;
  letter-spacing: 0.22em;
  font-size: 12px;
  font-weight: 700;
  color: var(--terra);
}
.lead, .me, .empty, .hint { color: var(--muted); line-height: 1.55; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: #fffaf3;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
}
.primary, .ghost, .rooms button {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary, .rooms button {
  background: var(--terra);
  color: #fffaf3;
  font-weight: 700;
}
.primary:disabled, .rooms button:disabled { opacity: 0.45; cursor: default; }
.ghost { background: transparent; 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 16px; }
.create-row input { flex: 1; min-width: 180px; 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, 250, 243, 0.82);
  border-radius: 16px;
  padding: 12px;
}
.rooms button { border-radius: 999px; padding: 8px 14px; }
.wait-players { display: grid; gap: 8px; margin: 14px 0; }
.person {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: rgba(255, 250, 243, 0.82);
  border-radius: 14px;
  padding: 10px 12px;
}
.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: var(--muted); }

.play { width: min(1040px, 100%); display: grid; gap: 14px; }
.play-head, .tray, .sheet-wrap, .log, .banner {
  background: var(--paper);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.play-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding: 18px 22px;
}
.status { margin: 0; font-weight: 700; text-align: right; }
.tray { padding: 18px 18px 20px; }
.hint { margin: 0 0 12px; text-align: center; }
.dice {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 14px;
  min-height: 92px;
  margin-bottom: 16px;
}
.die {
  position: relative;
  width: 76px;
  height: 76px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: radial-gradient(circle at 32% 24%, #fffefb, #f4ebdd 58%, #e5d8c4);
  box-shadow: 0 10px 18px rgba(40, 20, 8, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.die.hot { cursor: pointer; }
.die.keep {
  transform: translateY(-8px);
  box-shadow: 0 16px 20px rgba(40, 20, 8, 0.3), 0 0 0 3px var(--gold);
}
.die.blank {
  background: rgba(255, 248, 236, 0.28);
  border-style: dashed;
  border-color: rgba(255, 244, 228, 0.7);
  box-shadow: none;
}
.die:disabled { cursor: default; }
.pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
}
.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #241c16;
  align-self: center;
  justify-self: center;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.35);
}
.pip.off { visibility: hidden; }
.tag {
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.tray .actions { justify-content: center; }
.banner {
  margin: 0;
  padding: 14px 18px;
  text-align: center;
  font-size: 28px;
  color: #7a341f;
}
.sheet-wrap { overflow-x: auto; }
.sheet {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
.sheet th, .sheet td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.sheet th:first-child, .sheet td:first-child {
  position: sticky;
  left: 0;
  text-align: left;
  padding-left: 16px;
  font-weight: 700;
  background: #fff7ec;
  z-index: 1;
}
.sheet thead th { font-size: 14px; }
.sheet th em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}
.sheet td.turn, .sheet th.turn { background: rgba(200, 146, 42, 0.16); }
.sheet tr.stat td, .sheet tr.stat th { background: #f3ece1; }
.sheet tr.total td, .sheet tr.total th { font-size: 18px; }
.sheet td.empty { color: #b7a89a; }
.sheet button.cell {
  min-width: 52px;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  background: #f0e2cc;
  color: var(--ink);
}
.sheet button.cell.live { background: var(--terra); color: #fffaf3; }
.log {
  margin: 0;
  padding: 14px 18px 14px 36px;
  color: var(--muted);
}
.log li { margin: 4px 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  background: #2c2118;
  color: #fff7ec;
  border-radius: 999px;
  padding: 12px 16px;
  z-index: 5;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  h1 { font-size: 42px; }
  .play-head, .status { text-align: left; }
  .play-head { flex-direction: column; align-items: start; padding: 14px 16px; }
  .status { font-size: 15px; }
  .tray { padding: 14px 12px 16px; }
  .banner { font-size: 22px; }
  .die { width: 56px; height: 56px; padding: 6px; border-radius: 14px; }
  .pip { width: 8px; height: 8px; }
  .dice { gap: 10px; }
  .sheet th, .sheet td { padding: 6px 4px; font-size: 13px; }
  .sheet button.cell { min-width: 36px; padding: 4px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .die.keep { transform: none; }
}
