/* ============================================================
   いろいろ探検カメラ — パンフレットのトンマナ
   クリーム地 / ペイントスプラッシュ / 赤・青・緑の3色 / 丸ゴシック
   ============================================================ */
:root {
  --cream:  #FBF5EA;
  --ink:    #26292E;
  --red:    #FF4713;
  --blue:   #1B6FD8;
  --green:  #00A06A;
  --pink:   #E5399E;
  --orange: #FF8A00;
  --yellow: #FFC907;
  --purple: #7A3CE8;
  --radius: 16px;
  --font: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "BIZ UDGothic",
          "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: manipulation;
}

button, input, a { font-family: inherit; }
/* ふりがな：ruby / rt の line-height を 1 に固定し、ベース文字を
   周囲のテキストと同じ行に揃える（親の大きな line-height を継承すると
   注記のぶんベース文字が下に沈むため） */
ruby { line-height: 1; }
ruby rt { font-size: 0.5em; line-height: 1; font-weight: inherit; }
.ico { width: 1.4em; height: 1.4em; vertical-align: middle; }

.c-pink   { color: var(--pink); }
.c-orange { color: var(--orange); }
.c-green  { color: var(--green); }
.c-blue   { color: var(--blue); }

/* ============ スタート画面 ============ */
#start-screen {
  position: fixed; inset: 0;
  overflow-y: auto;
  background: var(--cream);
  z-index: 50;
}

/* ヒーロー：背景ペイントとロゴを親子にし、上下 padding だけで余白を管理する */
.hero {
  position: relative;
  display: flex; justify-content: center;
  padding: 44px 24px 48px;
  overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg svg { width: 100%; height: 100%; display: block; }

.start-inner {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 24px calc(40px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center;
}

/* パンフレット風セクション見出し（●●● 見出し ────） */
.section-head {
  align-self: stretch;
  display: flex; align-items: center; gap: 8px;
  font-size: 1rem;
  margin-bottom: 14px;
}
.section-head-text { flex: 0 1 auto; }
.section-head::after {
  content: "";
  flex: 1;
  border-top: 3px dotted #D8D2C6;
  margin-left: 6px;
}
.dots { display: inline-flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-red   { background: var(--red); }
.dot-blue  { background: var(--blue); }
.dot-green { background: var(--green); }

.logo-blob {
  position: relative;
  z-index: 1;
  max-width: 100%;
  background: var(--ink);
  color: #fff;
  border-radius: 32px 40px 36px 44px / 40px 32px 44px 36px;
  padding: 24px 28px 20px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(38, 41, 46, .25);
  transform: rotate(-1.5deg);
}
.logo { font-size: clamp(1.3rem, 6.5vw, 1.9rem); line-height: 1.3; letter-spacing: .02em; }
.logo-iro { font-size: 1.15em; }
.logo-main { display: inline-block; }
.logo-sub { margin-top: 8px; font-size: .8rem; color: var(--yellow); font-weight: bold; }

.promise-list { list-style: none; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.promise {
  display: flex; align-items: center; gap: 14px;
  background: #fff;
  border: 2.5px solid;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .92rem;
  line-height: 1.7;
  font-weight: bold;
}
.promise-red   { border-color: var(--red);   } .promise-red   .promise-mark { background: var(--red); }
.promise-blue  { border-color: var(--blue);  } .promise-blue  .promise-mark { background: var(--blue); }
.promise-green { border-color: var(--green); } .promise-green .promise-mark { background: var(--green); }
.promise-mark {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  color: #fff;
  display: grid; place-items: center;
  font-weight: bold; font-size: 1.1rem;
}

.start-btn {
  margin-top: 40px;
  display: flex; align-items: center; gap: 10px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 18px 36px;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 5px 0 #C33208;
  transition: transform .1s;
}
.start-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #C33208; }
.start-note { margin-top: 14px; font-size: .8rem; color: #777; }

/* ============ カメラ画面 ============ */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--ink);
}

.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  background: var(--ink);
  color: #fff;
}
.topbar-logo { font-weight: bold; font-size: 1rem; }
.icon-btn {
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, .35); }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 比較ラベル（ふつう／べつ） */
.view-label {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--ink);
  color: #fff;
  font-size: .8rem;
  font-weight: bold;
  line-height: 1.2;
  padding: 8px 12px 5px;
  border-radius: 999px;
  border: 2px solid #fff;
  pointer-events: none;
  z-index: 3;
  max-width: 46%;
}
.view-label rt { font-size: .45em; }
#label-b { background: var(--red); }
/* 縦分割（ポートレート）: 下半分の先頭へ */
.stage.split-v #label-b { top: calc(50% + 8px); left: 8px; }
/* 横分割（ランドスケープ）: 右半分の先頭へ */
.stage.split-h #label-b { top: 8px; left: calc(50% + 8px); }

/* ふきだし説明 */
.bubble {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px 24px 20px 24px / 24px 20px 24px 20px;
  padding: 14px 40px 12px 16px;
  z-index: 4;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bubble-close {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px;
  border: none; border-radius: 50%;
  background: var(--ink); color: #fff;
  font-size: 1rem; font-weight: bold;
  cursor: pointer;
}
.bubble-title { font-weight: bold; font-size: 1rem; margin-bottom: 4px; }
.bubble-desc { font-size: .88rem; line-height: 1.6; }
.bubble-note { font-size: .82rem; line-height: 1.5; color: #555; margin-top: 4px; }
.bubble-note:empty { display: none; }
.bubble-value {
  margin-top: 8px; padding-top: 8px;
  border-top: 2px dotted #ccc;
  font-size: .82rem; line-height: 1.5;
}

.cam-error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  text-align: center;
  padding: 20px;
  font-weight: bold;
  z-index: 5;
}
.cam-error-sub { font-size: .85rem; font-weight: normal; opacity: .8; }

/* ============ 下部パネル ============ */
.panel {
  flex: none;
  background: var(--cream);
  border-radius: 20px 20px 0 0;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  gap: 8px;
}

.type-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-btn {
  position: relative;
  background: #fff;
  border: 2.5px solid #D8D2C6;
  border-radius: 14px;
  padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  cursor: pointer;
  font-weight: bold;
  color: var(--ink);
}
.type-btn .type-shape { width: 26px; height: 26px; }
.type-btn .type-label { font-size: .7rem; line-height: 1.5; text-align: center; }
.type-btn .type-sub { font-size: .58rem; color: #999; }
.type-btn[aria-checked="true"] {
  border-width: 3px;
  border-color: var(--ink);
  background: #FFF6D8;
  box-shadow: 0 3px 0 rgba(38, 41, 46, .3);
}
.type-btn[aria-checked="true"]::after {
  content: "✓";
  position: absolute; top: -8px; right: -4px;
  width: 20px; height: 20px;
  background: var(--ink); color: #fff;
  border-radius: 50%;
  font-size: .7rem;
  display: grid; place-items: center;
}

.strength-row { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.strength-row.disabled { opacity: .35; pointer-events: none; }
.strength-label { font-size: .72rem; font-weight: bold; flex: none; }
#strength { flex: 1; min-width: 0; accent-color: var(--red); height: 28px; }

.action-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.round-btn {
  width: 56px;
  flex: none;
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
  color: var(--ink);
}
.round-btn-ico {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--ink);
  display: grid; place-items: center;
  font-size: 1.2rem; font-weight: bold;
}
.round-btn[aria-pressed="true"] .round-btn-ico { background: var(--blue); border-color: var(--blue); color: #fff; }
.round-btn[aria-pressed="true"] .round-btn-txt { color: var(--blue); }
.round-btn-txt { font-size: .68rem; font-weight: bold; }
.round-btn-spacer { width: 56px; flex: 0 1 auto; }

.shutter {
  flex: none;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--red);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #C33208, 0 0 0 3px var(--red);
  transition: transform .08s;
}
.shutter:active { transform: scale(.92); }
.shutter .ico { width: 2em; height: 2em; }

.panel-note { text-align: center; font-size: .62rem; color: #999; }

/* ============ 撮影プレビュー ============ */
.photo-modal {
  position: fixed; inset: 0;
  background: rgba(38, 41, 46, .8);
  display: grid; place-items: center;
  z-index: 60;
  padding: 20px;
}
.photo-card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  gap: 10px;
  text-align: center;
}
.photo-title { font-weight: bold; font-size: 1.1rem; }
#photo-img {
  width: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: 10px;
  border: 2px solid var(--ink);
}
.photo-hint { font-size: .78rem; color: #666; }
.photo-actions { display: flex; gap: 10px; justify-content: center; }

.chip-btn {
  display: inline-block;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-weight: bold;
  font-size: .95rem;
  padding: 10px 24px;
  cursor: pointer;
  text-decoration: none;
}
.chip-green { background: var(--green); border-color: var(--green); color: #fff; }

[hidden] { display: none !important; }

/* 横長端末: パネルを右に */
@media (orientation: landscape) and (max-height: 500px) {
  #app { flex-direction: row; }
  .topbar { position: absolute; top: 0; left: auto; right: 200px; z-index: 6; background: none; }
  .topbar-logo { display: none; }
  .panel {
    width: 190px;
    border-radius: 20px 0 0 20px;
    justify-content: center;
    overflow-y: auto;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .type-row { grid-template-columns: repeat(2, 1fr); }
  .action-row { flex-wrap: wrap; gap: 10px; }
  .round-btn-spacer { display: none; }
  .shutter { width: 60px; height: 60px; }
  .panel-note { font-size: .55rem; line-height: 1.3; }
}
