/* closeby: a booth machine you open in a browser.
   Themes swap the paper, accent, and ink tokens; everything else stays put. */

:root,
[data-theme='cream'] {
  --paper: #fbf5e9;
  --panel: #fffdf7;
  --soft: #f1e1c0;
  --accent: #eda83f;
  --ink: #2e2521;
  --ink-2: #6b5d55;
  --booth: #2e2521;
}
[data-theme='pink'] {
  --paper: #ffeff3;
  --panel: #fffafb;
  --soft: #f9cad8;
  --accent: #ec6a92;
  --ink: #3b1d2a;
  --ink-2: #7a5564;
  --booth: #3b1d2a;
}
[data-theme='blue'] {
  --paper: #edf2ff;
  --panel: #fafbff;
  --soft: #ccd9fb;
  --accent: #7c95fa;
  --ink: #1b2445;
  --ink-2: #545d7f;
  --booth: #1b2445;
}
[data-theme='mint'] {
  --paper: #e8f6ef;
  --panel: #f8fdfa;
  --soft: #c2e6d3;
  --accent: #3db386;
  --ink: #15342a;
  --ink-2: #4c6a5f;
  --booth: #15342a;
}

:root {
  --display: 'Bagel Fat One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Gowun Dodum', 'Apple SD Gothic Neo', system-ui, sans-serif;
  --line: 2.5px;
  --gutter: clamp(16px, 4vw, 40px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  transition: background-color 0.35s ease;
}

h1,
h2 {
  font-family: var(--display);
  font-weight: 400;
  margin: 0;
}

p {
  margin: 0;
}

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

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  padding: 0.55em 1.15em;
  font-size: 16px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:hover {
  background: var(--soft);
}
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--ink);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary,
.btn-primary:hover {
  background: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
}
.btn-big {
  font-family: var(--display);
  font-size: 22px;
  padding: 0.62em 1.5em;
  box-shadow: 0 5px 0 var(--ink);
}
.btn-big:active:not(:disabled) {
  transform: translateY(5px);
}
.btn-small {
  font-size: 14px;
  padding: 0.4em 0.9em;
  box-shadow: 0 2px 0 var(--ink);
}
.btn-quiet,
.btn-quiet:hover {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px var(--gutter);
}
.brand {
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}
.room-chip {
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  padding: 0.2em 0.85em;
  background: var(--panel);
  font-size: 15px;
}
.room-chip strong {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.08em;
  margin-left: 0.25em;
}
.net-status {
  margin-left: auto;
  font-size: 15px;
  background: var(--ink);
  color: var(--panel);
  border-radius: 999px;
  padding: 0.25em 0.9em;
}

main {
  padding-inline: var(--gutter);
  padding-bottom: 48px;
}

/* ---------- Shared machine parts ---------- */

.curtain {
  position: relative;
  height: 40px;
  background:
    repeating-linear-gradient(90deg, transparent 0 20px, rgb(0 0 0 / 0.1) 20px 22px, transparent 22px 44px),
    var(--accent);
  border-bottom: 0;
}
.curtain::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 20px;
  background: radial-gradient(circle at 50% 0, var(--accent) 21px, transparent 22px) 0 0 / 44px 22px repeat-x;
  z-index: 2;
  pointer-events: none;
}

/* ---------- Landing ---------- */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
  max-width: 1140px;
  margin: 0 auto;
  padding-block: clamp(16px, 5vh, 64px);
}
.landing h1 {
  font-size: clamp(42px, 6.2vw, 80px);
  line-height: 1.02;
  max-width: 11ch;
  letter-spacing: -0.01em;
}
.lede {
  margin: 22px 0 30px;
  max-width: 46ch;
  font-size: 19px;
  color: var(--ink-2);
}
.join {
  margin-top: 36px;
  max-width: 440px;
}
.join label {
  display: block;
  margin-bottom: 8px;
}
.join-row {
  display: flex;
  gap: 10px;
}
.join-row input {
  flex: 1;
  min-width: 0;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  padding: 0.55em 1em;
  background: var(--panel);
  font-family: var(--display);
  letter-spacing: 0.12em;
  font-size: 18px;
  text-transform: uppercase;
}
.join-row input::placeholder {
  color: var(--ink-2);
  opacity: 0.45;
}
.form-error {
  min-height: 1.5em;
  margin-top: 8px;
  font-size: 15px;
  color: #b0283f;
}
.how {
  list-style: none;
  counter-reset: how;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  color: var(--ink-2);
}
.how li {
  counter-increment: how;
  display: flex;
  align-items: center;
  gap: 12px;
}
.how li::before {
  content: counter(how);
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  font-family: var(--display);
  font-size: 14px;
  color: var(--ink);
}

.machine-art {
  position: relative;
  isolation: isolate;
  justify-self: center;
  width: min(360px, 100%);
  padding-bottom: 210px;
}
.machine {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 34px 34px 18px 18px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 10px 10px 0 var(--ink);
}
.marquee {
  font-family: var(--display);
  font-size: 34px;
  text-align: center;
  padding: 26px 0 10px;
}
.window {
  position: relative;
  margin: 0 26px;
  height: 200px;
  border-radius: 16px;
  background: var(--booth);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}
.sitter {
  width: 110px;
  height: 150px;
  border-radius: 55px 55px 0 0;
  background:
    radial-gradient(circle at 50% 36px, #f3c9a9 0 30px, transparent 31px),
    radial-gradient(ellipse 60px 70px at 50% 150px, var(--accent) 0 100%, transparent 100%);
}
.sitter-b {
  background:
    radial-gradient(circle at 50% 36px, #c98f6b 0 30px, transparent 31px),
    radial-gradient(ellipse 60px 70px at 50% 150px, var(--soft) 0 100%, transparent 100%);
}
.slot {
  margin: 22px auto 22px;
  width: 150px;
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
}
.mini-strip {
  position: absolute;
  left: 50%;
  top: calc(100% - 222px);
  width: 128px;
  margin-left: -64px;
  padding: 9px 9px 0;
  background: #fffdf8;
  border-radius: 3px;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.18);
  display: grid;
  gap: 6px;
  transform-origin: 50% 0;
  transform: rotate(4deg);
  z-index: -1;
  animation: mini-print 2.4s cubic-bezier(0.3, 0.7, 0.3, 1) 0.4s both;
}
.mini-shot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  height: 52px;
}
.mini-shot i {
  display: block;
  background:
    radial-gradient(circle at 50% 42%, var(--skin, #f3c9a9) 0 22%, transparent 23%),
    radial-gradient(ellipse 60% 44% at 50% 100%, var(--shirt, #eda83f) 0 100%, transparent 100%),
    var(--wall, #d9e6f5);
}
.mini-shot .p2,
.mini-shot .p4,
.mini-shot .p6,
.mini-shot .p8 {
  --skin: #c98f6b;
  --shirt: #3b1d2a;
  --wall: #f9cad8;
}
.mini-shot .p3 {
  --wall: #c2e6d3;
}
.mini-shot .p5 {
  --wall: #fbe7b5;
}
.mini-shot .p7 {
  --wall: #e4d9f7;
}
.mini-brand {
  font-family: var(--display);
  font-size: 13px;
  text-align: center;
  padding: 6px 0 9px;
  color: #2e2521;
}
@keyframes mini-print {
  from {
    transform: translateY(-190px) rotate(0deg);
  }
  70% {
    transform: translateY(0) rotate(0deg);
  }
  to {
    transform: translateY(0) rotate(4deg);
  }
}

/* ---------- Booth ---------- */

.booth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
  max-width: 1220px;
  margin: 0 auto;
}
.booth[data-phase='capture'] {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1040px;
}
.booth[data-phase='capture'] .lobby-panel {
  display: none;
}
.booth-machine {
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 8px 8px 0 var(--ink);
}
.stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 26px 16px 16px;
  padding: 10px;
  border-radius: 18px;
  background: var(--booth);
}
.cam {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 4;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--booth) 80%, #fff);
}
.cam video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}
#video-me {
  transform: scaleX(-1);
}
.tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.1em 0.75em;
  font-size: 14px;
  z-index: 3;
}
.cam-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  color: #fff;
  font-size: 15px;
  background: color-mix(in srgb, var(--booth) 88%, transparent);
  z-index: 2;
}
.cam-status p {
  max-width: 26ch;
}
.unmute {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
}
.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.flash.go {
  animation: flash 0.45s ease-out;
}
@keyframes flash {
  from {
    opacity: 0.95;
  }
  to {
    opacity: 0;
  }
}

.countdown {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
}
.booth[data-phase='capture'] .countdown {
  display: flex;
}
.count-num {
  font-family: var(--display);
  font-size: clamp(110px, 22vw, 220px);
  line-height: 1;
  color: var(--panel);
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink);
}
.count-num.pop {
  animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.count-label {
  margin-top: 12px;
  background: var(--panel);
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  padding: 0.2em 1em;
  font-size: 17px;
}
.count-label:empty {
  display: none;
}

.tray {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0 16px 18px;
}
.booth[data-phase='lobby'] .tray {
  display: none;
}
.tray li {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  width: 92px;
  aspect-ratio: 3 / 2;
  padding: 3px;
  border: 2px dashed var(--ink-2);
  border-radius: 8px;
  background: var(--paper);
}
.tray li.filled {
  border-style: solid;
  border-color: var(--ink);
}
.tray img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.tray span {
  border-radius: 3px;
  background: var(--soft);
}

/* ---------- Panels & form controls ---------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.panel h2,
.choice legend,
.field-label {
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.3;
}
.invite {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  background: var(--soft);
}
.invite p {
  color: var(--ink-2);
  font-size: 15px;
}
.invite-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.invite-row input,
.field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  padding: 0.5em 0.8em;
  background: var(--panel);
}
.invite-row input {
  font-size: 14px;
}
.field {
  display: grid;
  gap: 6px;
}
.choice {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.choice legend {
  padding: 0;
  margin-bottom: 8px;
}
.choice-pair {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
}

.opt {
  position: relative;
  cursor: pointer;
}
.opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.opt input:focus-visible + .opt-face {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.swatches .opt-face {
  display: grid;
  justify-items: center;
  gap: 4px;
  font-size: 14px;
  border-radius: 12px;
}
.swatch-dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: var(--line) solid var(--ink);
  background: linear-gradient(135deg, var(--sw-paper) 0 50%, var(--sw-accent) 50% 100%);
  transition: transform 0.15s ease;
}
.swatches input:checked + .opt-face .swatch-dot {
  box-shadow:
    0 0 0 3px var(--panel),
    0 0 0 6px var(--ink);
}

.segmented {
  display: inline-flex;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
}
.segmented .opt-face {
  display: block;
  padding: 0.35em 0.9em;
  font-size: 15px;
}
.segmented .opt + .opt .opt-face {
  border-left: var(--line) solid var(--ink);
}
.segmented input:checked + .opt-face {
  background: var(--accent);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 10px;
}
.tile-grid .opt-face {
  display: grid;
  justify-items: center;
  gap: 4px;
  font-size: 13px;
  text-align: center;
}
.tile-grid canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--soft);
}
.tile-grid.filters canvas {
  aspect-ratio: 3 / 4;
}
.tile-grid input:checked + .opt-face canvas {
  box-shadow:
    0 0 0 3px var(--panel),
    0 0 0 6px var(--ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--ink);
}

.lobby-actions,
.editor-actions {
  display: grid;
  gap: 10px;
  justify-items: stretch;
}
.hint {
  font-size: 15px;
  color: var(--ink-2);
  text-align: center;
}
.action-row {
  display: flex;
  gap: 10px;
}
.action-row .btn {
  flex: 1;
}

/* ---------- Editor ---------- */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: clamp(20px, 4vw, 56px);
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}
.print-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: 16px;
}
.printer {
  position: relative;
  z-index: 2;
  width: min(440px, 100%);
  height: 40px;
  border-radius: 20px;
  background: var(--ink);
  display: grid;
  place-items: center;
}
.printer-slot {
  width: 78%;
  height: 8px;
  border-radius: 999px;
  background: #000;
  opacity: 0.55;
}
.strip-wrap {
  margin-top: -4px;
  padding: 0 24px 40px;
  overflow: hidden;
  max-width: 100%;
}
#strip-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 170px);
  max-height: calc(100dvh - 170px);
  box-shadow: 0 18px 30px rgb(0 0 0 / 0.16);
}
.strip-wrap.printing #strip-canvas {
  animation: print-out 2.6s cubic-bezier(0.35, 0.6, 0.3, 1) both;
}
@keyframes print-out {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}
.together {
  font-size: 15px;
  color: var(--ink-2);
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

/* ---------- Notice ---------- */

.notice {
  display: grid;
  place-items: center;
  min-height: 60vh;
}
.notice-card {
  display: grid;
  gap: 16px;
  justify-items: start;
  max-width: 520px;
  padding: 32px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--ink);
}
.notice-card h1 {
  font-size: 34px;
  line-height: 1.1;
}
.notice-card p {
  color: var(--ink-2);
}

/* ---------- Story ---------- */

.story {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  overflow: visible;
}
.story::backdrop {
  background: rgb(18 14 12 / 0.86);
}
.story-frame {
  position: relative;
  width: min(390px, 92vw, calc((100vh - 110px) * 9 / 16));
  width: min(390px, 92vw, calc((100dvh - 110px) * 9 / 16));
  aspect-ratio: 9 / 16;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
}
.story-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.story-progress {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 3px;
  background: rgb(255 255 255 / 0.4);
  overflow: hidden;
  z-index: 2;
}
.story-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: #fff;
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.story-progress span.run {
  animation: story-bar 6s linear forwards;
}
@keyframes story-bar {
  to {
    transform: scaleX(1);
  }
}
.story-head {
  position: absolute;
  top: 22px;
  left: 12px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  z-index: 2;
}
.story-avatars {
  display: flex;
}
.story-avatars span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
  color: var(--ink);
  font-family: var(--display);
  font-size: 13px;
  text-shadow: none;
}
.story-avatars span + span {
  margin-left: -10px;
}
.story-names {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-time {
  opacity: 0.75;
}
.story-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}
.story-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: var(--panel);
  border-radius: 999px;
  padding: 0.6em 1.2em;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .landing {
    grid-template-columns: 1fr;
  }
  .machine-art {
    width: min(300px, 100%);
  }
  .booth,
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }
  .print-area {
    position: static;
  }
  #strip-canvas {
    max-height: none;
    max-width: min(100%, 360px);
  }
}

@media (max-width: 520px) {
  .stage {
    margin: 22px 10px 10px;
    padding: 6px;
    gap: 6px;
  }
  .booth-machine,
  .machine,
  .notice-card {
    box-shadow: 5px 5px 0 var(--ink);
  }
  .choice-pair {
    grid-template-columns: 1fr;
  }
  .join-row {
    flex-direction: column;
  }
  .tag {
    font-size: 12px;
  }
  .cam-status {
    font-size: 13px;
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
