/* PINK CAMERA
   UI そのものは無彩色。ピンクだけがアクセントになる。
   アプリ自体がコンセプトの実演。ここは崩さない。 */

:root {
  --ink: #141014;
  --paper: #EFEDEE;
  --lens: #FF1E8C;
  --edge: 3px solid var(--ink);
  --r: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0a0b;
  color: var(--ink);
  font-family: 'Zen Maru Gothic', system-ui, -apple-system, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- screens ---------------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
}
.screen.is-on { display: block; }

.sheetful {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 18% 6%, rgba(255,255,255,.9), transparent 45%),
    repeating-linear-gradient(115deg, rgba(0,0,0,.035) 0 2px, transparent 2px 6px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sheetful.is-on { display: block; }

.paper {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 22px) 18px calc(var(--safe-b) + 32px);
}

/* ---------------- type ---------------- */

.title, .wordmark {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: .88;
  margin: 0;
  background: linear-gradient(168deg, #fff 4%, #b9b6b8 22%, var(--lens) 48%, #6d6a6c 68%, #fff 84%, var(--lens) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.18));
}
/* 紙の上ではクロームの白がとぶので、黒のキーラインで縁を立てる */
.title {
  font-size: clamp(34px, 11vw, 54px);
  margin-bottom: 14px;
  filter:
    drop-shadow(1.5px 0 0 var(--ink)) drop-shadow(-1.5px 0 0 var(--ink))
    drop-shadow(0 1.5px 0 var(--ink)) drop-shadow(0 -1.5px 0 var(--ink))
    drop-shadow(3px 4px 0 rgba(0,0,0,.22));
}

/* ---------------- さいしょ ---------------- */

.start-paper {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.start-title {
  font-size: clamp(52px, 18vw, 92px);
  margin-bottom: 10px;
}
.start-sub {
  font-size: 14px;
  letter-spacing: .16em;
  font-weight: 700;
  color: #5d585b;
  margin: 0 0 34px;
}
.btn.big { padding: 20px 20px; font-size: 17px; margin-bottom: 14px; }
.start-note { margin: 10px 2px 0; font-size: 12px; }

.note {
  font-size: 13px;
  line-height: 1.7;
  color: #5d585b;
  margin: 0 0 16px;
}

/* ---------------- stage ---------------- */

#stage {
  position: absolute;
  inset: 0;
  background: #171516;
  touch-action: none;
}
#video {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
#view {
  display: block;
  width: 100%;
  height: 100%;
}
/* 編集モードは写真を切らない。バーに隠れない位置に、全体を収める */
#stage.is-fit {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 68px) 10px calc(var(--safe-b) + 168px);
}
#stage.is-fit #view {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

/* モードごとに出し分けるボタン（.round の display を上書きしないよう限定する） */
.round.only-edit, .round.only-camera { display: grid; }
#scr-camera.mode-camera .only-edit,
#scr-camera.mode-edit .only-camera { display: none; }
.shutter-check { display: none; }
#scr-camera.mode-edit .shutter-check {
  display: block;
  position: absolute;
  width: 34px; height: 34px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
}

.badge {
  position: absolute;
  top: calc(var(--safe-t) + 96px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .18em;
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
}

.gate {
  position: absolute;
  inset: 0;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  z-index: 5;
}
.gate[hidden] { display: none; }   /* class の display が hidden 属性に勝つので明示 */
.gate-title {
  font-family: 'Outfit', 'Zen Maru Gothic', sans-serif;
  font-weight: 800;
  font-size: 20px;
  margin: 0;
  color: var(--ink);
}
.gate-body { font-size: 13px; line-height: 1.8; color: #5d585b; margin: 0 0 8px; }
.gate .btn { max-width: 280px; }

/* ---------------- top bar ---------------- */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) 14px 0;
  pointer-events: none;
}
.wordmark {
  font-size: 22px;
  line-height: .84;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.5));
}
.top-actions { display: flex; gap: 8px; pointer-events: auto; }

.pill {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: rgba(255,255,255,.92);
  border: var(--edge);
  border-radius: 999px;
  padding: 8px 15px;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.pill:active { transform: translate(2px,2px); box-shadow: 0 0 0 var(--ink); }

/* ---------------- なぞる（編集モードだけ） ---------------- */

.brush {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,.92);
  border: var(--edge);
  border-radius: 999px;
  padding: 5px;
  box-shadow: 2px 2px 0 var(--ink);
}
#scr-camera.mode-camera .brush { display: none; }
.seg {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
}
.seg.is-on {
  background: var(--lens);
  color: #fff;
  border-color: var(--ink);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.seg:active { transform: translateY(1px); }
.brush-sep {
  width: 2px;
  align-self: stretch;
  background: #dcd9da;
  border-radius: 2px;
  margin: 2px 1px;
}
.seg.icon { padding: 7px 10px; display: grid; place-items: center; }
.seg.icon svg { width: 20px; height: 20px; display: block; fill: var(--ink); }
.seg.icon:disabled { opacity: .28; cursor: default; }
.seg.icon:disabled:active { transform: none; }

/* ---------------- bottom bar ---------------- */

.bottombar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 16px calc(var(--safe-b) + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.bottombar > * { pointer-events: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: rgba(255,255,255,.92);
  border: var(--edge);
  border-radius: 999px;
  padding: 7px 15px 7px 8px;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  max-width: 78vw;
}
.chip:active { transform: translate(2px,2px); box-shadow: 0 0 0 var(--ink); }
.chip-dot {
  width: 22px; height: 22px; border-radius: 7px;
  border: 2px solid var(--ink);
  background: linear-gradient(140deg, #FFD9EC, #FF7FC0 45%, var(--lens) 70%, #C8006B);
  box-shadow: inset -3px -3px 5px rgba(0,0,0,.25), inset 3px 3px 4px rgba(255,255,255,.55);
  flex: none;
}
.chip-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}
.round {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: var(--edge);
  background: rgba(255,255,255,.92);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.round svg { width: 24px; height: 24px; display: block; }
.round:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }

.shutter {
  position: relative;
  width: 82px; height: 82px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: #fff;
  box-shadow: 4px 4px 0 var(--lens);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.shutter span {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(140deg, #FF7FC0, var(--lens) 55%, #C8006B);
  box-shadow: inset -5px -5px 9px rgba(0,0,0,.28), inset 5px 5px 8px rgba(255,255,255,.5);
  display: block;
}
.shutter:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--lens); }

.hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: .06em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  pointer-events: none;
}

/* ---------------- knobs sheet ---------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: transparent;   /* つまみの効きを見たいので映像は暗くしない */
  display: flex;
  align-items: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-inner {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: #fff;
  border-top: var(--edge);
  border-left: var(--edge);
  border-right: var(--edge);
  border-radius: var(--r) var(--r) 0 0;
  padding: 10px 18px calc(var(--safe-b) + 18px);
  box-shadow: 0 -6px 0 var(--lens);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); } to { transform: none; } }

.sheet-grab {
  width: 46px; height: 5px;
  border-radius: 99px;
  background: #cfcccd;
  margin: 2px auto 12px;
}
.knob-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.knob-eyebrow {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  letter-spacing: .22em;
  color: #7a7679;
  font-weight: 800;
}
.knob-name {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .02em;
}

.row { margin: 15px 0; }
.row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.row label span { font-family: 'Outfit', sans-serif; color: var(--lens); font-weight: 800; }

.range {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #cfcccd, var(--lens));
  border: 2px solid var(--ink);
  margin: 0;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--lens);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--lens);
  cursor: pointer;
}
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { margin: 0; }

/* ---------------- buttons ---------------- */

.btn {
  font-family: 'Outfit', 'Zen Maru Gothic', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  border: var(--edge);
  border-radius: 999px;
  padding: 14px 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
}
.btn.hot { background: var(--lens); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--lens); outline-offset: 3px; }

/* ---------------- result ---------------- */

.shot-frame {
  border: var(--edge);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: 6px 6px 0 var(--lens);
  background: #dedbdc;
  /* 縦長の写真でも「保存」ボタンが画面内に残るように上限をつけ、枠は画像に添わせる */
  display: flex;
  width: fit-content;
  max-width: 100%;
  max-height: 46vh;
  margin: 0 auto 12px;
}
.shot-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 46vh;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 26px);
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 13px;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  pointer-events: none;
}
.toast[hidden] { display: none; }

/* ---------------- flash ---------------- */

.flash {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  pointer-events: none;
  animation: blink .26s ease-out forwards;
}
@keyframes blink { from { opacity: .9; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .btn:active, .round:active, .shutter:active, .pill:active, .chip:active { transform: none; }
  .sheet-inner { animation: none; }
  .flash { animation: none; opacity: 0; }
}
