:root {
  --bg: #ffffff; --fg: #111111; --mute: #767676; --line: #e6e6e6; --soft: #f3f3f3;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e0e0e; --fg: #f2f2f2; --mute: #8d8d8d; --line: #262626; --soft: #1a1a1a; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }

.page {
  max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.between { justify-content: space-between; }
.between b { color: var(--fg); font-size: 16px; letter-spacing: 0; }
.mute { color: var(--mute); font-size: 14px; }
.center { text-align: center; align-self: center; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 10px; }

.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.label .i { width: 15px; height: 15px; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; margin-left: -10px; }

input {
  width: 100%; height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--soft); color: var(--fg); font: inherit; font-size: 17px; outline: none;
}
input:focus { border-color: var(--fg); }
input[type=range] { height: 32px; padding: 0; border: 0; background: none; accent-color: var(--fg); }
.code-in { text-transform: uppercase; letter-spacing: .2em; font-weight: 600; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; }
.card .btn { height: 48px; }
.card input { height: 48px; padding: 0 8px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 54px;
  border: 1.5px solid var(--fg); border-radius: 16px; font-weight: 600;
}
.btn.primary { background: var(--fg); color: var(--bg); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .4; }
.two { display: flex; gap: 8px; }

.seg { display: flex; padding: 3px; gap: 3px; background: var(--soft); border-radius: 14px; }
.seg button { flex: 1; height: 42px; border-radius: 11px; font-weight: 600; color: var(--mute); }
.seg button.on { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place { width: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sw { display: flex; width: 52px; height: 52px; border-radius: 12px; overflow: hidden; flex: none; }
.sw.sm { width: 28px; height: 28px; border-radius: 8px; }
.sw.xs { width: 16px; height: 16px; border-radius: 5px; }
.sw i { flex: 1; box-shadow: inset 0 0 0 1px rgba(128,128,128,.25); } /* keeps light colours visible on white */
.sw.hidden { background: var(--soft); align-items: center; justify-content: center; color: var(--mute); }
.row.locked { color: var(--mute); }
.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; }

.hero-code { font-size: 52px; font-weight: 700; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
/* animated logo: rainbow glow circling a white prism (rotating square inside a triangle clip) */
.logo { position: relative; width: 120px; height: 120px; margin: 16px 0 0 -12px; }
.home { min-height: 100vh; min-height: 100dvh; justify-content: center; text-align: center; }
.home .logo { align-self: center; margin: 0; }
.home .label { justify-content: center; }
.home input { text-align: center; }
.logo.big { width: 180px; height: 180px; margin-bottom: 8px; }
.ask { animation: rise .5s ease-out both; }
.ask + * { animation: rise .5s .12s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.link { align-self: center; padding: 10px; color: var(--mute); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.logo svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.logo-glow { position: absolute; left: 12%; top: 21%; width: 76%; height: 62%; filter: blur(12px); animation: breathe 3s ease-in-out infinite; }
.logo-glow > div { position: relative; width: 100%; height: 100%; overflow: hidden; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.logo-glow > div::before {
  content: ''; position: absolute; left: -50%; top: -50%; width: 200%; height: 200%;
  background: conic-gradient(#ff2d55, #ff8a00, #ffd000, #22d65a, #0a7aff, #8a3dff, #ff2d55);
  animation: spin 5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: translateY(4px) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .logo-glow, .logo-glow > div::before { animation: none; } }
.timer { display: flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* camera: target colour(s) on top, live camera below */
.cam { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.cam-colors { position: relative; flex: 1; display: flex; min-height: 0; }
.cam-colors > div:not(.bar) { flex: 1; min-width: 0; display: flex; align-items: flex-end; padding: 12px 16px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.cam-colors.multi > div:not(.bar) { font-size: 20px; }
.bar { position: absolute; top: max(4px, env(safe-area-inset-top)); left: 6px; right: 16px; display: flex; align-items: center; justify-content: space-between; height: 44px; }
.bar .iconbtn { margin-left: 0; }
.cam-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #111; }
.cam-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-fallback { position: absolute; inset: 0 0 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; font-weight: 600; }
.cam-fallback .i { width: 40px; height: 40px; stroke-width: 1.4; }
.cam-ui {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 14px;
  padding: 48px 20px max(20px, env(safe-area-inset-bottom)); color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.cam-info { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 24px; font-weight: 600; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.cam-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25); box-shadow: inset 0 0 0 3px rgba(0,0,0,.25); }
.shutter:active { background: #fff; }
.shutter[disabled] { opacity: .4; }
.cam-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shutter.submit { display: grid; place-items: center; background: #fff; color: #111; }
.shutter.submit .i { width: 34px; height: 34px; stroke-width: 2.4; }
.cam-pill { justify-self: start; height: 44px; padding: 0 18px; border-radius: 22px; background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.grid figcaption { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding-top: 4px; font-size: 13px; font-weight: 600; }
.cam-thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; border: 2px solid #fff; }
.cam-next { justify-self: end; display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 6px 0 16px; border-radius: 22px; background: rgba(255,255,255,.2); font-weight: 600; color: #fff; }

.stars { display: inline-flex; gap: 2px; vertical-align: -2px; }
.star { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; opacity: .45; }
.star.on { fill: currentColor; opacity: 1; }

select {
  width: 100%; height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--soft); color: var(--fg); font: inherit;
}
.collage { width: 100%; border-radius: 16px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600;
  max-width: calc(100% - 32px); z-index: 10;
}
