/* =========================================
   ばあちゃん、お年玉ちょうだい。 見た目の設定
   色を変えたいときは、下の :root の色だけ変えればOK
   ========================================= */
:root {
  --red: #b3202a;
  --red-dark: #8a1820;
  --gold: #d9a441;
  --cream: #fbf5ea;
  --paper: #fffdf8;
  --ink: #3a2e28;
  --ink-soft: #7a6a60;
  --line: #eadfcd;
  --bubble-gran: #ffffff;
  --bubble-me: #fde3c3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--paper);
  box-shadow: 0 0 24px rgba(0,0,0,.06);
}

.screen { display: none; }
.screen.active { display: block; }

/* ---------- ボタン ---------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-dark { background: #111; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 2px solid var(--line); }
.btn-big { font-size: 20px; padding: 18px; margin: 28px 0 20px; }

/* ---------- タイトル ---------- */
#screen-title.active {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  background:
    radial-gradient(circle at 50% 0%, #fff6e4 0, transparent 60%),
    var(--paper);
}
.title-box { padding: 32px 24px; text-align: center; width: 100%; }
.title-emoji { font-size: 64px; }
.title {
  font-size: 32px;
  line-height: 1.35;
  margin: 12px 0;
  color: var(--red);
  letter-spacing: .02em;
}
.title-sub { color: var(--ink-soft); line-height: 1.7; margin: 0; }
.notes {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.8;
}

/* ---------- 会話画面 ---------- */
#screen-game.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--red);
  color: #fff;
}
.turn-label { font-weight: bold; font-size: 14px; white-space: nowrap; }
.progress { flex: 1; height: 8px; background: rgba(255,255,255,.3); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 5%; background: var(--gold); transition: width .4s; }

.grandma-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff8ee;
}
.grandma-face {
  font-size: 44px;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--line);
  transition: transform .3s;
}
.grandma-face.bounce { animation: bounce .4s; }
@keyframes bounce { 50% { transform: translateY(-6px); } }
.grandma-name { font-weight: bold; }
.grandma-mood { font-size: 13px; color: var(--ink-soft); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  -webkit-overflow-scrolling: touch;
}
.msg { display: flex; margin: 8px 0; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.msg .bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.gran .bubble { background: var(--bubble-gran); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--bubble-me); border-top-right-radius: 4px; }
.msg.system { justify-content: center; }
.msg.system .bubble { background: none; color: var(--ink-soft); font-size: 12px; }
.typing .bubble { color: var(--ink-soft); letter-spacing: .2em; }

.controls {
  padding: 10px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 64px;
}
.choice {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line);
  text-align: left;
  font-weight: normal;
  font-size: 15px;
  padding: 12px 14px;
}
.choice:active { border-color: var(--red); }
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* 16px未満だとiPhoneで勝手にズームされる */
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
}
.input-row input:focus { outline: none; border-color: var(--red); }
.input-row .btn { width: auto; padding: 12px 18px; }
.input-hint { font-size: 12px; color: var(--ink-soft); margin: 0 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- 結果画面 ---------- */
.result-box {
  text-align: center;
  padding: 32px 20px 24px;
  background:
    radial-gradient(circle at 50% 10%, #ffe9c4 0, transparent 55%),
    var(--paper);
}
.envelope { font-size: 80px; animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.3) rotate(-15deg); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.result-label { margin: 8px 0 0; color: var(--ink-soft); }
.result-amount {
  font-size: 44px;
  font-weight: bold;
  color: var(--red);
  margin: 4px 0 8px;
  line-height: 1.2;
  word-break: keep-all;
}
.result-amount.jackpot { color: var(--gold); text-shadow: 0 0 12px rgba(217,164,65,.6); animation: shine 1.2s infinite alternate; }
@keyframes shine { to { transform: scale(1.05); } }
.result-type {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: bold;
  font-size: 15px;
}
.result-type-desc { font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; }
.result-line {
  margin: 20px 0;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 17px;
  line-height: 1.7;
}
.result-line::before { content: "👵 "; }
.result-buttons { display: flex; flex-direction: column; gap: 10px; }
.result-preview { width: 100%; margin-top: 16px; border-radius: 12px; border: 1px solid var(--line); }
.small-note { font-size: 11px; color: var(--ink-soft); line-height: 1.7; margin-top: 14px; text-align: left; }

.shop-box {
  padding: 24px 20px 40px;
  border-top: 8px solid var(--cream);
}
.pr-label {
  display: inline-block;
  font-size: 11px;
  border: 1px solid var(--ink-soft);
  color: var(--ink-soft);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 0;
}
.shop-title { font-size: 20px; margin: 8px 0 4px; }
.shop-guess { font-size: 13px; color: var(--ink-soft); margin: 0 0 12px; }
.genre-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.genre-btn {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 4px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  position: relative;
}
.genre-btn .g-emoji { display: block; font-size: 24px; }
.genre-btn.selected { border-color: var(--red); background: #fff1ef; }
.genre-btn.guess::after {
  content: "おすすめ";
  position: absolute; top: -8px; right: -4px;
  background: var(--gold); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
}
.product-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.product {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.product-name { font-weight: bold; }
.product-price { font-size: 13px; color: var(--red); margin-top: 2px; }
.product-desc { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.product-link { font-size: 12px; color: #2a62c9; margin-top: 6px; }
.product-empty { font-size: 14px; color: var(--ink-soft); }

.footer-link { margin-top: 16px; font-size: 12px; }
.footer-link a, .small-note a { color: var(--ink-soft); }
