:root {
  --ink: #241c16;
  --paper: rgba(247, 241, 230, 0.94);
  --line: rgba(36, 28, 22, 0.14);
  --left: #2a6f97;
  --right: #b5523a;
  --gold: #f0c14d;
  --shadow: 0 18px 50px rgba(36, 28, 22, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.22), rgba(255, 252, 246, 0.08) 40%, rgba(36, 28, 22, 0.08)),
    url("/assets/lobby-bg.jpg") center / cover no-repeat fixed;
}

body:has(#screen-play:not(.hidden)) {
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.05), rgba(36, 28, 22, 0.05)),
    url("/assets/play-bg.jpg") center / cover no-repeat fixed;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

h1, h2, .eyebrow, #clock, #resultTitle, .floor-btn {
  font-family: "Gowun Batang", serif;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
}

body:has(#screen-play:not(.hidden)) #app {
  justify-content: flex-start;
}

.panel {
  width: min(440px, 100%);
  padding: 28px 26px 24px;
  border-radius: 28px;
  background: var(--paper);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 252, 245, 0.8);
}

.panel.wide { width: min(720px, 100%); }

.hidden { display: none !important; }

.mark {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: block;
  margin-bottom: 8px;
  background: #f4efe4;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  color: #8a6244;
  font-size: 0.92rem;
}

h1, h2 { margin: 4px 0 8px; }

h1 { font-size: 2.5rem; }

.lead, .empty, #hint, #resultDetail {
  color: #5c4b3a;
  line-height: 1.55;
}

label {
  display: block;
  margin: 18px 0 12px;
  font-weight: 700;
}

input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.primary, .ghost {
  border-radius: 999px;
  padding: 11px 18px;
  border: 1px solid transparent;
}

.primary {
  background: var(--ink);
  color: #fffaf3;
}

.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.ghost {
  background: transparent;
  border-color: var(--line);
}

.row, .actions, .create-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.create-row input {
  margin: 0;
  flex: 1;
  min-width: 0;
  width: auto;
}

.create-row button,
.rooms button,
.actions button {
  flex: none;
  white-space: nowrap;
}

.me { margin: 0; color: #5c4b3a; }

.rooms {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.rooms li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.rooms li div { color: #5c4b3a; font-size: 0.92rem; }

.rooms strong { display: block; color: var(--ink); font-size: 1rem; }

.wait-players {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.person {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.person.left { box-shadow: inset 4px 0 0 var(--left); }
.person.right { box-shadow: inset 4px 0 0 var(--right); }

.rules {
  margin: 8px 0 16px;
  color: #5c4b3a;
}

.rules ul { margin: 8px 0 0; padding-left: 18px; }

.actions { justify-content: flex-start; margin-top: 8px; }

.play {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.play-top, .stage-wrap, .dock {
  width: min(1180px, 100%);
}

.play-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

.side-meta {
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(247, 241, 230, 0.88);
  min-height: 42px;
}

.side-meta.left { box-shadow: inset 4px 0 0 var(--left); }
.side-meta.right { box-shadow: inset -4px 0 0 var(--right); text-align: right; }
.side-meta.mine { background: #fffaf0; }

.clock-block { text-align: center; }

#clock {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1;
}

.danger {
  min-height: 1.2em;
  margin: 4px 0 0;
  color: #9a3412;
  font-size: 0.82rem;
  font-weight: 700;
}

.stage-wrap {
  position: relative;
  height: min(640px, calc(100dvh - 196px));
  min-height: 300px;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 22px;
  box-shadow: var(--shadow);
  background: #d7e6f1;
  touch-action: none;
}

.dock { text-align: center; }

#hint {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(247, 241, 230, 0.9);
}

.floors {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.floor-btn {
  min-width: 76px;
  height: 58px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: #f7f1e6;
  font-size: 1.25rem;
}

.floor-btn.here { box-shadow: inset 0 0 0 3px var(--ink); }

.floor-btn.on {
  background: var(--gold);
}

.floor-btn:disabled { opacity: 0.55; cursor: default; }

.result {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  background: rgba(247, 241, 230, 0.9);
  border-radius: 22px;
  text-align: center;
  padding: 20px;
}

.result h2 { font-size: 2.2rem; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf3;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  body,
  body:has(#screen-play:not(.hidden)) {
    background-attachment: scroll;
    background-position: 16% center;
  }

  #app { padding: 12px 10px 16px; }
  h1 { font-size: 2.1rem; }
  .play-top { grid-template-columns: 1fr; }
  .side-meta.right { text-align: left; box-shadow: inset 4px 0 0 var(--right); }
  .floor-btn { flex: 1; min-width: 0; height: 52px; }
  .stage-wrap { height: min(520px, calc(100dvh - 250px)); }
}
