* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1a1420;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 画面の中央に置く。スマホ縦持ちでは js/orient.js が 90 度回して横画面にする(2026-10-24) */
body { display: flex; align-items: center; justify-content: center; }
#game {
  position: relative;
  width: min(96vw, calc(96vh * 4 / 3));
  aspect-ratio: 4 / 3;
  container-type: inline-size;  /* 文字の大きさは画面(#game)の幅に合わせる(cqw)。回しても崩れない */
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  background: #000;
}

/* ===== ステージ(背景) ===== */
#stage { position: absolute; inset: 0; overflow: hidden; }

.sky {
  position: absolute; inset: 0 0 45% 0;
  background: linear-gradient(#eda8b4 0%, #f4c3ae 45%, #f7dfc0 100%);
}

.sun {
  position: absolute; left: 18%; top: 9%;
  width: 15%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6dd 0%, #ffe9b8 45%, rgba(255, 233, 184, 0) 72%);
}

.cloud {
  position: absolute;
  height: 7%;
  border-radius: 999px;
  background: rgba(255, 244, 230, 0.55);
  filter: blur(6px);
  animation: drift 60s linear infinite;
}
.cloud1 { top: 10%; left: 55%; width: 28%; }
.cloud2 { top: 22%; left: 5%; width: 20%; animation-duration: 80s; animation-delay: -30s; }
@keyframes drift {
  from { transform: translateX(30%); }
  to   { transform: translateX(-160%); }
}

/* 並木(遠景) */
.trees {
  position: absolute; left: 0; right: 0; bottom: 42%;
  height: 22%;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="480" height="160"><g fill="%237b4b2e"><ellipse cx="70" cy="120" rx="70" ry="55"/><ellipse cx="180" cy="132" rx="55" ry="45"/><ellipse cx="300" cy="115" rx="75" ry="60"/><ellipse cx="420" cy="134" rx="60" ry="48"/></g><g fill="%23945f3a" opacity="0.85"><ellipse cx="120" cy="138" rx="45" ry="35"/><ellipse cx="250" cy="142" rx="50" ry="38"/><ellipse cx="390" cy="145" rx="42" ry="34"/></g></svg>');
  background-repeat: repeat-x;
  background-size: auto 100%;
  animation: scroll-bg 22s linear infinite;
}

/* レンガ塀 */
.wall-top {
  position: absolute; left: 0; right: 0; bottom: 43.2%;
  height: 2.6%;
  background: linear-gradient(#c9b09a, #a88a72);
}
.wall {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 43.5%;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="96" height="60"><rect width="96" height="60" fill="%236e3a2e"/><g fill="%23a05a48"><rect x="1.5" y="1.5" width="45" height="27"/><rect x="49.5" y="1.5" width="45" height="27"/><rect x="-22.5" y="31.5" width="45" height="27"/><rect x="25.5" y="31.5" width="45" height="27" fill="%23935243"/><rect x="73.5" y="31.5" width="45" height="27"/></g></svg>');
  background-size: auto 26%;
  animation: scroll-bg 5s linear infinite;
  filter: brightness(0.96);
}
@keyframes scroll-bg {
  from { background-position-x: 0; }
  to   { background-position-x: -480px; }
}

/* ===== キャラクター ===== */
#girl-wrap {
  position: absolute;
  right: 2%; bottom: -4%;
  width: 47%;
  animation: bob 0.92s ease-in-out infinite alternate;
}
#girl { width: 100%; height: auto; display: block; }
#girl.pop { animation: pop 0.35s ease-out; }
@keyframes bob {
  from { transform: translateY(0); }
  to   { transform: translateY(1.6%); }
}
@keyframes pop {
  0%   { transform: scale(0.965); }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.st { fill: none; stroke: #4a2c1a; stroke-width: 3.5; stroke-linecap: round; }
.st.thick { stroke-width: 5.5; }

/* 表情の出しわけ */
#girl .x { display: none; }
#girl[data-expr="cool"]  .x-cool  { display: inline; }
#girl[data-expr="smile"] .x-smile { display: inline; }
#girl[data-expr="tears"] .x-tears { display: inline; }
#girl[data-expr="blush"] .x-blush { display: inline; }
#girl[data-expr="shock"] .x-shock { display: inline; }
#girl[data-expr="pout"]  .x-pout  { display: inline; }

#boy-wrap {
  position: absolute;
  left: -3%; bottom: -6%;
  width: 22%;
  opacity: 0.92;
  animation: bob 0.92s ease-in-out -0.45s infinite alternate;
}
#boy { width: 100%; height: auto; display: block; }

/* ===== UI ===== */
#gauge {
  position: absolute; left: 2.5%; top: 3.5%;
  width: 13%;
  filter: drop-shadow(0 2px 3px rgba(60, 20, 30, 0.35));
}
#gauge svg { width: 100%; height: auto; display: block; }
#g-heart { fill: #e2454f; }
#g-heart.beat { animation: heartbeat 0.5s ease-out; }
@keyframes heartbeat {
  0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); }
}
#g-heart { transform-box: fill-box; transform-origin: center; }
#g-val { transition: stroke-dasharray 0.5s ease, stroke 0.5s ease; }

#delta-float {
  position: absolute; left: 70%; top: 8%;
  font-weight: bold; font-size: clamp(14px, 2.2cqw, 22px);
  opacity: 0; pointer-events: none; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}
#delta-float.show { animation: float-up 1.1s ease-out; }
#delta-float.plus { color: #e0447c; }
#delta-float.minus { color: #4d64b8; }
@keyframes float-up {
  0% { opacity: 0; transform: translateY(6px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}

#progress {
  position: absolute; right: 3%; top: 4.5%;
  display: flex; gap: 6px; align-items: center;
}
#progress .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  border: 1.5px solid rgba(90, 40, 40, 0.4);
}
#progress .dot.done { background: #e0447c; }
#progress .goal {
  font-size: 15px; line-height: 1;
  filter: grayscale(0.6) opacity(0.75);
}
#progress .goal.done { filter: none; }

#mute {
  position: absolute; right: 3%; top: 11%;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(90, 70, 120, 0.45);
  color: #fff; font-size: 16px;
  cursor: pointer;
}
#mute.muted { opacity: 0.45; }

/* PS1っぽい走査線 */
.scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    rgba(0, 0, 30, 0) 0 3px, rgba(0, 0, 30, 0.045) 3px 4px);
  mix-blend-mode: multiply;
}

/* 夕暮れ→たそがれ(分かれ道) */
#dusk-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(70, 40, 110, 0.35), rgba(120, 60, 80, 0.3));
  opacity: 0; transition: opacity 3s ease;
}
#stage.dusk #dusk-overlay { opacity: 1; }
#stage.dusk .trees, #stage.dusk .wall, #stage.dusk .wall-top,
#stage.dusk #girl-wrap, #stage.dusk #boy-wrap {
  animation-play-state: paused;
}

/* ===== 会話ウィンドウ ===== */
#dialog {
  position: absolute; left: 3%; right: 3%; bottom: 3.5%;
  min-height: 22%;
  padding: 2.2% 3% 3.2%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  background: linear-gradient(rgba(126, 116, 205, 0.62), rgba(96, 88, 170, 0.66));
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: clamp(14px, 2.6cqw, 24px);
  line-height: 1.65;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(40, 30, 90, 0.8);
  cursor: pointer;
}
#speaker { font-weight: bold; }
#next-arrow {
  position: absolute; right: 2.5%; bottom: 8%;
  animation: blink 0.9s steps(2) infinite;
  font-size: 0.8em;
}
@keyframes blink { 50% { opacity: 0; } }

/* ===== 表情パネル ===== */
#expr-panel {
  position: absolute; left: 3%; right: 3%; bottom: 28%;
  padding: 1.6% 2%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  background: linear-gradient(rgba(205, 126, 160, 0.55), rgba(170, 88, 130, 0.6));
  text-align: center;
}
.expr-title {
  color: #fff; font-size: clamp(12px, 2cqw, 18px);
  letter-spacing: 0.15em; margin-bottom: 8px;
  text-shadow: 0 1px 3px rgba(90, 30, 60, 0.8);
}
.expr-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.expr-btn {
  padding: 7px 2px 6px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  background: rgba(255, 250, 250, 0.88);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  font-family: inherit;
}
.expr-btn:hover, .expr-btn:focus-visible {
  transform: translateY(-3px) scale(1.06);
  background: #fff;
  outline: none;
}
.expr-btn .icon { display: block; font-size: clamp(18px, 3.4cqw, 32px); }
.expr-btn .label {
  display: block; margin-top: 2px;
  font-size: clamp(12px, 1.9cqw, 16px);
  color: #7a3a55; font-weight: bold;
}

/* ===== タイトル / エンディング ===== */
#title-screen, #end-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3.5%;
  text-align: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  z-index: 5;
}
#title-screen {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 240, 210, 0.5), transparent 40%),
    linear-gradient(#e89aa8 0%, #eeb49e 45%, #caa27e 75%, #7c5a48 100%);
}
#title-screen h1 {
  color: #fff;
  font-size: clamp(40px, 11cqw, 96px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-shadow: 0 3px 0 #b5607a, 0 8px 24px rgba(120, 40, 60, 0.5);
}
.title-sub, .title-hint {
  color: #fff;
  font-size: clamp(15px, 3cqw, 24px);
  font-weight: bold;
  letter-spacing: 0.12em;
  padding: 0.25em 0.9em;
  border-radius: 999px;
  background: rgba(90, 30, 50, 0.55);  /* 明るい背景の上でも読めるように(明暗比 4.5 以上) */
  text-shadow: 0 1px 3px rgba(60, 10, 30, 0.8);
}
.title-hint { font-size: clamp(14px, 2.6cqw, 21px); }

#start-btn, #retry-btn {
  font-family: inherit;
  font-size: clamp(16px, 2.8cqw, 24px);
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  padding: 0.6em 2.2em;
  color: #7a3a55;
  background: rgba(255, 252, 248, 0.92);
  border: 2px solid #fff;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(120, 40, 60, 0.35);
  transition: transform 0.15s ease;
}
#start-btn:hover, #retry-btn:hover { transform: scale(1.06); }

#end-screen {
  background: linear-gradient(#3d2c5e 0%, #7c4668 55%, #b56a70 100%);
}
#end-screen h2 {
  color: #ffe9ef;
  font-size: clamp(34px, 9cqw, 80px);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-shadow: 0 4px 20px rgba(30, 10, 40, 0.7);
}
#end-result {
  color: #fff;
  font-size: clamp(15px, 2.8cqw, 24px);
  letter-spacing: 0.12em;
}
#end-score {
  color: #ffd9e4;
  font-size: clamp(12px, 2cqw, 18px);
  letter-spacing: 0.1em;
}

/* フェード */
#fade {
  position: absolute; inset: 0;
  background: #fff7ee;
  opacity: 0; pointer-events: none;
  transition: opacity 2.2s ease;
  z-index: 4;
}
#fade.show { opacity: 1; }

.hidden { display: none !important; }
