/* ことばのボタン — プロトタイプ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}
body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #FFF8F0;
  color: #4A3728;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}
input[type="text"] {
  user-select: text;
  -webkit-user-select: text;
}
.hidden { display: none !important; }

/* ───── 画面共通 ───── */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.back-btn {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  z-index: 20;
  min-height: 44px;
  padding: 0 16px 0 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #E8D5C0;
  font-size: 15px;
  font-weight: bold;
  color: #8A7360;
  line-height: 1;
}

/* ───── ホーム ───── */
#screen-home {
  justify-content: center;
  align-items: center;
  gap: 24px;
  text-align: center;
}
.home-head { margin-top: 8px; }
.home-title {
  font-size: 30px;
  margin: 0 0 6px;
  color: #E86A17;
}
.home-icon { margin-right: 6px; }
.home-sub {
  margin: 0;
  color: #A08870;
  font-size: 15px;
}
.home-cards {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(88vw, 400px);
}
.home-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 26px 20px;
  border-radius: 28px;
  font-size: 30px;
  font-weight: bold;
  color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s;
}
.home-card:active { transform: scale(0.96) translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.card-talk { background: linear-gradient(135deg, #FFA24D, #FF7A2E); }
.card-voice { background: linear-gradient(135deg, #5AB0FF, #3D7BE8); }
.card-book { background: linear-gradient(135deg, #7ED957, #4CAF50); }
.card-game { background: linear-gradient(135deg, #F48FB1, #EC407A); }
.card-line { background: linear-gradient(135deg, #B39DDB, #7E57C2); }
.card-emoji { font-size: 44px; }
.card-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.card-sub {
  font-size: 13px;
  font-weight: normal;
  opacity: 0.92;
}
.home-links { display: flex; gap: 2px; margin-top: 10px; }
.parent-link {
  background: none;
  color: #B09880;
  font-size: 14px;
  padding: 12px 12px;
}
.parent-hint { color: #E86A17; font-size: 13px; margin: 0; }

/* ───── つたえるモード ───── */
#screen-talk {
  padding-top: calc(60px + env(safe-area-inset-top));
  padding-bottom: 16px;
}
.talk-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 14px;
  padding: 0 14px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}
.talk-btn {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.14);
  color: #fff;
}
.talk-btn .tb-emoji {
  font-size: clamp(44px, 16vw, 88px);
  line-height: 1.1;
}
.talk-btn .tb-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.talk-btn .tb-label {
  font-size: clamp(18px, 5.5vw, 30px);
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  z-index: 2;
}
.talk-btn.has-photo .tb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 4px;
  background: rgba(0, 0, 0, 0.45);
  text-shadow: none;
}
.talk-btn.pressed { animation: pop 0.45s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(0.92); }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ───── こえあそび ───── */
#screen-voice-menu {
  justify-content: center;
  align-items: center;
  gap: 20px;
}
.scene-title { font-size: 26px; color: #3D7BE8; margin: 0; }
.scene-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(85vw, 380px);
}
.scene-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  font-size: 26px;
  font-weight: bold;
  color: #4A3728;
  background: #fff;
  border: 3px solid #CFE3FF;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.08);
}
.scene-card:active { transform: scale(0.96); }
.scene-card .card-emoji { font-size: 40px; }
.mic-note { color: #A08870; font-size: 13px; margin: 4px 16px 0; text-align: center; }

#screen-voice-play {
  padding: 0;
  background: #1A1A2E;
}
#scene-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
}
#mic-meter {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(60vw, 280px);
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
  z-index: 10;
}
#mic-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: #9AA5B5;
  transition: width 0.06s linear;
}
#mic-meter-fill.voiced { background: #FFB84D; }

/* ───── えほんモード ───── */
#screen-book { padding: 0; }
.book-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
  overflow: hidden;
  background: #FFE3C7;
  transition: background 0.35s ease;
  padding: calc(56px + env(safe-area-inset-top)) 16px 8px;
}
.book-pic {
  width: min(64vw, 300px);
  height: min(64vw, 300px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.08);
}
.book-pic:active { transform: scale(0.97) translateY(3px); box-shadow: 0 5px 0 rgba(0,0,0,0.08); }
.book-emoji { font-size: clamp(96px, 34vw, 190px); line-height: 1; }
.book-pic.tapped .book-emoji { animation: wiggle 0.6s ease; }
@keyframes wiggle {
  0% { transform: scale(1) rotate(0); }
  20% { transform: scale(1.18) rotate(-8deg); }
  40% { transform: scale(1.12) rotate(8deg); }
  60% { transform: scale(1.16) rotate(-5deg); }
  80% { transform: scale(1.08) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
.book-word {
  font-size: clamp(30px, 9vw, 52px);
  font-weight: bold;
  color: #4A3728;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}
.book-sparkle {
  position: absolute;
  left: 50%;
  top: 42%;
  font-size: 30px;
  pointer-events: none;
  will-change: transform, opacity;
  animation: sparkle-fly 0.7s ease-out forwards;
}
@keyframes sparkle-fly {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; }
}
.book-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.5);
}
.book-arrow {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #E8D5C0;
  font-size: 34px;
  color: #E86A17;
  line-height: 1;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}
.book-arrow:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1); }
.book-dots { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; flex: 1; }
.book-dot { width: 9px; height: 9px; border-radius: 50%; background: #D8C4AE; transition: transform 0.15s; }
.book-dot.active { background: #E86A17; transform: scale(1.3); }

/* ───── ゲート ───── */
#screen-gate { justify-content: center; align-items: center; }
.gate-box { text-align: center; padding: 20px; }
.gate-box h2 { color: #8A7360; }
.gate-question { font-size: 34px; font-weight: bold; margin: 12px 0 20px; }
.gate-choices { display: flex; gap: 14px; justify-content: center; }
.gate-choices button {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  font-size: 28px;
  font-weight: bold;
  background: #fff;
  border: 3px solid #E8D5C0;
  color: #4A3728;
}

/* ───── おうちのひと画面 ───── */
#screen-parent {
  padding-top: env(safe-area-inset-top);
  padding-bottom: 40px;
}
.parent-header {
  display: flex;
  align-items: center;
  padding: 10px 12px 4px 122px;
}
.parent-header h2 { margin: 6px 0; font-size: 20px; color: #8A7360; }
.parent-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  position: sticky;
  top: 0;
  background: #FFF8F0;
  z-index: 5;
}
.tab-btn {
  flex: 1;
  padding: 10px 4px;
  border-radius: 14px;
  background: #F3E7D8;
  color: #8A7360;
  font-size: 14px;
  font-weight: bold;
}
.tab-btn.active { background: #FF8C42; color: #fff; }
.tab-pane { display: none; padding: 14px 16px; max-width: 640px; margin: 0 auto; width: 100%; }
.tab-pane.active { display: block; }
.pane-note { font-size: 13px; color: #A08870; line-height: 1.6; }

.button-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 16px;
  padding: 10px 12px;
  border: 2px solid #F0E2D0;
}
.button-row .br-thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.button-row .br-thumb img { width: 100%; height: 100%; object-fit: cover; }
.button-row .br-label { flex: 1; font-size: 17px; font-weight: bold; }
.button-row .br-actions { display: flex; gap: 6px; }
.button-row .br-actions button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #F3E7D8;
  font-size: 16px;
}
.list-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #B09880;
  font-size: 12px;
  font-weight: bold;
  margin: 4px 0;
}
.list-divider::before,
.list-divider::after {
  content: "";
  flex: 1;
  border-top: 2px dashed #E8D5C0;
}
.button-row.stashed { opacity: 0.55; }
.preset-title { font-size: 15px; color: #8A7360; margin: 18px 0 8px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chips button {
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #F0C9A8;
  font-size: 15px;
  color: #4A3728;
}

.stat-hero { text-align: center; margin: 14px 0 20px; }
.stat-num { font-size: 64px; font-weight: bold; color: #E86A17; line-height: 1; }
.stat-caption { color: #A08870; font-size: 14px; margin-top: 6px; }
.stat-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 8px;
  background: #fff;
  border-radius: 16px;
  border: 2px solid #F0E2D0;
}
.stat-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 2px; }
.stat-bar { width: 100%; max-width: 26px; background: #FFB84D; border-radius: 6px 6px 0 0; min-height: 2px; }
.stat-bar-day { font-size: 9px; color: #B09880; }
.stat-button-list { display: flex; flex-direction: column; gap: 8px; }
.stat-button-row {
  display: flex;
  justify-content: space-between;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  border: 2px solid #F0E2D0;
  font-size: 15px;
}

.setting-row { margin: 16px 0; }
.setting-row label { display: block; font-size: 15px; font-weight: bold; margin-bottom: 8px; }
.setting-row input[type="range"] { width: 100%; }
.setting-help { font-size: 12px; color: #A08870; margin: 6px 0 0; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  background: #F3E7D8;
  color: #8A7360;
  font-weight: bold;
}
.seg button.active { background: #FF8C42; color: #fff; }
hr { border: none; border-top: 2px dashed #E8D5C0; margin: 22px 0; }

.primary-btn {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  background: #FF8C42;
  color: #fff;
  font-size: 17px;
  font-weight: bold;
}
.secondary-btn {
  display: inline-block;
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #E8D5C0;
  color: #4A3728;
  font-size: 15px;
  text-align: center;
  margin: 6px 0;
}
.danger-btn {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #F5B5B5;
  color: #C0392B;
  font-size: 14px;
  margin-top: 6px;
}

.guide-list { font-size: 14px; line-height: 1.9; padding-left: 20px; }

/* ───── つかいかた画面 ───── */
#screen-guide {
  padding-top: env(safe-area-inset-top);
  padding-bottom: 40px;
}
.guide-body {
  padding: 0 16px 14px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.guide-body h3 { color: #E86A17; font-size: 16px; margin: 20px 0 6px; }

/* ───── おうちのこえ（ろくおんタブ） ───── */
/* タブが5つになったので、せまい画面でも はみ出さないよう折り返し可にする */
.parent-tabs { flex-wrap: wrap; }
.tab-btn { white-space: nowrap; font-size: 13px; padding: 10px 2px; }
.voice-title { color: #E86A17; font-size: 16px; margin: 4px 0 6px; }
.voice-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  padding: 8px 12px;
  border: 2px solid #F0E2D0;
}
.voice-row .vr-name { font-size: 16px; font-weight: bold; flex-shrink: 0; }
.voice-row .vr-state { flex: 1; font-size: 12px; color: #B09880; text-align: right; }
.voice-row .vr-state.has-voice { color: #4CAF50; font-weight: bold; }
.voice-row .vr-state.recording { color: #C0392B; font-weight: bold; animation: rec-blink 1s infinite; }
@keyframes rec-blink { 50% { opacity: 0.35; } }
.voice-row .vr-actions { display: flex; gap: 6px; flex-shrink: 0; }
.voice-row .vr-actions button {
  min-width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #F3E7D8;
  font-size: 16px;
  padding: 0 8px;
}
.voice-row .vr-actions .vr-stop { background: #C0392B; color: #fff; font-weight: bold; font-size: 14px; }

/* ───── ダイアログ ───── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 55, 40, 0.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog {
  background: #FFF8F0;
  border-radius: 22px;
  padding: 20px;
  width: min(94vw, 440px);
  max-height: 88dvh;
  overflow-y: auto;
}
.dialog h3 { margin: 0 0 14px; color: #E86A17; }
.edit-photo-row { display: flex; gap: 12px; align-items: center; }
.edit-preview {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  background: #F3E7D8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  overflow: hidden;
  flex-shrink: 0;
}
.edit-preview img { width: 100%; height: 100%; object-fit: cover; }
.edit-photo-btns { flex: 1; }
.file-btn { display: block; cursor: pointer; }
.edit-label { display: block; font-size: 13px; font-weight: bold; color: #8A7360; margin: 14px 0 4px; }
.dialog input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #E8D5C0;
  font-size: 17px;
  background: #fff;
}
.emoji-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.emoji-suggest button {
  font-size: 24px;
  background: #fff;
  border: 2px solid #F0E2D0;
  border-radius: 10px;
  padding: 4px 8px;
}
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 3px solid transparent;
}
.color-swatch.selected { border-color: #4A3728; }
.dialog-btns { display: flex; gap: 10px; margin-top: 18px; }
.dialog-btns button { flex: 1; margin: 0; }
