:root {
  color-scheme: light;
  --panel: #e8eaf0;
  --paper: #ffffff;
  --ink: #15172b;
  --ink-soft: #5a5e75;
  --cobalt: #2b3fd6;
  --cobalt-deep: #1d2ca8;
  --flash: #ffd23f;
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --ui: "Instrument Sans", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--panel);
  color: var(--ink);
  font: 400 1rem/1.5 var(--ui);
  padding: max(20px, env(safe-area-inset-top)) 16px 32px;
}
button, label, a { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--flash); outline-offset: 3px; }

.top, .booth { max-width: 1080px; margin: 0 auto; }
.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
h1 {
  margin: 0;
  font: 800 clamp(2.6rem, 7vw, 4.25rem)/0.85 var(--display);
  color: var(--cobalt);
  letter-spacing: -0.01em;
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: inline-grid; place-items: center;
  background: var(--paper); color: var(--ink);
  box-shadow: inset 0 0 0 1px #d4d7e2;
}
.round-btn:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }
.round-btn .fs-exit, .is-fullscreen .round-btn .fs-enter { display: none; }
.is-fullscreen .round-btn .fs-exit { display: block; }

.modes {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--paper); border-radius: 999px;
  box-shadow: inset 0 0 0 1px #d4d7e2;
}
.modes button {
  border: 0; background: none; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; font-weight: 500; color: var(--ink-soft);
}
.modes button[aria-checked="true"] { background: var(--cobalt); color: #fff; }
.modes button:disabled { cursor: not-allowed; opacity: .5; }

.booth {
  display: grid; gap: 24px;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
}

.machine {
  background: var(--cobalt);
  border-radius: 32px;
  padding: 18px 18px 22px;
  color: #fff;
  box-shadow: inset 0 -6px 0 var(--cobalt-deep);
}

.stage {
  position: relative; overflow: hidden;
  aspect-ratio: var(--ratio, 1.3846);
  border-radius: 20px;
  background: #000;
  box-shadow: 0 0 0 6px var(--cobalt-deep);
}
.stage video, .stage canvas#frame { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage video { transform: scaleX(-1); }

#countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 800 clamp(7rem, 22vw, 12rem)/1 var(--display);
  color: #fff; text-shadow: 0 6px 40px rgba(0, 0, 0, .55);
}
#countdown.tick { animation: tick .7s ease-out; }
@keyframes tick { from { transform: scale(1.35); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

.poses {
  position: absolute; left: 0; right: 0; bottom: 14px;
  display: flex; justify-content: center; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
.poses li {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, .25);
}
.poses li.done { background: var(--flash); border-color: var(--flash); }

#flash { position: absolute; inset: 0; background: #fff; animation: flash .35s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

#spinner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(21, 23, 43, .6); font-weight: 600; font-size: 1.1rem;
}
#camMsg {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center;
  padding: 24px; background: var(--ink);
}
#camMsg p { margin: 0; max-width: 30ch; }

.filters {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 16px 2px 4px; margin: 0 -2px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; display: grid; gap: 6px; justify-items: center;
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: .8125rem; font-weight: 500; color: rgba(255, 255, 255, .78);
}
.filter canvas {
  width: 76px; height: 57px; border-radius: 12px; display: block;
  background: var(--cobalt-deep);
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow .15s;
}
.filter[aria-checked="true"] { color: #fff; }
.filter[aria-checked="true"] canvas { box-shadow: 0 0 0 3px var(--flash); }
.filter:focus-visible { outline: none; }
.filter:focus-visible canvas { outline: 3px solid #fff; outline-offset: 3px; }

.deck {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin-top: 14px;
}
.deck-side { display: flex; gap: 8px; }
.deck .hint { justify-content: flex-end; margin: 0; font-size: .8125rem; color: rgba(255, 255, 255, .7); }
kbd {
  font: 600 .75rem var(--ui); padding: 1px 6px; margin: 0 4px;
  border-radius: 6px; background: rgba(255, 255, 255, .16);
}

.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #fff; font-weight: 500;
}
.icon-btn:hover { background: rgba(255, 255, 255, .2); }
.upload:focus-within { outline: 3px solid var(--flash); outline-offset: 3px; }
.icon-btn:disabled, .upload.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.shutter {
  width: 84px; height: 84px; border-radius: 50%;
  border: 5px solid #fff; padding: 5px; cursor: pointer;
  background: transparent;
}
.shutter span {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: var(--flash);
  transition: transform .12s ease-out;
}
.shutter:hover span { transform: scale(.94); }
.shutter:active span { transform: scale(.86); }
.shutter:disabled { cursor: not-allowed; }
.shutter:disabled span { background: rgba(255, 255, 255, .35); }

.ai { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .18); }
.ai h2 { margin: 0 0 10px; font-size: .9375rem; font-weight: 600; }
.ai-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-row button {
  border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #fff; text-transform: capitalize;
}
.ai-row button:hover { background: rgba(255, 255, 255, .2); }
.ai-row button:disabled { opacity: .45; cursor: not-allowed; }

.tray { display: flex; flex-direction: column; align-items: center; }
.slot {
  width: 100%; height: 14px; border-radius: 999px;
  background: var(--ink);
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, .6), 0 1px 0 #fff;
  position: relative; z-index: 1;
}
.output {
  width: 86%; margin-top: -7px; overflow: hidden;
  display: flex; justify-content: center;
  padding-bottom: 12px;
}
.output img {
  display: block; max-width: 100%; height: auto;
  background: var(--paper);
  box-shadow: 0 10px 24px -8px rgba(21, 23, 43, .35);
}
.output img:not(.is-strip) { padding: 10px; }
.output img.is-strip { max-height: 72vh; width: auto; }
.output .printing { animation: print 1.1s cubic-bezier(.3, .7, .2, 1) both; }
@keyframes print { from { transform: translateY(-100%); } to { transform: translateY(0); } }

.empty {
  width: 100%; aspect-ratio: 1 / 3; max-height: 420px; margin: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 24px; color: var(--ink-soft);
  border: 2px dashed #c4c8d6; border-top: 0; border-radius: 0 0 16px 16px;
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; cursor: pointer; text-decoration: none;
  border: 0; background: var(--paper); color: var(--ink); font-weight: 500;
  box-shadow: inset 0 0 0 1px #d4d7e2;
}
.pill:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }
.pill.primary { background: var(--cobalt); color: #fff; box-shadow: none; }
.pill.primary:hover { background: var(--cobalt-deep); }
#camMsg .pill { background: #fff; }

.gallery { max-width: 1080px; margin: 32px auto 0; }
.gallery-locked { display: flex; justify-content: center; }
.kiosk-only { display: none; }
.is-kiosk .kiosk-only { display: inline-flex; }
.gallery-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.gallery h2 { margin: 0; font: 700 1.75rem/1 var(--display); color: var(--ink); }
#galleryCount { font: 500 .875rem var(--ui); color: var(--ink-soft); margin-left: 6px; }
.gallery-actions { display: flex; gap: 8px; }
.shots {
  display: flex; gap: 14px; overflow-x: auto; padding: 6px 4px 12px;
  align-items: flex-end;
}
.shot-item { position: relative; flex: none; }
.thumb {
  display: block; padding: 5px; border: 0; cursor: pointer;
  background: var(--paper); box-shadow: 0 4px 12px -6px rgba(21, 23, 43, .35);
}
.thumb img { display: block; height: 110px; width: auto; }
.thumb.is-strip img { height: 180px; }
.thumb[aria-current="true"] { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.shot-item .del {
  position: absolute; top: -8px; right: -8px;
  width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; font-size: 1rem; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.shot-item:hover .del, .shot-item:focus-within .del { opacity: 1; }
@media (hover: none) { .shot-item .del { opacity: 1; } }

dialog#qrDialog {
  border: 0; border-radius: 24px; padding: 28px; max-width: 360px; width: calc(100% - 32px);
  text-align: center; color: var(--ink); background: var(--paper);
}
dialog#qrDialog::backdrop { background: rgba(21, 23, 43, .6); }
#qrDialog h2 { margin: 0 0 12px; font: 800 2rem/1 var(--display); color: var(--cobalt); }
#qrCanvas { width: 100%; max-width: 264px; height: auto; image-rendering: pixelated; }
#qrDialog p { margin: 12px 0 18px; color: var(--ink-soft); font-size: .9375rem; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(440px, calc(100% - 32px)); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 500; z-index: 10;
  box-shadow: 0 10px 30px -10px rgba(21, 23, 43, .6);
}

.print-only { display: none; }
@media print {
  body { padding: 0; background: #fff; }
  body > :not(#printArea) { display: none !important; }
  #printArea { display: block; }
  #printImg { display: block; object-fit: contain; }
}

@media (max-width: 860px) {
  .booth { grid-template-columns: minmax(0, 1fr); }
  .tray { max-width: 360px; width: 100%; margin: 0 auto; }
  .empty { aspect-ratio: auto; height: 120px; }
}
@media (max-width: 520px) {
  .top { flex-direction: column; align-items: flex-start; }
  .machine { border-radius: 24px; padding: 12px 12px 16px; }
  .stage { border-radius: 14px; }
  .deck .hint { display: none; }
  .icon-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .icon-btn { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .output .printing, #countdown.tick, #flash { animation: none; }
  #flash { opacity: 0; }
}
@media (min-width: 861px) {
  .stage { width: min(100%, max(360px, calc((100dvh - 380px) * var(--ratio, 1.3846)))); margin-inline: auto; }
}
