:root {
  --ink: #f6f1e7;
  --muted: #d9d0c2;
  --panel: rgba(10, 18, 22, 0.78);
  --line: rgba(244, 220, 176, 0.28);
  --gold: #e6b15c;
  --green: #1f9d55;
  --red: #e23d3d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background: url("/assets/bg.jpg") center / cover no-repeat fixed;
}

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

.panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  backdrop-filter: blur(8px);
}
.panel.wide { width: min(720px, 100%); }
.mark {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.eyebrow {
  margin: 12px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--gold);
}
.lead, .me, .empty { color: var(--muted); }
h1 { font-size: 40px; }
h2 { font-size: 32px; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: rgba(255, 248, 236, 0.92);
  color: #2a241c;
  border-radius: 12px;
  padding: 12px 14px;
}
.primary, .ghost {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: var(--gold); color: #2a2114; font-weight: 700; }
.primary: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; }
.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, 248, 236, 0.08);
  border-radius: 14px;
  padding: 12px;
}
.rooms strong { display: block; }
.rooms button {
  border: 0;
  background: var(--gold);
  color: #2a2114;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.rooms button:disabled { opacity: 0.45; }
.wait-players { display: grid; gap: 8px; margin: 14px 0; }
.person {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: rgba(255, 248, 236, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
}
.rules { margin: 8px 0 16px; }
.rules summary { cursor: pointer; }
.rules ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

#screen-play {
  position: fixed;
  inset: 0;
  z-index: 2;
}
#pad {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  color: transparent;
  background:
    linear-gradient(180deg, rgba(8, 16, 18, 0.2), rgba(8, 16, 18, 0.45)),
    url("/assets/bg.jpg") center / cover no-repeat;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#pad:disabled { cursor: default; }
#screen-play.is-green #pad {
  background:
    linear-gradient(180deg, rgba(16, 110, 58, 0.62), rgba(6, 36, 22, 0.5)),
    url("/assets/bg.jpg") center / cover no-repeat;
}
#screen-play.is-red #pad {
  background:
    linear-gradient(180deg, rgba(168, 24, 32, 0.7), rgba(54, 6, 12, 0.55)),
    url("/assets/bg.jpg") center / cover no-repeat;
}
.hud {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}
.lamp {
  width: min(22vw, 148px);
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: radial-gradient(circle at 38% 34%, #f7fff8, #8d8d8d 42%, #2a2a2a 74%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#screen-play.is-green .lamp {
  background: radial-gradient(circle at 38% 34%, #f4fff6, #3dce78 40%, #0d5c34 74%);
  box-shadow: 0 0 42px rgba(40, 190, 96, 0.85);
}
#screen-play.is-red .lamp {
  background: radial-gradient(circle at 38% 34%, #fff5f2, #ff5b48 40%, #8d1420 74%);
  box-shadow: 0 0 48px rgba(226, 48, 48, 0.9);
}
#cue {
  font-size: clamp(64px, 12vw, 128px);
  line-height: 1.05;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#sub {
  margin: 8px 0 0;
  font-size: 18px;
  color: var(--muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
}
.scores li {
  background: rgba(8, 14, 16, 0.46);
  border: 1px solid rgba(255, 248, 236, 0.16);
  border-radius: 999px;
  padding: 6px 12px;
}
.scores li.foul { color: #ffb4ae; }
.scores li.win,
.scores li.champ { outline: 2px solid var(--gold); }
.play-actions {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 3;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(20, 12, 12, 0.92);
  color: #fff6f2;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 5;
}

@media (max-width: 640px) {
  .row, .actions, .rooms li { align-items: stretch; }
  .rooms li, .actions { flex-direction: column; }
  .lamp { width: 96px; }
  #cue { font-size: 56px; }
}
