:root {
  color-scheme: light;
  --paper: #fff9ef;
  --card: rgba(255, 255, 255, 0.88);
  --ink: #2c211b;
  --muted: #786a60;
  --line: #e8d9c8;
  --orange: #f36c2f;
  --orange-dark: #d94f17;
  --orange-soft: #fff0e3;
  --yellow: #ffca55;
  --pink: #f48ea8;
  --blue: #74b9e7;
  --green: #77c6a1;
  --red: #d94841;
  --shadow: 0 22px 70px rgba(79, 47, 24, 0.12);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  line-height: 1.55;
  word-break: keep-all;
}

button, input, textarea { font: inherit; }
button { color: inherit; touch-action: manipulation; }
button, input, textarea { outline: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  box-shadow: 0 0 0 4px rgba(243, 108, 47, 0.23);
}
[hidden] { display: none !important; }

.background {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.background::before {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(106, 73, 48, 0.11) 0.8px, transparent 0.8px);
  background-size: 24px 24px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.48;
}

.blob-one {
  top: -220px;
  right: -180px;
  width: 620px;
  height: 620px;
  background: #ffdca4;
}

.blob-two {
  bottom: -300px;
  left: -220px;
  width: 680px;
  height: 680px;
  background: #ffd6c1;
}

.bean {
  position: absolute;
  color: rgba(126, 75, 42, 0.12);
  font-size: 42px;
  transform: scaleX(0.62) rotate(22deg);
}

.bean::after {
  position: absolute;
  top: 44%;
  left: 25%;
  width: 52%;
  height: 3px;
  border-radius: 999px;
  background: var(--paper);
  content: "";
  transform: rotate(-26deg);
}

.bean-one { top: 18%; left: 7%; }
.bean-two { right: 6%; bottom: 16%; transform: scaleX(0.62) rotate(-18deg); }
.bean-three { bottom: 7%; left: 46%; font-size: 28px; transform: scaleX(0.62) rotate(52deg); }

.topbar {
  display: flex;
  width: min(100% - 40px, 1240px);
  height: 92px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: "Jua", sans-serif;
  font-size: 1.45rem;
}

.brand-cup {
  display: grid;
  width: 46px;
  height: 46px;
  border: 2px solid #8d5635;
  border-radius: 14px;
  background: #fff;
  font-size: 23px;
  place-items: center;
  transform: rotate(-5deg);
  box-shadow: 3px 4px 0 #e5c6aa;
}

.topbar-actions, .connection { display: flex; align-items: center; }
.topbar-actions { gap: 10px; }

.connection {
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.connection-dot, .live-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
}

.connection[data-state="online"] .connection-dot, .live-pill i {
  background: #36b775;
  box-shadow: 0 0 0 4px rgba(54, 183, 117, 0.12);
}
.connection[data-state="error"] .connection-dot { background: var(--red); }

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  place-items: center;
}

#app {
  width: min(100% - 40px, 1240px);
  margin: 0 auto;
  padding: 34px 0 80px;
}

.view { animation: view-in 420ms cubic-bezier(0.16, 1, 0.3, 1); }

.landing-view {
  display: grid;
  min-height: calc(100vh - 206px);
  grid-template-columns: minmax(0, 0.88fr) minmax(480px, 1.12fr);
  align-items: center;
  gap: 72px;
}

.eyebrow, .panel-kicker {
  color: var(--orange-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 18px;
  padding: 6px 11px;
  border: 1px solid rgba(243, 108, 47, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
}

h1, h2, p { margin-top: 0; }

.hero-copy h1 {
  margin-bottom: 24px;
  font-family: "Jua", sans-serif;
  font-size: clamp(3.7rem, 6.8vw, 6.6rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.hero-copy h1 em {
  position: relative;
  color: var(--orange);
  font-style: normal;
}

.hero-copy h1 em::after {
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 9px;
  border-radius: 50%;
  border-top: 4px solid var(--yellow);
  content: "";
  transform: rotate(-2deg);
}

.hero-description {
  margin-bottom: 32px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions, .setup-actions, .draw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 17px;
  border: 1.5px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  transition: transform 130ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-large { min-height: 57px; padding: 14px 23px; border-radius: 16px; font-size: 1rem; }

.button-primary {
  border-color: var(--orange);
  background: linear-gradient(140deg, #ff7f43, var(--orange));
  color: white;
  box-shadow: 0 10px 24px rgba(217, 79, 23, 0.22), inset 0 1px rgba(255, 255, 255, 0.24);
}

.button-primary:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(217, 79, 23, 0.3); }
.button-secondary { border-color: var(--line); background: rgba(255, 255, 255, 0.82); color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: #d7bea7; background: white; }
.button-dark { background: var(--ink); color: #fff; }
.button-danger-solid { background: var(--red); color: #fff; }
.hero-actions .button:first-child { min-width: 180px; }

.join-card {
  display: grid;
  margin-top: 38px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
}

.join-card label { font-size: 0.91rem; font-weight: 900; }
.join-card p, .form-hint { margin: 3px 0 0; color: var(--muted); font-size: 0.75rem; }
.join-form { display: flex; gap: 8px; }

input {
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border 160ms ease, box-shadow 160ms ease;
}
input:focus { border-color: var(--orange); }
input::placeholder { color: #aa9a8f; }

#join-code {
  width: 142px;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.hero-visual {
  position: relative;
  width: min(100%, 610px);
  margin-left: auto;
  padding: 28px;
}

.demo-card {
  position: relative;
  padding: 26px 30px 23px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 38px;
  background: rgba(255, 255, 255, 0.83);
  box-shadow: var(--shadow);
  transform: rotate(1.2deg);
  backdrop-filter: blur(18px);
}

.demo-people, .demo-prizes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
}

.demo-people span {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  font-size: 0.78rem;
}
.demo-people .demo-winner b {
  position: relative;
  animation: demo-winner-name 7s 0.4s ease-in-out infinite;
}
.demo-people .demo-winner em {
  position: absolute;
  top: 50%;
  left: calc(100% + 4px);
  display: block;
  margin: 0;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 0.55rem;
  font-style: normal;
  opacity: 0;
  white-space: nowrap;
  animation: demo-winner-badge 7s 0.4s ease-in-out infinite;
}
.demo-people .demo-winner .avatar {
  animation: demo-winner-avatar 7s 0.4s ease-in-out infinite;
}

.avatar {
  display: grid;
  width: 47px;
  height: 47px;
  border: 3px solid white;
  border-radius: 50%;
  color: #4b382d;
  font-size: 0.9rem;
  font-style: normal;
  font-weight: 900;
  place-items: center;
  box-shadow: 0 3px 10px rgba(65, 36, 18, 0.15);
}

.avatar-yellow { background: var(--yellow); }
.avatar-pink { background: var(--pink); }
.avatar-blue { background: var(--blue); }
.avatar-green { background: var(--green); }

.demo-ladder {
  display: block;
  width: 100%;
  height: auto;
  margin: 8px 0 0;
  overflow: visible;
}

.demo-rail, .demo-line, .demo-route-track, .demo-route {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.demo-rail { stroke: var(--ink); stroke-width: 5; }
.demo-line { stroke: var(--ink); stroke-width: 8; }
.line-a, .line-b, .line-c, .line-d { stroke: var(--ink); }
.demo-route {
  stroke: var(--red);
  stroke-dasharray: 456;
  stroke-dashoffset: 456;
  stroke-width: 9;
  animation: demo-route 7s 0.4s ease-in-out infinite;
}
.demo-route-track { stroke: var(--ink); stroke-width: 9; opacity: 1; }

.demo-prizes span {
  padding: 8px 5px;
  border-radius: 10px;
  background: #f4eee7;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
}
.demo-prizes { margin-top: 20px; }
.demo-prizes .winner { background: var(--orange-soft); color: var(--orange-dark); }

.scribble {
  position: absolute;
  top: -42px;
  right: -12px;
  z-index: 2;
  margin: 0;
  font-family: "Jua", sans-serif;
  font-size: 1rem;
  line-height: 1.25;
  text-align: right;
  transform: rotate(-5deg);
}
.scribble strong { color: var(--orange-dark); font-size: 1.17rem; }
.scribble span {
  position: absolute;
  right: 14px;
  bottom: -31px;
  font-size: 2rem;
  transform: rotate(-8deg);
}

.room-view { padding-top: 6px; }
.room-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.room-heading .eyebrow { margin-bottom: 10px; }
.room-heading h1 {
  margin-bottom: 6px;
  font-family: "Jua", sans-serif;
  font-size: clamp(2.1rem, 4vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1;
}
.room-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 0.9rem; }

.invite-box {
  display: grid;
  min-width: 226px;
  padding: 13px 15px;
  border: 1px dashed #d8b694;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
}
.invite-box span { color: var(--muted); font-size: 0.69rem; font-weight: 800; }
.invite-box strong { font-size: 1.3rem; letter-spacing: 0.13em; }
.mini-button {
  grid-column: 2;
  grid-row: 1 / 3;
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 800;
}

.stepper {
  display: grid;
  width: min(100%, 700px);
  margin: 34px auto 26px;
  grid-template-columns: auto 1fr auto 1fr auto 1fr auto;
  align-items: center;
}
.stepper > i { height: 2px; background: var(--line); }
.step {
  display: flex;
  position: relative;
  align-items: center;
  gap: 7px;
  color: #aa9b90;
  font-size: 0.75rem;
}
.step span {
  display: grid;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  font-size: 0.7rem;
  place-items: center;
}
.step.active, .step.complete { color: var(--ink); }
.step.active span { border-color: var(--orange); background: var(--orange); color: white; }
.step.complete span { border-color: var(--orange); color: var(--orange); }

.room-grid { display: grid; grid-template-columns: 294px minmax(0, 1fr); gap: 18px; }
.panel {
  border: 1px solid rgba(228, 210, 193, 0.9);
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 16px 50px rgba(81, 48, 26, 0.08);
  backdrop-filter: blur(14px);
}
.side-panel { align-self: start; padding: 23px; }
.main-panel { min-height: 570px; overflow: hidden; }
.panel-title, .section-heading, .ladder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.panel-title h2, .section-heading h2, .ladder-toolbar h2 { margin: 3px 0 0; font-size: 1.25rem; }
.panel-title h2 b { color: var(--orange); }
.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #ebf9f2;
  color: #24865a;
  font-size: 0.62rem;
  font-weight: 900;
}

.nickname-form {
  margin: 21px 0 17px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}
.nickname-form label { display: block; margin-bottom: 7px; font-size: 0.77rem; font-weight: 800; }
.input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}
.input-row input { width: 100%; min-width: 0; padding-inline: 10px; }
.input-row .button { width: 100%; }
.pin-input { letter-spacing: 0.05em; }
.nickname-form.locked .input-row { position: relative; }
.nickname-form.locked .input-row > * { opacity: 0.3; pointer-events: none; filter: grayscale(0.4); }
.nickname-form.locked .input-row::after {
  content: attr(data-lock-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--orange);
  border-radius: 12px;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.participant-list {
  display: grid;
  margin: 0;
  padding: 0;
  overflow: visible;
  gap: 7px;
  list-style: none;
}
.participant-item {
  display: grid;
  min-height: 49px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #faf5ee;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  transition: transform 260ms ease;
}
.participant-item.reorderable { grid-template-columns: auto auto auto minmax(0, 1fr) auto; }
.participant-item.reorderable,
.prize-card.reorderable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.participant-item.reorderable:active,
.prize-card.reorderable:active { cursor: grabbing; }
.participant-item.dragging, .prize-card.dragging {
  z-index: 5;
  opacity: 0.55;
  transform: scale(0.98);
}
.participant-item.drag-over, .prize-card.drag-over {
  outline: 2px dashed var(--orange);
  outline-offset: 2px;
}
.participant-item.me { border-color: rgba(243, 108, 47, 0.34); background: var(--orange-soft); }
.participant-order {
  display: grid;
  width: 25px;
  height: 25px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 950;
  place-items: center;
}
.participant-item .avatar { width: 31px; height: 31px; border-width: 2px; font-size: 0.68rem; }
.participant-name {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cancel-participant {
  width: auto;
  height: 27px;
  padding: 0 8px;
  border: 1px solid rgba(217, 72, 65, 0.28);
  border-radius: 8px;
  background: rgba(217, 72, 65, 0.1);
  color: var(--red);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 900;
}
.empty-list { padding: 28px 8px; color: var(--muted); font-size: 0.8rem; text-align: center; }
.drag-handle {
  display: grid;
  width: 25px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b39e8d;
  cursor: grab;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.2em;
  place-items: center;
  touch-action: none;
  user-select: none;
}
.drag-handle:hover { background: rgba(243, 108, 47, 0.09); color: var(--orange-dark); }
.drag-handle:active { cursor: grabbing; }
.reorder-hint {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.69rem;
  text-align: center;
}
.reorder-hint span { color: var(--orange); font-weight: 900; }

.stage-panel {
  display: grid;
  min-height: 570px;
  padding: 38px;
  align-content: center;
}
#waiting-panel { justify-items: center; text-align: center; }
.waiting-illustration { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.waiting-illustration span {
  display: grid;
  width: 68px;
  height: 68px;
  border: 1px solid #ead6c3;
  border-radius: 23px;
  background: #fff9f0;
  font-size: 30px;
  place-items: center;
  animation: cup-bob 2.2s ease-in-out infinite alternate;
}
.waiting-illustration span:nth-of-type(2) { animation-delay: -0.7s; }
.waiting-illustration span:nth-of-type(3) { animation-delay: -1.4s; }
.waiting-illustration i { color: #c7aa91; font-style: normal; font-weight: 900; }
.stage-panel > h2 { margin-bottom: 8px; font-family: "Jua", sans-serif; font-size: 2.25rem; font-weight: 400; }
.stage-panel > p { margin-bottom: 25px; color: var(--muted); font-size: 0.9rem; }
.waiting-note { padding: 11px 15px; border-radius: 12px; background: #f7f0e7; }

#setup-panel { align-content: start; }
.count-chip {
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 0.78rem;
  font-weight: 800;
}
.winner-control {
  display: grid;
  margin: 42px 0 35px;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}
.count-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 800;
}
input[type="range"] { min-height: auto; padding: 0; border: 0; accent-color: var(--orange); }
.prize-preview {
  display: grid;
  min-height: 190px;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  align-items: start;
  gap: 10px;
}
.prize-reorder-hint { margin: 28px 0 10px; text-align: left; }
.prize-card {
  position: relative;
  display: grid;
  min-height: 112px;
  padding: 13px 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #faf6f0;
  align-content: center;
  justify-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1);
}
.prize-card .drag-handle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  height: 28px;
  letter-spacing: -0.25em;
}
.prize-card span { display: grid; width: 43px; height: 43px; border-radius: 50%; background: #eee4da; place-items: center; }
.prize-card.winner { border-color: rgba(243, 108, 47, 0.35); background: var(--orange-soft); color: var(--orange-dark); }
.prize-card.winner span { background: #ffd4bc; font-size: 1.25rem; }
.setup-actions { justify-content: flex-end; margin-top: 28px; }

.ladder-stage { min-height: 650px; padding: 27px 27px 23px; align-content: start; }
.ladder-toolbar { margin-bottom: 18px; }
.tool-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.tool-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}
.tool-button.active { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-dark); }
.tool-button.generate { border-color: var(--ink); background: var(--yellow); color: var(--ink); }
.tool-button.generate:hover:not(:disabled) { transform: translateY(-1px) rotate(-1deg); }
.tool-button.danger { color: var(--red); }
.ladder-scroll { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.ladder-canvas-wrap { width: 100%; min-width: 320px; }
.ladder-labels { display: grid; min-height: 53px; align-items: center; }
.ladder-label {
  display: grid;
  min-width: 0;
  padding: 4px;
  justify-items: center;
  gap: 3px;
  text-align: center;
}
.ladder-label .avatar { width: 34px; height: 34px; font-size: 0.7rem; }
.ladder-label b { max-width: 100%; overflow: hidden; font-size: 0.69rem; text-overflow: ellipsis; white-space: nowrap; }
.bottom-labels .ladder-label {
  min-height: 48px;
  align-content: center;
  border-radius: 11px;
  background: #f5eee7;
  color: var(--muted);
}
.bottom-labels .ladder-label.winner { background: var(--orange-soft); color: var(--orange-dark); }
.ladder-svg {
  display: block;
  width: 100%;
  height: 390px;
  border-top: 1px dashed #eadfd5;
  border-bottom: 1px dashed #eadfd5;
  background: rgba(255, 252, 247, 0.68);
  cursor: crosshair;
  user-select: none;
  touch-action: pan-x;
}
.ladder-svg[data-tool="delete"] { cursor: not-allowed; }
.ladder-rail { stroke: #cdb9aa; stroke-linecap: round; stroke-width: 5; vector-effect: non-scaling-stroke; }
.ladder-hit { stroke: transparent; stroke-width: 28; vector-effect: non-scaling-stroke; }
.ladder-line { stroke: var(--orange); stroke-linecap: round; stroke-width: 8; transition: stroke 120ms ease, stroke-width 120ms ease; vector-effect: non-scaling-stroke; }
.ladder-group:hover .ladder-line { stroke: var(--orange-dark); stroke-width: 11; }
.ladder-preview { stroke: rgba(243, 108, 47, 0.42); stroke-dasharray: 8 7; stroke-linecap: round; stroke-width: 7; vector-effect: non-scaling-stroke; }
.ladder-route {
  fill: none;
  stroke: var(--red);
  stroke-linecap: butt;
  stroke-linejoin: round;
  stroke-width: 10;
  filter: drop-shadow(0 0 4px rgba(217, 72, 65, 0.28)) drop-shadow(0 2px 2px white);
  vector-effect: non-scaling-stroke;
}
.ladder-runner {
  fill: var(--red);
  stroke: white;
  stroke-width: 4;
  filter: drop-shadow(0 3px 7px rgba(217, 79, 23, 0.45));
}
.ladder-tip { margin: 12px 0 13px !important; font-size: 0.72rem !important; text-align: center; }
.draw-speed {
  width: min(100%, 380px);
  margin: 10px auto 17px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f3ed;
}
.draw-speed label,
.draw-speed > div { display: flex; align-items: center; justify-content: space-between; }
.draw-speed label { margin-bottom: 5px; font-size: 0.76rem; font-weight: 850; }
.draw-speed label b { color: var(--orange-dark); font-size: 0.9rem; }
.draw-speed input {
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: grab;
}
.draw-speed input:active { cursor: grabbing; }
.draw-speed input::-webkit-slider-runnable-track {
  height: 7px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--green));
}
.draw-speed input::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  appearance: none;
  background: white;
  box-shadow: 2px 2px 0 var(--ink);
}
.draw-speed input::-moz-range-track {
  height: 7px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--green));
}
.draw-speed input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: white;
  box-shadow: 2px 2px 0 var(--ink);
}
.draw-speed > div { color: var(--muted); font-size: 0.62rem; font-weight: 700; }
.draw-actions { justify-content: center; }
.result-pop { animation: result-pop 520ms cubic-bezier(0.16, 1, 0.3, 1); }

.modal-backdrop {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 20px;
  background: rgba(50, 33, 23, 0.52);
  backdrop-filter: blur(8px);
  place-items: center;
}
.modal {
  position: relative;
  width: min(100%, 470px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 30px 100px rgba(33, 19, 11, 0.3);
  animation: modal-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-small { width: min(100%, 410px); }
.modal h2 { margin-bottom: 8px; font-family: "Jua", sans-serif; font-size: 2rem; font-weight: 400; }
.modal > p:not(.eyebrow) { margin-bottom: 23px; color: var(--muted); font-size: 0.88rem; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(44, 33, 27, 0.07);
  cursor: pointer;
  font-size: 1.4rem;
}
.modal-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 20px;
  background: var(--orange-soft);
  font-size: 30px;
  place-items: center;
  transform: rotate(-5deg);
}
.modal-icon-small { width: 54px; height: 54px; font-size: 25px; }
.success-modal-icon { background: #e7f7ee; color: #21875a; font-weight: 900; }
.modal form { display: grid; gap: 12px; }
.modal label { margin-bottom: -5px; font-size: 0.78rem; font-weight: 800; }
.cancel-step > p:not(.eyebrow) { margin-bottom: 23px; color: var(--muted); font-size: 0.88rem; }
.cancel-actions { display: grid; gap: 9px; }

.share-modal label { display: block; margin-bottom: 7px; font-size: 0.78rem; font-weight: 800; }
.share-preview {
  position: relative;
  overflow: hidden;
  margin: 18px 0;
  padding: 19px;
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  background: var(--green);
  box-shadow: 5px 5px 0 var(--ink);
}
.share-preview::after {
  position: absolute;
  top: -28px;
  right: -22px;
  width: 90px;
  height: 90px;
  border: 18px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  content: "";
}
.share-preview > span { display: block; font-size: 0.69rem; font-weight: 950; letter-spacing: 0.13em; }
.share-preview > strong { display: block; margin-top: 5px; font-size: 1.35rem; line-height: 1.25; }
.share-preview > p { margin: 5px 0 15px; color: var(--ink); font-size: 0.82rem; }
.share-preview > div { display: flex; align-items: baseline; gap: 10px; }
.share-preview small { font-size: 0.69rem; font-weight: 800; }
.share-preview b { font-family: "Arial Black", sans-serif; font-size: 1.25rem; letter-spacing: 0.12em; }
.share-preview a {
  display: block;
  overflow: hidden;
  margin-top: 9px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 750;
  text-decoration: underline;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-modal textarea {
  width: 100%;
  min-height: 150px;
  padding: 14px;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: #f4f2eb;
  color: var(--ink);
  line-height: 1.65;
  resize: none;
}
.share-actions { display: grid; margin-top: 12px; grid-template-columns: 1.2fr 0.8fr; gap: 9px; }
.share-actions.has-native-share { grid-template-columns: 1.2fr 1fr 0.8fr; }

.result-modal { width: min(100%, 560px); }
.result-modal-icon { background: var(--red); color: white; font-weight: 900; }
.result-summary {
  display: grid;
  max-height: min(48vh, 430px);
  margin: 4px 0 24px;
  overflow-y: auto;
  gap: 9px;
}
.result-summary-item {
  display: grid;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #eeede7;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}
.result-summary-item .avatar { width: 38px; height: 38px; }
.result-summary-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-summary-item strong { font-size: 0.86rem; }
.result-summary-item.winner {
  border-color: var(--red);
  background: var(--red);
  color: white;
}
.result-summary-item.winner .avatar {
  border-color: white;
  background: white;
  color: var(--red);
}
.result-modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.toast-region {
  display: grid;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: min(360px, calc(100% - 44px));
  gap: 9px;
  pointer-events: none;
}
.toast {
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 13px;
  background: #2c211b;
  color: white;
  box-shadow: 0 12px 32px rgba(42, 25, 16, 0.24);
  font-size: 0.79rem;
  font-weight: 700;
  animation: toast-in 250ms ease;
}
.toast.error { background: #a92f2a; }

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}
.confetti {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall 2.8s ease-in forwards;
}

@keyframes demo-route {
  0% { stroke-dashoffset: 456; }
  90%, 98% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 456; }
}
@keyframes demo-winner-name {
  0%, 89%, 100% { color: var(--ink); }
  90%, 98% { color: var(--red); }
}
@keyframes demo-winner-badge {
  0%, 89%, 100% { opacity: 0; transform: translateY(-50%) scale(0.7); }
  90%, 98% { opacity: 1; transform: translateY(-50%) scale(1); }
}
@keyframes demo-winner-avatar {
  0%, 89%, 100% { border-color: var(--ink); box-shadow: none; }
  90%, 98% {
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(217, 72, 65, 0.13);
  }
}
@keyframes cup-bob {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-8px) rotate(3deg); }
}
@keyframes view-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(15px) scale(0.96); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes result-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
}
@keyframes confetti-fall {
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(720deg); }
}

/* Reference-led editorial UI: warm paper, black linework, lime accent. */
:root {
  --paper: #f4f2eb;
  --card: #fbfaf6;
  --ink: #1d1d1b;
  --muted: #74736d;
  --line: #d9d7cf;
  --orange: #1d1d1b;
  --orange-dark: #11110f;
  --orange-soft: #edf5e7;
  --yellow: #a9e765;
  --pink: #e8e7e0;
  --blue: #deddd6;
  --green: #cfeaaf;
  --shadow: 0 18px 50px rgba(29, 29, 27, 0.07);
}

.background::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 60%);
  mask-image: none;
}

.blob, .bean { display: none; }

.brand {
  font-family: "Noto Sans KR", sans-serif;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.brand::after {
  width: 8px;
  height: 8px;
  margin: 8px 0 0 -8px;
  border-radius: 50%;
  background: var(--yellow);
  content: "";
}

.brand-cup {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  transform: rotate(-3deg);
  box-shadow: 3px 3px 0 var(--ink);
  overflow: hidden;
}

.brand-cup img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: contain;
}

.connection, .icon-button { background: var(--card); }

.eyebrow {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.hero-copy h1 {
  font-family: "Noto Sans KR", sans-serif;
  font-size: clamp(3.2rem, 5.8vw, 5.7rem);
  font-weight: 900;
  letter-spacing: -0.075em;
  line-height: 1.08;
}

.hero-copy h1 em { color: var(--ink); }
.hero-copy h1 em::after { display: none; }

.hero-copy h1 .word-pop {
  display: inline-flex;
  align-items: baseline;
  gap: 0.02em;
}

.hero-copy h1 .hero-line { display: block; }
.hero-subtitle {
  margin: 20px 0 28px;
  color: var(--muted);
  font-family: "Jua", sans-serif;
  font-size: clamp(0.94rem, 1.65vw, 1.35rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.45;
  white-space: nowrap;
}
.hero-subtitle strong {
  display: inline-block;
  color: var(--orange);
  font-weight: 400;
  transform: rotate(-1.5deg);
}

.hero-copy h1 .word-pop span {
  display: inline-block;
}

.hero-copy h1 .word-pop span:nth-child(1) {
  color: #f36c2f;
  transform: rotate(-3deg);
}

.hero-copy h1 .word-pop span:nth-child(2) {
  color: #62b832;
  transform: translateY(-0.04em) rotate(2deg);
}

.hero-copy h1 .word-pop span:nth-child(3) {
  color: #f36c2f;
  transform: rotate(-2deg);
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: none;
}

.button-primary:hover:not(:disabled) {
  background: #363633;
  box-shadow: none;
}

.button-secondary {
  border-color: var(--ink);
  background: transparent;
}

.join-card {
  border-radius: 16px;
  background: transparent;
}

.demo-card {
  border: 2px solid var(--ink);
  border-radius: 28px;
  background: var(--card);
  box-shadow: 8px 8px 0 var(--ink);
  transform: rotate(0.4deg);
  backdrop-filter: none;
}

.avatar {
  border: 2px solid var(--ink);
  color: var(--ink);
  box-shadow: none;
}

.avatar-yellow { background: var(--yellow); }
.avatar-pink { background: #f3f2ed; }
.avatar-blue { background: #e3e2dc; }
.avatar-green { background: var(--green); }
.demo-rail { stroke: var(--ink); stroke-width: 4; }
.line-a, .line-b, .line-c, .line-d { stroke: var(--ink); }
.demo-route { stroke: #78b43c; }
.demo-route { stroke: var(--red); }

.demo-prizes span {
  border: 1px solid var(--line);
  background: transparent;
}

.demo-prizes .winner {
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.room-heading h1, .stage-panel > h2, .modal h2 {
  font-family: "Noto Sans KR", sans-serif;
  font-weight: 900;
}

.invite-box, .panel {
  background: var(--card);
  backdrop-filter: none;
}

.panel {
  border-radius: 22px;
  box-shadow: none;
}

.participant-item { background: #f1f0ea; }
.participant-item.me {
  border-color: var(--ink);
  background: var(--orange-soft);
}
.participant-item.winner {
  border-color: var(--red);
  background: var(--red);
  color: white;
}
.participant-item.winner .participant-order,
.participant-item.winner .avatar {
  border-color: white;
  background: white;
  color: var(--red);
}
.participant-item.winner .cancel-participant {
  border-color: white;
  background: white;
  color: var(--red);
}

.waiting-illustration span {
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  background: transparent;
  filter: grayscale(1);
}

.waiting-note { background: #eeede7; }
.count-chip { color: var(--ink); }

.prize-card { background: #f1f0ea; }
.prize-card.winner {
  border-color: var(--ink);
  background: var(--yellow);
  color: var(--ink);
}

.prize-card.winner span {
  background: rgba(255, 255, 255, 0.58);
}

.ladder-svg { background: #f7f6f1; }
.ladder-rail { stroke: var(--ink); stroke-width: 4; }
.ladder-line { stroke: var(--ink); stroke-width: 7; }
.ladder-group:hover .ladder-line { stroke: #000; }
.ladder-preview { stroke: rgba(31, 30, 28, 0.48); }
.ladder-route { stroke: var(--red); }
.ladder-runner {
  fill: var(--red);
  stroke: white;
}

.bottom-labels .ladder-label { background: #eeede7; }
.bottom-labels .ladder-label.winner {
  border: 1px solid var(--red);
  background: var(--red);
  color: white;
}
.bottom-labels .ladder-label.pending {
  margin-inline: 3px;
  border: 1px solid white;
  background: var(--ink);
  color: white;
}

.top-labels .ladder-label.winner-found .avatar {
  border-color: var(--red);
  background: var(--red);
  color: white;
  box-shadow: 0 0 0 4px rgba(217, 72, 65, 0.15);
}

.top-labels .ladder-label.winner-found b {
  color: var(--red);
}

.modal {
  border-color: var(--ink);
  background: var(--card);
  box-shadow: 8px 8px 0 var(--ink);
}

.modal-icon {
  border: 1px solid var(--ink);
  background: var(--yellow);
  filter: grayscale(0.25);
}

.toast { background: var(--ink); }

@media (max-width: 980px) {
  .landing-view { grid-template-columns: 1fr; gap: 40px; }
  .hero-copy { max-width: 680px; margin: 20px auto 0; text-align: center; }
  .hero-actions { justify-content: center; }
  .hero-visual { margin: 0 auto; }
  .join-card { text-align: left; }
  .room-grid { grid-template-columns: 1fr; }
  .side-panel { width: 100%; }
  .participant-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { width: min(100% - 28px, 1240px); height: 74px; }
  .brand { font-size: 1.12rem; }
  .brand-cup { width: 44px; height: 44px; font-size: 19px; }
  .connection { padding: 7px 9px; }
  #connection-label { display: none; }
  #app { width: min(100% - 24px, 1240px); padding: 18px 0 55px; }
  .hero-copy h1 { font-size: clamp(3.15rem, 16vw, 4.5rem); }
  .hero-description { font-size: 0.92rem; }
  .desktop-only { display: none; }
  .hero-actions { display: grid; }
  .join-card { grid-template-columns: 1fr; }
  .join-form { width: 100%; }
  #join-code { width: 100%; }
  .hero-visual { padding: 14px 0 42px; }
  .demo-card { padding: 22px 14px 17px; border-radius: 26px; }
  .scribble { top: -32px; right: 4px; }
  .room-heading { align-items: flex-start; flex-direction: column; }
  .invite-box { width: 100%; }
  .stepper { margin: 24px 0 18px; }
  .step b { display: none; }
  .panel { border-radius: 22px; }
  .side-panel { padding: 18px; }
  .participant-list { grid-template-columns: 1fr; }
  .input-row { grid-template-columns: 1fr; }
  .input-row .pin-input, .input-row .button { grid-column: auto; grid-row: auto; }
  .stage-panel { min-height: 490px; padding: 26px 18px; }
  .waiting-illustration span { width: 56px; height: 56px; border-radius: 18px; }
  .section-heading, .ladder-toolbar { align-items: flex-start; flex-direction: column; }
  .winner-control { margin: 30px 0 26px; }
  .prize-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-actions { display: grid; }
  .ladder-stage { min-height: 610px; padding: 22px 12px; }
  .tool-actions { justify-content: flex-start; }
  .modal { padding: 31px 23px 24px; }
  .result-modal-actions { grid-template-columns: 1fr; }
  .share-actions,
  .share-actions.has-native-share { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .demo-route {
    animation-duration: 7s !important;
    animation-iteration-count: infinite !important;
  }
  .demo-people .demo-winner b,
  .demo-people .demo-winner em,
  .demo-people .demo-winner .avatar {
    animation-duration: 7s !important;
    animation-iteration-count: infinite !important;
  }
}
