:root {
  --red: #e10600;
  --yellow: #ffd400;
  --bg: #0b0b0d;
  --card: #17171b;
  --text: #f5f5f5;
  --muted: #9a9aa3;
  --checker-size: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Titan One", "Arial Black", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.checker-strip {
  height: 22px;
  background:
    conic-gradient(#fff 0 90deg, #111 90deg 180deg, #fff 180deg 270deg, #111 270deg)
    0 0 / var(--checker-size) var(--checker-size) repeat;
}
.checker-strip.small { height: 12px; --checker-size: 10px; }

.site-header { text-align: center; }
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  gap: 10px;
}
.site-header h1 {
  font-family: "Racing Sans One", "Arial Black", sans-serif;
  font-size: clamp(26px, 7.5vw, 40px);
  letter-spacing: 1px;
  font-style: italic;
  text-shadow: 3px 3px 0 #000, 5px 5px 0 var(--red);
}
.accent { color: var(--yellow); }
.gallery-link {
  color: #000;
  background: var(--yellow);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 0 #a88700;
}
.tagline {
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  padding: 2px 16px 10px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.stage {
  position: relative;
  width: min(94vw, 60dvh, 520px);
  aspect-ratio: 1;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid #2a2a30;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.stage video.mirrored { transform: scaleX(-1); }
.stage canvas#overlayPreview {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#flash {
  position: absolute; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease-out;
}
#flash.on { opacity: 1; transition: none; }

.stage-start {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 30%, #26262e 0%, #101014 70%);
  z-index: 2;
  padding: 20px;
  text-align: center;
}
.stage-start[hidden] { display: none; }
.stage-start p { font-size: 22px; }
.start-flag {
  width: 84px; height: 60px;
  border-radius: 6px;
  background:
    conic-gradient(#fff 0 90deg, #111 90deg 180deg, #fff 180deg 270deg, #111 270deg)
    0 0 / 21px 20px repeat;
  border: 2px solid #444;
  transform: rotate(-6deg);
}

.btn {
  font-family: inherit;
  font-size: 17px;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  color: #fff;
}
.btn-primary { background: var(--red); box-shadow: 0 4px 0 #8f0400; }
.btn-secondary { background: #2e2e36; box-shadow: 0 4px 0 #131316; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 14px;
  text-decoration: underline;
}
.btn:active { transform: translateY(3px); box-shadow: none; }

.filter-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  width: min(94vw, 520px);
  padding: 14px 4px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  width: 86px;
  border: none;
  background: var(--card);
  border-radius: 14px;
  padding: 6px 6px 8px;
  color: var(--text);
  cursor: pointer;
  border: 2px solid transparent;
}
.filter-chip.selected { border-color: var(--yellow); background: #26262e; }
.filter-chip canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 9px;
  display: block;
  background: #333;
}
.filter-chip span {
  display: block;
  font-size: 11px;
  margin-top: 5px;
  font-family: system-ui, sans-serif;
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 10px 0 18px;
}
.ctrl-btn {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  font-size: 22px;
  cursor: pointer;
}
.shutter {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--red);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 4px rgba(225,6,0,.35);
}
.shutter span {
  width: 54px; height: 54px;
  border-radius: 50%;
  background:
    conic-gradient(#fff 0 90deg, #111 90deg 180deg, #fff 180deg 270deg, #111 270deg)
    0 0 / 18px 18px repeat;
  opacity: .95;
}
.shutter:active { transform: scale(.93); }
.shutter:disabled, .ctrl-btn:disabled { opacity: .4; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  width: min(94vw, 440px);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}
.modal-close {
  position: absolute;
  top: 20px;
  right: 8px;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.modal-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #000;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--yellow);
  color: #000;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 999px;
  z-index: 20;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.site-footer { text-align: center; }
.site-footer p {
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  padding: 10px 0 14px;
}

/* Gallery page */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.gallery-head h1 {
  font-family: "Racing Sans One", "Arial Black", sans-serif;
  font-style: italic;
  font-size: clamp(22px, 6.5vw, 34px);
  text-shadow: 2px 2px 0 #000, 4px 4px 0 var(--red);
}
.back-link {
  color: #000;
  background: var(--yellow);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 0 #a88700;
}
.photo-count {
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  text-align: center;
  padding-bottom: 10px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 0 4px 20px;
}
.grid button {
  border: none;
  padding: 0;
  background: #1c1c22;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.grid img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  padding: 60px 24px;
  font-size: 15px;
  line-height: 1.6;
}
.empty-state .start-flag { margin: 0 auto 16px; }

.viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.94);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
}
.viewer[hidden] { display: none; }
.viewer img {
  max-width: 96vw;
  max-height: 74dvh;
  border-radius: 12px;
}
.viewer-actions { display: flex; gap: 12px; }
