:root {
  color-scheme: dark;
  --glass: rgba(15, 15, 14, 0.72);
  --glass-soft: rgba(20, 20, 18, 0.48);
  --line: rgba(255, 255, 255, 0.18);
  --text: #fffdf4;
  --muted: rgba(255, 253, 244, 0.72);
  --coral: #ff596c;
  --lime: #75e05b;
  --cyan: #43cce7;
  --gold: #ffc542;
  --bottom-space: max(48px, calc(env(safe-area-inset-bottom, 0px) + 16px));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080807;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.booth {
  position: relative;
  width: 100vw;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(circle at 38% 20%, #4a473d 0%, #171714 34%, #080807 100%);
  isolation: isolate;
}

.camera,
.camera-fallback,
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera {
  z-index: 1;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  transition: opacity 220ms ease;
}

.booth.camera-live .camera {
  opacity: 1;
}

.booth.camera-live .camera-fallback {
  opacity: 0;
}

.camera-fallback {
  z-index: 0;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.18), transparent 19%),
    linear-gradient(150deg, rgba(255, 197, 66, 0.2), transparent 28%),
    radial-gradient(circle at 24% 16%, rgba(67, 204, 231, 0.22), transparent 20%),
    radial-gradient(circle at 78% 58%, rgba(255, 89, 108, 0.24), transparent 26%),
    #11110f;
  transition: opacity 220ms ease;
}

.camera-fallback::after {
  position: absolute;
  left: 50%;
  top: 36%;
  width: min(50vw, 230px);
  height: min(62vw, 290px);
  border-radius: 44% 44% 38% 38%;
  background:
    radial-gradient(circle at 35% 31%, rgba(255, 255, 255, 0.32) 0 3px, transparent 4px),
    radial-gradient(circle at 63% 31%, rgba(255, 255, 255, 0.32) 0 3px, transparent 4px),
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04) 62%, transparent 64%);
  content: "";
  transform: translate(-50%, -50%);
}

.overlay {
  z-index: 2;
  touch-action: none;
}

.topbar {
  position: absolute;
  z-index: 4;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 14px;
  height: 72px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 36px;
  background: var(--glass);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(22px);
}

.icon-btn {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.icon-btn svg,
.hand-chip svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.mode-dots {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: clamp(10px, 4vw, 24px);
  min-width: 0;
  height: 56px;
  padding: 0 10px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.06);
}

.dot {
  width: 29px;
  height: 29px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.28), 0 8px 18px rgba(0, 0, 0, 0.22);
}

.dot.is-active {
  border-color: rgba(255, 255, 255, 0.9);
}

.coral { background: var(--coral); }
.lime { background: var(--lime); }
.cyan { background: var(--cyan); }

.status {
  position: absolute;
  z-index: 4;
  top: calc(max(18px, env(safe-area-inset-top)) + 86px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 40px);
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

.status span {
  line-height: 1.3;
}

#scoreText {
  white-space: nowrap;
}

.how-to {
  position: absolute;
  z-index: 7;
  top: calc(max(18px, env(safe-area-inset-top)) + 132px);
  left: 18px;
  right: 18px;
  max-height: calc(100% - 174px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 15, 14, 0.95);
  font-size: 14px;
  line-height: 1.5;
}

.how-to summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.instructions {
  padding: 0 16px 16px;
}

.instructions p { margin: 8px 0 12px; }
.instructions ol { padding-left: 22px; }
.instructions li { margin-bottom: 8px; }
.instructions button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--lime);
  color: #111;
  font-weight: 700;
  cursor: pointer;
}

.hand-chip {
  position: absolute;
  z-index: 4;
  right: 26px;
  bottom: calc(var(--bottom-space) + 224px);
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0.78;
  backdrop-filter: blur(16px);
}

.tray {
  position: absolute;
  z-index: 5;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--bottom-space) + 76px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  padding: 12px;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(15, 15, 14, 0.64), rgba(7, 7, 6, 0.92));
  box-shadow: 0 -18px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(26px);
}

.tray::-webkit-scrollbar {
  display: none;
}

.tray::before {
  content: none;
}

.prop-btn {
  display: grid;
  width: 100%;
  height: 48px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.prop-btn.is-selected {
  border-color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.13);
}

.none-mark {
  width: 30px;
  height: 30px;
  border: 4px solid #fff;
  border-radius: 50%;
  transform: rotate(-42deg);
}

.none-mark::after {
  display: block;
  width: 4px;
  height: 30px;
  margin: -4px auto 0;
  border-radius: 999px;
  background: #fff;
  content: "";
}

.shutter {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: var(--bottom-space);
  width: 64px;
  height: 64px;
  border: 5px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 7px rgba(0, 0, 0, 0.78), 0 12px 35px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  transform: translateX(-50%);
}

.thumb {
  position: absolute;
  z-index: 6;
  left: 30px;
  bottom: var(--bottom-space);
  width: 62px;
  height: 62px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #ffcf4f 0 11%, transparent 12%),
    radial-gradient(circle at 58% 40%, #43cce7 0 12%, transparent 13%),
    linear-gradient(145deg, #28251d, #0d0d0b);
  background-size: cover;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.34);
}

@media (min-width: 480px) {
  .tray { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 374px) {
  .topbar {
    grid-template-columns: 50px minmax(0, 1fr) 50px;
    gap: 8px;
    height: 66px;
  }

  .icon-btn {
    width: 50px;
    height: 50px;
  }

  .mode-dots {
    gap: 10px;
    min-width: 0;
    padding: 0 4px;
  }

}

/* Include the language bar in the viewport budget, even in landscape. */
html.yj-has-languages main.booth {
  height: calc(100svh - var(--yj-language-height));
  height: calc(100dvh - var(--yj-language-height));
}

@media (max-height: 600px) {
  .prop-btn { height: 44px; font-size: 25px; }
  .none-mark { width: 30px; height: 30px; }
  .none-mark::after { height: 30px; }
  .shutter { width: 56px; height: 56px; }
  .thumb { width: 48px; height: 48px; }
  .hand-chip { display: none; }
  .how-to { top: 140px; max-height: calc(100% - 152px); }
}

@media (max-height: 450px) and (min-width: 600px) {
  .booth { width: 100vw; border-radius: 0; }
  .topbar { right: 260px; }
  .status { left: 18px; max-width: calc(100% - 278px); transform: none; }
  .how-to { right: 260px; }
  .tray {
    left: auto;
    width: 232px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .shutter { left: auto; right: 100px; transform: none; }
  .thumb { display: none; }
}
