:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --panel: #5c5c5d;
  --panel-2: #20242c;
  --text: #f5f6f8;
  --muted: #a5abba;
  --line: rgba(255,255,255,.10);
  --accent: #ffffff;
  --danger: #ff5a66;
  --radius: 24px;

  --app-height: 100vh;
}
@supports (height: 100dvh) {
  :root { --app-height: 100dvh; }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: var(--app-height);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;

  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { overflow: hidden; }
button, a { font: inherit; }
button { color: inherit; }

.app-shell {
  position: relative;
  width: min(100%, 560px);
  height: var(--app-height);
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.top-spacer {
  flex: 1 1 auto;
  min-height: 0;
}

h1, h2 { margin: 0; font-size: 24px; line-height: 1.2; }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 24px;
}
.icon-btn img { width: 22px; height: 22px; object-fit: contain; pointer-events: none; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

#switchCameraBtn, #uploadBtn { border-width: 2px; border-color: #fff; }

.camera-card {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.camera-stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: var(--capture-ratio, 1200 / 1800);
  overflow: hidden;
  background: #000;
}

.stage-spacer {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--panel);
}

#cameraVideo,
.camera-placeholder {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#cameraVideo {
  object-fit: cover;
  background: #000;
  transform: scaleX(-1);
}

#cameraVideo.is-environment { transform: none; }

.character-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.safe-area {
  --safe-line: rgba(255, 255, 255, .9);
  --safe-corner: 22px;
  position: absolute;
  left: var(--safe-left);
  top: var(--safe-top);
  width: var(--safe-width);
  height: var(--safe-height);
  z-index: 3;
  background:
    linear-gradient(var(--safe-line), var(--safe-line)) left top / var(--safe-corner) 2px,
    linear-gradient(var(--safe-line), var(--safe-line)) left top / 2px var(--safe-corner),
    linear-gradient(var(--safe-line), var(--safe-line)) right top / var(--safe-corner) 2px,
    linear-gradient(var(--safe-line), var(--safe-line)) right top / 2px var(--safe-corner),
    linear-gradient(var(--safe-line), var(--safe-line)) left bottom / var(--safe-corner) 2px,
    linear-gradient(var(--safe-line), var(--safe-line)) left bottom / 2px var(--safe-corner),
    linear-gradient(var(--safe-line), var(--safe-line)) right bottom / var(--safe-corner) 2px,
    linear-gradient(var(--safe-line), var(--safe-line)) right bottom / 2px var(--safe-corner);
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, .6));
  pointer-events: none;
}
.safe-area[hidden] { display: none; }
.safe-area-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--safe-line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.safe-area-center::before,
.safe-area-center::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--safe-line);
  transform: translate(-50%, -50%);
}
.safe-area-center::before { width: 12px; height: 1.5px; }
.safe-area-center::after { width: 1.5px; height: 12px; }

.camera-placeholder {
  z-index: 2;
  background: #000;
}
.camera-placeholder.is-hidden { display: none; }

.camera-hint {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(0, 0, 0, .5);
  pointer-events: none;
}
.camera-hint.is-hidden { display: none; }
.camera-icon { font-size: 56px; opacity: .9; }
.camera-hint p { margin: 0; font-size: 18px; font-weight: 700; }
.camera-hint span { color: var(--muted); font-size: 13px; }

.countdown {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  display: none;
  place-items: center;
  font-size: 92px;
  font-weight: 800;
  text-shadow: 0 8px 30px rgba(0,0,0,.5);
  background: rgba(0,0,0,.12);
}
.countdown.is-visible { display: grid; }

.bottom-dock {
  position: relative;
  flex: 0 0 auto;
}

.character-tabs {
  position: relative;
  z-index: 7;
  padding: 0 16px;
}

#characterPanel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 7;
}

.character-tabs.result-tabs {
  position: static;
  padding: 0;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(13, 15, 19, .4);
  backdrop-filter: blur(6px);
  border-radius: 12px 12px 0 0;
}

.tab-label {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-radius: 12px 0 0 0;
}

.tab-btn {
  border: 0;
  padding: 6px 14px;
  border-radius: 12px 12px 0 0;
  background: rgba(13, 15, 19, .4);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.is-active {
  background: rgba(13, 15, 19, .7);
  color: var(--text);
}

.tab-panel {
  padding: 8px 0;
  background: rgba(13, 15, 19, .7);
  backdrop-filter: blur(6px);
  border-radius: 0 12px 12px 12px;
}
.tab-panel[hidden] { display: none; }

.frame-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}

.frame-picker {
  --items-per-view: 3;
  --item-gap: 10px;
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  gap: var(--item-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;

  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.frame-picker::-webkit-scrollbar { display: none; }

.frame-option {
  display: block;
  flex: 0 0 calc((100% - var(--item-gap) * (var(--items-per-view) - 1)) / var(--items-per-view));
  scroll-snap-align: start;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}
.frame-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;

  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}
.frame-option.is-active { border-color: rgba(255,255,255,.95); box-shadow: 0 0 0 3px rgba(255,255,255,.08); }

.frame-option-none {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.3;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.frame-nav-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.frame-nav-btn.is-disabled {
  opacity: .35;
  pointer-events: none;
}

.frame-nav-icon { display: inline-block; font-size: 14px; }
.frame-nav-icon-prev { transform: rotate(-90deg); }
.frame-nav-icon-next { transform: rotate(90deg); }

.controls {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  background: var(--panel);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: clamp(32px, 16vw, 72px);

  padding-bottom: 13px;
}

.icon-btn-wrap { position: relative; display: grid; }
.icon-btn-label {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  line-height: 14px;
  pointer-events: none;
}
.icon-btn-wrap:has(.icon-btn:disabled) .icon-btn-label { opacity: .35; }

.primary-btn, .secondary-btn {
  min-height: 48px;
  padding: 0 22px;
  border-radius: 14px;
  border: 0;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-weight: 800;
}
.primary-btn { background: var(--accent); color: #0d0f13; }
.secondary-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

.shutter-btn {
  --size: 56px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border-style: solid;
  border-width: calc(var(--size) * 0.05);
  border-color: rgba(255,255,255,.92);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.shutter-btn span { width: calc(var(--size) * 0.66); height: calc(var(--size) * 0.66); border-radius: 50%; background: #fff; transition: transform .12s ease, opacity .12s ease; }
.shutter-btn:active span { transform: scale(.9); }
.shutter-btn.is-start { opacity: .9; transition: opacity .2s ease; }
.shutter-btn:disabled { opacity: .35; cursor: not-allowed; }
.status-text { margin: 0 0 6px; min-height: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.status-text.is-error { color: #ff9ea6; }

.result-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: none;
  background: rgba(5,6,8,.82);
}
.result-modal.is-open { display: flex; justify-content: center; }

.result-panel {
  position: relative;
  width: min(100%, 560px);
  height: var(--app-height);
  overflow: hidden;
  background: #11141a;
  display: flex;
  flex-direction: column;
}

.result-image-wrap {
  flex: 1 1 auto;
  padding-top: env(safe-area-inset-top);
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #050607;
}
.result-image-wrap img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

.result-image-wrap { position: relative; }
.adjust-canvas {
  position: absolute;
  touch-action: none;
  cursor: grab;
}
.adjust-canvas:active { cursor: grabbing; }
.adjust-canvas[hidden] { display: none; }

.adjust-bar { margin: 12px 0 0; color: var(--text); font-size: 13px; text-align: center; }
.adjust-bar[hidden] { display: none; }
.adjust-bar:not([hidden]) ~ .border-hint.is-invisible { display: none; }

.result-dock {
  position: relative;
  flex: 0 0 auto;

  min-height: var(--camera-dock-h, auto);
  padding: 0 16px max(12px, env(safe-area-inset-bottom));
}

.border-hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.border-hint.is-invisible { visibility: hidden; }
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 48px;
  margin-top: 14px;
}
.result-actions.is-locked .primary-btn {
  opacity: .4;
  pointer-events: none;
}
.save-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.save-hint[hidden] { display: none; }
.save-done-btn {
  display: block;
  margin: 8px auto 0;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.save-done-btn[hidden] { display: none; }

.save-hint.is-flash { animation: hint-flash .9s ease 2; color: var(--text); }
@keyframes hint-flash { 50% { opacity: .2; } }

.inapp-notice {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: rgba(13, 15, 19, .88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 12px;
  line-height: 1.4;
}
.inapp-notice[hidden] { display: none; }
.inapp-notice-text { flex: 1 1 auto; margin: 0; min-width: 0; }
.inapp-notice-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #0d0f13;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.inapp-notice-btn[hidden] { display: none; }
.inapp-notice-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.gate-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: rgba(5, 6, 8, .78);
}
.gate-modal[hidden] { display: none; }
.gate-panel {
  position: relative;
  width: min(100%, 360px);
  padding: 24px 20px 20px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--line);
  text-align: center;
}
.gate-title { margin: 0 0 10px; font-size: 18px; }
.gate-text { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.gate-actions { display: grid; gap: 10px; }
.gate-actions [hidden] { display: none; }
.gate-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.guide-help {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 54px;

  z-index: 21;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 50%;
  background: rgba(13, 15, 19, .55);
  color: #fff;
  font: 800 18px/1 Inter, sans-serif;
  cursor: pointer;
}

.home-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 50%;
  background: rgba(13, 15, 19, .55);
  color: #fff;
}
.home-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html:not(.is-result-open) .inapp-notice:not([hidden]) ~ .guide-help,
html:not(.is-result-open) .inapp-notice:not([hidden]) ~ .home-btn { display: none; }

.guide-modal {
  --g-brown: #6a3a22;
  --g-brown-2: #8a5a3c;
  --g-yellow: #f8b830;
  --g-red: #b42018;
  --g-cream: #fff7e8;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 6, 8, .78);
}
.guide-modal[hidden] { display: none; }
.guide-panel {
  position: relative;
  width: min(100%, 400px);
  max-height: calc(var(--app-height) - 32px);
  display: flex;
  flex-direction: column;
  padding: 18px 0 16px;
  border: 3px solid var(--g-brown);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 1px 1px, rgba(248, 184, 48, .3) 1.5px, transparent 2px) 0 0 / 14px 14px,
    var(--g-cream);
  color: var(--g-brown);
  overflow: hidden;
}

.guide-skip {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 1;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--g-brown-2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.guide-head {
  flex: 0 0 auto;
  display: block;
  width: 270px;
  max-width: 78%;
  height: auto;
  margin: 4px auto 4px;
}
.guide-track {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.guide-track::-webkit-scrollbar { display: none; }

.guide-track { cursor: grab; user-select: none; -webkit-user-select: none; }
.guide-track.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }
.guide-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow-y: auto;
  padding: 8px 20px 4px;

  scrollbar-width: none;
}
.guide-slide::-webkit-scrollbar { display: none; }
.guide-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 4px;

  font-size: 18px;
  font-weight: 900;
  text-align: center;
}
.guide-lead { margin: 0 0 14px; color: var(--g-brown-2); font-size: 14px; font-weight: 700; text-align: center; }
.guide-tag {
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
}
.guide-tag.is-red { background: var(--g-red); }
.guide-tag.is-yellow { background: var(--g-yellow); color: var(--g-brown); }

.guide-formula, .guide-result { display: flex; align-items: center; justify-content: center; gap: 6px; }
.guide-formula figure, .guide-result figure { margin: 0; text-align: center; }
.guide-formula img, .guide-result img {
  display: block;
  width: 72px;
  height: 108px;
  border: 2px solid var(--g-brown);
  border-radius: 8px;
  background: #fff;
}
.guide-formula .is-checker img { background: repeating-conic-gradient(#efe6d6 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.guide-result { margin-top: 8px; }
.guide-result img { width: 120px; height: 180px; border-color: var(--g-red); box-shadow: 0 0 0 4px rgba(180, 32, 24, .15); }
.guide-formula figcaption, .guide-result figcaption { margin-top: 4px; font-size: 13px; font-weight: 800; }
.guide-result figcaption { color: var(--g-red); font-size: 15px; }
.guide-op { color: var(--g-yellow); font-size: 26px; font-weight: 900; -webkit-text-stroke: 1px var(--g-brown); padding-bottom: 18px; }
.guide-result { flex-direction: column; gap: 2px; }
.guide-arrow { padding: 0; font-size: 18px; line-height: 1; }

.guide-steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: guide-step; display: grid; gap: 12px; }
.guide-steps li {
  counter-increment: guide-step;
  position: relative;
  padding-left: 38px;
  min-height: 28px;
}
.guide-steps li::before {
  content: counter(guide-step);
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--g-brown);
  color: #fff;
  font: 800 15px/28px Inter, sans-serif;
  text-align: center;
}
.guide-steps b { display: block; font-size: 16px; line-height: 28px; }

.guide-ui {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-top: 2px solid var(--g-yellow);
  border-radius: 10px;
  background: url(../assets/bg.webp) center / cover no-repeat, var(--g-brown);
}
.guide-ui-controls { flex-direction: row; align-items: center; gap: 16px; padding: 8px 16px; }
.guide-ui-row { display: flex; align-items: center; gap: 5px; }
.guide-ui-tabs { display: flex; gap: 4px; }
.guide-ui-tab {
  padding: 3px 10px;
  border-radius: 8px 8px 0 0;
  background: var(--g-yellow);
  color: var(--g-brown);
  font-size: 12px;
  font-weight: 800;
}
.guide-ui-tab.is-off { background: rgba(58, 32, 22, .6); color: #e6c9a0; }
.guide-nav {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  background: url(../assets/icon/arrow.webp) center / 100% 100% no-repeat;
}
.guide-nav.is-next { transform: scaleX(-1); }
.guide-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 9px;
  overflow: hidden;
}
.guide-thumb img { display: block; width: 100%; height: 100%; }
.guide-thumb.is-active { border-color: var(--g-yellow); }

.guide-thumb-none {
  display: grid;
  place-items: center;
  border-color: var(--g-cream);
  background: rgba(30, 17, 11, .5);
  color: var(--g-cream);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}
.guide-shutter {
  width: 40px;
  height: 40px;
  border: 3px solid var(--g-yellow);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.guide-shutter::after { content: ''; width: 28px; height: 28px; border-radius: 50%; background: var(--g-cream); }
.guide-icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px solid var(--g-cream);
  border-radius: 10px;
  background: var(--g-red);
  display: grid;
  place-items: center;
}
.guide-icon-btn img { width: 17px; height: 17px; }
.guide-icon-btn em {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 2px;
  transform: translateX(-50%);
  color: var(--g-cream);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}
.guide-ui-controls:has(em) { padding-bottom: 20px; }

.guide-shutter.is-focus, .guide-icon-btn.is-focus { box-shadow: 0 0 0 3px rgba(248, 184, 48, .55); }
.guide-save {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 18px;
  border-radius: 10px;
  background: var(--g-red);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.guide-steps li > .guide-save { display: table; }

.guide-step-note { display: block; color: var(--g-brown-2); font-size: 15px; font-weight: 700; }
.guide-step-note em { color: var(--g-red); font-style: normal; font-weight: 900; }
.guide-badge { display: block; width: 100%; max-width: 250px; height: auto; margin: 4px 0 2px; }

.guide-dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 10px; }
.guide-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(106, 58, 34, .25); transition: width .2s, background .2s; }
.guide-dots span.is-active { width: 20px; border-radius: 4px; background: var(--g-brown); }
.guide-next {
  align-self: center;
  min-width: 180px;
  min-height: 46px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--g-red);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.done-panel { padding: 24px 20px 20px; text-align: center; }

.done-panel .guide-title { font-size: 24px; }
.done-close { font-size: 22px; line-height: 1; }
.done-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--g-red);
  color: #fff;
  font: 900 30px/56px Inter, sans-serif;
}
.done-steps { margin: 6px 0 0; text-align: left; }

.done-sns { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

.guide-sns { display: inline-flex; align-items: center; gap: 4px; vertical-align: -0.15em; white-space: nowrap; }
.guide-sns img { width: 1.1em; height: 1.1em; border-radius: 22%; }
.done-sns img { width: 1.1em; height: 1.1em; border-radius: 22%; flex: 0 0 auto; }
.done-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 6px 6px 12px;
  border: 2px dashed var(--g-yellow);
  border-radius: 12px;
  background: #fff;
}
.done-tags-text { flex: 1 1 auto; color: var(--g-red); font-size: 16px; font-weight: 900; }
.done-copy {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--g-brown);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.done-note { display: block; color: var(--g-brown-2); font-size: 12px; font-weight: 700; }
.done-actions { display: grid; justify-items: center; gap: 6px; margin-top: 18px; }
.done-actions [hidden] { display: none; }
.done-again {
  padding: 10px 20px;
  border: 0;
  background: transparent;
  color: var(--g-brown);
  font-size: 15px;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

.shutter-btn.is-guide-pulse { animation: guide-pulse .7s ease-in-out 2; }
@keyframes guide-pulse {
  50% { box-shadow: 0 0 0 8px rgba(248, 184, 48, .75); }
}

@media (prefers-reduced-motion: reduce) {
  .guide-track { scroll-behavior: auto; }
  .shutter-btn.is-guide-pulse { animation: none; }
}

.guide-panel.is-fit-1 { padding: 14px 0 12px; }
.is-fit-1 .guide-head { width: 220px; margin: 0 auto 2px; }
.is-fit-1 .guide-slide { padding-top: 2px; }
.is-fit-1 .guide-title { font-size: 17px; }
.is-fit-1 .guide-lead { margin-bottom: 8px; }
.is-fit-1 .guide-formula img { width: 60px; height: 90px; }
.is-fit-1 .guide-result img { width: 96px; height: 144px; }
.is-fit-1 .guide-steps { margin-top: 10px; gap: 6px; }
.is-fit-1 .guide-ui { padding: 4px 8px; }
.is-fit-1 .guide-thumb { width: 36px; height: 36px; }
.is-fit-1 .guide-dots { margin: 6px 0; }
.is-fit-1 .guide-next { min-height: 42px; }

.is-fit-2 .guide-head { width: 180px; }
.is-fit-2 .guide-title { font-size: 16px; }
.is-fit-2 .guide-tag { font-size: 12px; }
.is-fit-2 .guide-lead { margin-bottom: 6px; font-size: 12px; }
.is-fit-2 .guide-formula img { width: 52px; height: 78px; }
.is-fit-2 .guide-result img { width: 80px; height: 120px; }
.is-fit-2 .guide-op { font-size: 20px; padding-bottom: 14px; }
.is-fit-2 .guide-steps { margin-top: 8px; gap: 4px; }
.is-fit-2 .guide-steps li { padding-left: 32px; min-height: 24px; }
.is-fit-2 .guide-steps li::before { width: 24px; height: 24px; font-size: 13px; line-height: 24px; }
.is-fit-2 .guide-steps b { font-size: 14px; line-height: 24px; }
.is-fit-2 .guide-ui { margin-top: 3px; padding: 3px 6px; gap: 4px; }
.is-fit-2 .guide-ui-controls { padding: 4px 12px; gap: 12px; }
.is-fit-2 .guide-ui-controls:has(em) { padding-bottom: 16px; }
.is-fit-2 .guide-thumb { width: 30px; height: 30px; }
.is-fit-2 .guide-nav { width: 18px; height: 18px; }
.is-fit-2 .guide-shutter { width: 32px; height: 32px; }
.is-fit-2 .guide-shutter::after { width: 22px; height: 22px; }
.is-fit-2 .guide-icon-btn { width: 28px; height: 28px; }
.is-fit-2 .guide-icon-btn img { width: 14px; height: 14px; }
.is-fit-2 .guide-save { margin-top: 4px; padding: 4px 14px; font-size: 12px; }
.is-fit-2 .guide-step-note { font-size: 14px; }
.is-fit-2 .guide-badge { max-width: 200px; }
.is-fit-2 .guide-dots { margin: 4px 0; }
.is-fit-2 .guide-next { min-height: 38px; font-size: 15px; }

.is-fit-3 .guide-head { width: 150px; }
.is-fit-3 .guide-title { font-size: 15px; }
.is-fit-3 .guide-formula img { width: 44px; height: 66px; }
.is-fit-3 .guide-formula figcaption { font-size: 11px; }
.is-fit-3 .guide-result img { width: 64px; height: 96px; }
.is-fit-3 .guide-result figcaption { font-size: 13px; }
.is-fit-3 .guide-steps li { padding-left: 28px; min-height: 22px; }
.is-fit-3 .guide-steps li::before { width: 22px; height: 22px; font-size: 12px; line-height: 22px; }
.is-fit-3 .guide-steps b { font-size: 13px; line-height: 22px; }
.is-fit-3 .guide-badge { max-width: 160px; }
.is-fit-3 .guide-step-note { font-size: 13px; }
.is-fit-3 .guide-thumb { width: 26px; height: 26px; }
.is-fit-3 .guide-ui-tab { padding: 2px 8px; font-size: 11px; }

.rotate-notice {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  background: var(--bg);
  text-align: center;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
}
.rotate-notice-icon {
  width: 36px;
  height: 60px;
  border: 3px solid var(--text);
  border-radius: 8px;
  animation: rotate-hint 1.6s ease-in-out infinite;
}
.rotate-notice p { margin: 0; font-size: 16px; font-weight: 700; }
@keyframes rotate-hint {
  0%, 20% { transform: rotate(-90deg); }
  60%, 100% { transform: rotate(0deg); }
}

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .rotate-notice { display: grid; }
}

@media (max-height: 640px) {
  .controls { padding-top: 6px; gap: 2px; }
  .shutter-btn { --size: 50px; }
  .icon-btn { width: 40px; height: 40px; }
  .controls-row { padding-bottom: 11px; }
  .icon-btn-label { top: calc(100% + 2px); font-size: 11px; line-height: 13px; }
  .status-text { margin-bottom: 2px; font-size: 12px; }
  .result-actions { margin-top: 10px; }
  .primary-btn, .secondary-btn { min-height: 44px; }
  .border-hint { margin-top: 8px; }
}

:root {
  --bg: #1e110b;
  --panel: #4a2a1a;
  --panel-2: #2e1a10;
  --text: #fff7e8;
  --muted: #e6c9a0;
  --line: rgba(248, 184, 48, .3);
  --accent: #f8b830;
  --smile-brown: #6a3a22;
  --smile-brown-dark: #3a2016;
  --smile-yellow: #f8b830;
  --smile-red: #b42018;
  --smile-cream: #fff7e8;

  --smile-dark-30: rgba(30, 17, 11, .3);
  --smile-dark-50: rgba(30, 17, 11, .5);

  --smile-bg: url(../assets/bg.webp) center / cover no-repeat;
}

.app-shell { background: var(--smile-brown); }
.app-shell::before {
  content: "";
  position: absolute;
  top: var(--dock-top, 0px);
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--smile-bg), var(--smile-brown);
  pointer-events: none;
}
.top-spacer { background: var(--bg); }
.controls,
.stage-spacer { background: transparent; }
.controls { border-top: 3px solid var(--smile-yellow); }
.status-text { color: var(--muted); }
.status-text.is-error { color: #ffb4a8; }
.icon-btn-label { color: var(--smile-cream); font-weight: 700; }

.icon-btn { background: var(--smile-red); }
#switchCameraBtn, #uploadBtn { border-color: var(--smile-cream); }

.shutter-btn { border-color: var(--smile-yellow); }
.shutter-btn span { background: var(--smile-cream); }

.bottom-dock .character-tabs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
}
.bottom-dock .tab-bar { background: transparent; backdrop-filter: none; }
.bottom-dock .tab-label {
  padding: 5px 14px;
  border-radius: 12px 12px 0 0;
  background: var(--smile-yellow);
  color: var(--smile-brown);
  font-size: 13px;
}

.tab-panel {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 12px;
}

.frame-option { background: transparent; }

.frame-option:has(.frame-option-none) {
  border-color: var(--smile-cream);
  background: var(--smile-dark-50);
}
.frame-option.is-active:has(.frame-option-none) { border-color: var(--smile-yellow); }
.frame-option.is-active {
  border-color: var(--smile-yellow);
  box-shadow: 0 0 0 3px rgba(248, 184, 48, .25);
}
.frame-option-none { color: var(--smile-cream); }

.frame-nav-btn {
  border: 0;
  background: url(../assets/icon/arrow.webp) center / 100% 100% no-repeat;
}
.frame-nav-btn:has(.frame-nav-icon-next) { transform: scaleX(-1); }
.frame-nav-btn .frame-nav-icon { display: none; }

.camera-icon { color: var(--smile-yellow); }
.countdown {
  color: var(--smile-yellow);
  -webkit-text-stroke: 3px var(--smile-brown);
  paint-order: stroke fill;
}

.guide-help,
.home-btn {
  border-color: var(--smile-cream);
  background: var(--smile-red);
  color: #fff;
}

.result-panel { background: var(--smile-brown-dark); }
.result-image-wrap { background: var(--bg); }

.character-tabs.result-tabs {
  position: absolute;
  left: 0;
  right: 0;

  bottom: calc(100% + 3px);
  padding: 0 16px;
}

.result-tab-panels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
}
.result-tabs .tab-btn[hidden] { display: none; }
.result-dock {
  border-top: 3px solid var(--smile-yellow);
  background: var(--smile-bg), var(--smile-brown);
}
.result-tabs .tab-bar { background: transparent; backdrop-filter: none; }
.tab-btn {
  background: rgba(58, 32, 22, .6);
  color: var(--muted);
}
.tab-btn.is-active {
  background: var(--smile-yellow);
  color: var(--smile-brown);
}
.border-hint { color: var(--smile-cream); }
.save-hint { color: var(--muted); }

.primary-btn { background: var(--smile-red); color: #fff; }
.secondary-btn {

  background: var(--smile-dark-30);
  color: var(--smile-cream);
  border: 2px solid var(--smile-cream);
}

.inapp-notice { background: rgba(58, 32, 22, .92); }
.inapp-notice-btn { background: var(--smile-yellow); color: var(--smile-brown); }
.gate-panel { border: 3px solid var(--smile-yellow); background: var(--smile-bg), var(--smile-brown); }
.gate-text { color: var(--smile-cream); }
