:root {
  color-scheme: light;
  --bg: #eef6fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --ink: #172331;
  --muted: #5b6b79;
  --accent: #eb0a1e;
  --warm: #8edbff;
  --danger: #f04452;
  --line: rgba(38, 68, 91, 0.18);
  --shadow: 0 14px 40px rgba(58, 91, 116, 0.16);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 18% 10%, rgba(235, 10, 30, 0.09), transparent 28rem),
    radial-gradient(circle at 84% 20%, rgba(97, 190, 230, 0.22), transparent 24rem),
    linear-gradient(160deg, #f8fcff 0%, #eaf4fa 48%, #dcecf5 100%);
  color: var(--ink);
  touch-action: manipulation;
}

/* 画面を1枚に固定：ページスクロール・ピンチズーム・ラバーバンドを禁止。
   高さは inset:0 で visual viewport に追従（iOSのアドレスバー伸縮にもズレない） */
body {
  position: fixed;
  inset: 0;
  width: 100%;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 2px solid #1778b8;
  border-radius: 8px;
  padding: 0 18px;
  background: linear-gradient(180deg, #198ed2, #0870b2);
  color: #ffffff;
  box-shadow: 0 5px 12px rgba(12, 105, 167, 0.24);
  font-weight: 800;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  width: min(100vw, 620px);
  height: 100%;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 14px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  /* 操作中に文字/要素が選択されたり、iOSの長押しコピーが出ないようにする */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 名前入力だけは選択・編集できるように戻す */
.name-field input {
  user-select: text;
  -webkit-user-select: text;
}

/* メイン：左=プレイエリア / 右=縦カラム(CHANGE・キャラ・SCORE)。ここ全体が相対スライドの操作領域 */
.main-row {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  touch-action: none; /* 相対スライド中にスクロール/選択を起こさない */
}

/* 左：プレイエリアを内包し中央に置く。相対スライド操作の領域 */
.game-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* 相対スライド中にスクロール/ズームを起こさない */
}

/* 右：CHANGE / キャラ / SCORE を縦に並べる固定幅カラム */
.side-column {
  flex: 0 0 clamp(138px, 34%, 190px);
  min-width: 0;  /* 中の数字(スコア)の幅につられてカラムが広がらない＝桁数でレイアウトを変えない */
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: none; /* キャラ/SCORE付近を触っても玉を操作できるように（CHANGEのみ除外） */
}

.side-column .change-panel { flex: 0 0 auto; }
.side-column .score-panel { flex: 0 0 auto; }
.side-column .character { flex: 1 1 auto; min-height: 0; }

.screen-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eaf4fa;
}

.start-modal {
  cursor: pointer;
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
  transition: opacity 500ms ease;
}

.screen-modal.hidden {
  display: none;
}

.screen-art {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
}

.start-modal .screen-art {
  background-image:
    linear-gradient(180deg, rgba(234, 247, 255, 0.03) 0%, rgba(255, 255, 255, 0.02) 50%, rgba(223, 241, 250, 0.18) 100%),
    url("./assets/auto/screens/start_game_title_portrait.png?v=toyota-title-v2");
  z-index: 3;
  opacity: 1;
  transition: opacity 200ms ease-out;
}

.start-modal.is-title-fading .screen-art {
  opacity: 0;
}

.start-movie {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
  opacity: 1;
  pointer-events: none;
}

.start-modal:not(.is-playing-movie) .start-movie {
  visibility: hidden;
}

.start-modal.movie-fallback .start-movie {
  display: none;
}

.gameover-modal .screen-art {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(232, 243, 249, 0.46)),
    url("./assets/auto/screens/gameover_portrait.png?v=toyota-bright-v2");
}

/* PC/横長画面では縦長の背景画像を「縦フィット」させる（横幅合わせで拡大されすぎないように）。
   上下にちょっと余白を入れる（高さ90%・中央）。スマホ縦(3:4より縦長)はそのまま cover で画面を満たす。 */
@media (min-aspect-ratio: 3 / 4) {
  .start-modal .screen-art,
  .gameover-modal .screen-art {
    background-size: cover, auto 90%;
    background-repeat: no-repeat;
    background-position: center;
  }
}

.screen-copy {
  position: relative;
  width: min(92vw, 460px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.90);
  box-shadow: 0 26px 80px rgba(37, 66, 88, 0.24);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 14px;
}

.start-copy {
  position: absolute;
  inset: 0;
  width: 100%;
  max-height: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  padding: max(8vh, 48px) 18px max(7vh, 34px);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.start-title {
  width: min(92vw, 500px);
  color: #092d51;
  text-align: center;
  filter: drop-shadow(0 5px 0 rgba(255, 255, 255, 0.82)) drop-shadow(0 12px 18px rgba(14, 83, 135, 0.28));
}

.start-title-small {
  display: inline-block;
  margin-bottom: -2px;
  padding: 3px 22px;
  border: 1px solid rgba(44, 146, 209, 0.62);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.78), rgba(219,245,255,.92), rgba(255,255,255,.78));
  color: #1c71a8;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 900;
  letter-spacing: .16em;
}

.start-title h2 {
  margin: 3px 0 0;
  color: #092d51;
  font-size: clamp(38px, 10vw, 58px);
  font-weight: 1000;
  line-height: 1.02;
  letter-spacing: -.08em;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.85);
  text-shadow:
    0 2px 0 #ffffff,
    0 5px 0 #74c7ef,
    0 8px 0 #165f96,
    0 13px 20px rgba(4, 54, 94, 0.32);
}

.start-title-line {
  display: block;
  width: min(330px, 72vw);
  height: 4px;
  margin: 12px auto 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #27a9e8 18%, #ffffff 48%, #eb0a1e 82%, transparent);
  box-shadow: 0 0 14px rgba(46, 173, 232, 0.8);
}

.start-title p {
  margin: 0;
  color: #195b88;
  font-size: clamp(10px, 2.6vw, 13px);
  font-weight: 900;
  letter-spacing: .28em;
  line-height: 1.2;
}

.start-action {
  width: min(86vw, 390px);
  display: grid;
  gap: 8px;
  place-items: center;
}

.start-button {
  position: relative;
  width: 100%;
  min-height: 70px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.98);
  border-radius: 999px;
  padding: 0 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.48), transparent 38%),
    linear-gradient(110deg, #0b75bd 0%, #21b8ed 48%, #0963a7 75%, #eb0a1e 100%);
  color: #fff;
  box-shadow:
    0 0 0 5px rgba(35, 147, 211, .25),
    inset 0 -5px 0 rgba(4, 67, 116, .42),
    inset 0 2px 0 rgba(255,255,255,.82),
    0 13px 28px rgba(4, 76, 129, .35);
  font-size: clamp(19px, 5vw, 25px);
  font-weight: 1000;
  letter-spacing: .08em;
  text-shadow: 0 2px 2px rgba(2, 50, 86, .7);
  pointer-events: auto;
  animation: start-button-pulse 1.9s ease-in-out infinite;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.start-button::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: inherit;
}

.start-button::after {
  content: "";
  position: absolute;
  top: -30%;
  left: -45%;
  width: 28%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.84), transparent);
  transform: skewX(-20deg);
  animation: start-button-shine 2.6s ease-in-out infinite;
}

.start-button span {
  position: relative;
  z-index: 1;
}

.start-modal.is-tapped .start-button {
  transform: scale(.93);
  filter: brightness(1.35);
  box-shadow: 0 0 0 12px rgba(62, 188, 239, .18), 0 0 42px rgba(235, 10, 30, .55);
}

.start-tap-hint {
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  color: #184f75 !important;
  font-size: 12px !important;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1.4 !important;
  box-shadow: 0 4px 12px rgba(23, 87, 128, .16);
}

.start-tap-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.start-modal.is-whiting .start-tap-flash {
  animation: start-white-cover 500ms ease-in forwards;
}

@keyframes start-button-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@keyframes start-button-shine {
  0%, 55% { left: -45%; opacity: 0; }
  66% { opacity: 1; }
  82%, 100% { left: 120%; opacity: 0; }
}

@keyframes start-white-cover {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.game-fade {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(255, 255, 255);
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

.game-fade.is-covering {
  opacity: 1;
}

.game-fade.is-revealing {
  opacity: 0;
  transition: opacity 340ms cubic-bezier(.4, 0, 1, 1);
}

/* The finished title, logo and button are all rendered into the splash illustration. */
.start-modal .start-copy {
  inset: 0;
  padding: 0;
}

.start-modal .start-button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  animation: none;
  cursor: pointer;
}

.start-modal .start-button::before,
.start-modal .start-button::after {
  display: none;
}

.gameover-copy {
  align-self: start;
  margin-top: 5vh;
  text-align: center;
}

.screen-kicker {
  color: #a50717;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.screen-copy h2 {
  font-size: 30px;
  line-height: 1.08;
}

.screen-copy p {
  color: #526675;
  font-size: 15px;
  line-height: 1.65;
}

#finalScore {
  color: #172331;
  font-size: 42px;
  line-height: 1;
}

.bonus-message {
  color: #a50717;
  font-size: 15px;
  font-weight: 900;
}

.primary-button:not(.start-button) {
  min-height: 54px;
  border-color: rgba(255, 191, 105, 0.55);
  background: linear-gradient(135deg, #8edbff, #eb0a1e);
  color: #142235;
  font-size: 17px;
  font-weight: 900;
}

/* 上：製品情報パネル（全幅・固定高） */
.title-panel {
  flex: 0 0 auto;
}

.score-panel,
.next-panel,
.title-panel {
  border: 1px solid rgba(38, 68, 91, 0.16);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.score-panel,
.next-panel {
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 8px;
}

.score-panel strong {
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
}

.score-panel {
  gap: 5px;
  min-width: 0;
  overflow: hidden; /* 万一スコアが枠より広くても、枠は広げずクリップ＝レイアウト不変 */
}

.score-line {
  min-width: 0;
  max-width: 100%;
}

.score-line,
.best-line {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.best-line {
  min-width: 74px;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(235, 10, 30, 0.10);
  color: #a50717;
  font-size: 11px;
  font-weight: 900;
}

.best-line strong {
  font-size: 16px;
}

.next-panel canvas {
  width: 84px;
  height: 48px;
}

/* CHANGE パネル＝タップで初期3アイテムを循環 */
.change-panel {
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  grid-template-rows: auto 1fr auto;
  gap: 2px;
  padding: 6px 8px;
  border: 2px solid #1778b8;
  background: linear-gradient(180deg, #eff9ff, #d8effc);
  box-shadow: 0 6px 16px rgba(12, 105, 167, 0.20);
}

.change-panel:active {
  transform: translateY(1px);
}

.change-panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.change-hint {
  color: #b00020;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.panel-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.title-panel {
  min-width: 0;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  text-align: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  line-height: 1.18;
}

.title-panel p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-info {
  min-width: 0;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  text-align: left;
}

.product-info img {
  width: 70px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
  -webkit-user-drag: none;
  pointer-events: none;
}

.game-wrap {
  position: relative;
  /* 実寸は app.js の sizeGameWrap() が px で設定（玉は等倍・はみ出さない・.game-left の中央） */
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 340 / 620;
  min-height: 0;
  border: 1px solid rgba(38, 68, 91, 0.20);
  border-radius: 8px;
  overflow: visible;
  background:
    linear-gradient(rgba(61, 104, 134, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 104, 134, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(218, 235, 245, 0.88));
  background-size: 42px 42px, 42px 42px, 100% 100%;
  box-shadow: var(--shadow);
  touch-action: none;
}

.danger-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 8px;
  background: rgba(255, 44, 73, 0.24);
  opacity: 0;
  pointer-events: none;
}

.game-wrap.danger .danger-flash {
  animation: dangerPulse 500ms ease-in-out infinite;
}

@keyframes dangerPulse {
  0%, 100% { opacity: 0.06; }
  50% { opacity: 0.42; }
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#gameCanvas:active {
  cursor: grabbing;
}

.line-label {
  position: absolute;
  top: calc(16% + 7px);
  left: 14px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid rgba(176, 0, 32, 0.28);
  background: rgba(255, 245, 247, 0.84);
  color: rgba(176, 0, 32, 0.76);
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1.2;
  pointer-events: none;
}

/* 右カラム中段：キャラ。盤面には重ねず、CHANGEとSCOREの間のスペースを大きく埋める */
.character {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
  transform-origin: center bottom;
  transition: transform 240ms ease, filter 240ms ease;
}

/* 全表情を高さ基準で揃え、キリ番や進化時だけ小さく見える現象を防ぐ。 */
.character.adult .researcher,
.character.dandy .researcher {
  background-size: 100% auto;
}

.researcher {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 100% auto;
}

.character-glow {
  position: absolute;
  left: 8%;
  bottom: 14px;
  width: 84%;
  height: 42%;
  border-radius: 50%;
  opacity: 0.45;
  filter: blur(12px);
  z-index: -1;
}

.researcher > span,
.character.image-ready .researcher > span {
  display: none;
}

.stage-0 .character-glow { background: #8edbff; }
.stage-1 .character-glow { background: #eb0a1e; }
.stage-2 .character-glow { background: #8bd3ff; }
.stage-3 .character-glow { background: #ff8cc6; }
.stage-4 .character-glow { background: #fff0a8; }

.hair {
  position: absolute;
  top: 2%;
  left: 17%;
  width: 66%;
  height: 43%;
  border-radius: 48% 48% 38% 38%;
  background: #382337;
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, 0.18);
}

.head {
  position: absolute;
  top: 8%;
  left: 21%;
  width: 58%;
  height: 38%;
  border-radius: 48% 48% 46% 46%;
  background: #ffd9c7;
  border: 2px solid rgba(255, 255, 255, 0.58);
  box-shadow: inset -7px -7px 0 rgba(180, 112, 91, 0.15);
}

.body-coat {
  position: absolute;
  left: 18%;
  bottom: 7%;
  width: 64%;
  height: 47%;
  border-radius: 24% 24% 14% 14%;
  background:
    linear-gradient(90deg, transparent 48%, rgba(35, 75, 100, 0.22) 49% 51%, transparent 52%),
    linear-gradient(160deg, #ffffff, #dbefff);
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.22);
}

.body-coat::before {
  content: "";
  position: absolute;
  top: 18%;
  left: 34%;
  width: 32%;
  height: 16%;
  border-radius: 0 0 999px 999px;
  background: #3cc1b0;
}

.arm {
  position: absolute;
  bottom: 28%;
  width: 15%;
  height: 30%;
  border-radius: 999px;
  background: #f5fbff;
  transform-origin: top center;
}

.arm.left {
  left: 9%;
  transform: rotate(22deg);
}

.arm.right {
  right: 8%;
  transform: rotate(-31deg);
}

.beaker {
  position: absolute;
  right: 0;
  bottom: 28%;
  width: 22%;
  height: 20%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-top: 0;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(0deg, rgba(71, 215, 172, 0.8) 0 44%, rgba(255, 255, 255, 0.18) 45%);
}

.eye {
  position: absolute;
  top: 36%;
  width: 9%;
  height: 12%;
  border-radius: 50%;
  background: #10202c;
}

.eye.left { left: 31%; }
.eye.right { right: 31%; }

.mouth {
  position: absolute;
  left: 38%;
  bottom: 29%;
  width: 24%;
  height: 12%;
  border-bottom: 4px solid #10202c;
  border-radius: 0 0 999px 999px;
}

#characterLabel {
  flex: 0 0 auto;
  align-self: center;
  max-width: 100%;
  margin-top: 2px;
  border-radius: 999px;
  padding: 3px 4px;
  background: rgba(255, 255, 255, 0.92);
  color: #172331;
  box-shadow: 0 4px 14px rgba(37, 66, 88, 0.18);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
}

.character.cheer .researcher {
  animation: cheer 360ms ease;
}

.character.evolve .researcher {
  animation: evolve 680ms ease;
}

.character.milestone .researcher {
  animation: milestone 820ms ease;
}

.character.sad {
  transform: rotate(-7deg) scale(0.92);
  filter: grayscale(0.35);
}

@keyframes cheer {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  45% { transform: scale(0.96) rotate(-2deg); filter: brightness(1.18); }
}

@keyframes evolve {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(0.94); filter: brightness(1.7); }
  70% { transform: scale(0.98); filter: brightness(1.2); }
}

@keyframes milestone {
  0%, 100% { transform: translateY(0) rotate(0) scale(1); }
  18% { transform: rotate(-4deg) scale(0.96); }
  38% { transform: rotate(4deg) scale(0.98); }
  58% { transform: rotate(-2deg) scale(0.95); }
}

.name-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.name-field input {
  min-height: 44px;
  border: 2px solid rgba(23, 120, 184, 0.48);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ranking-head h2,
.ranking-head h3 {
  font-size: 1rem;
  margin: 0;
}

.ranking-list {
  max-height: 116px;
  margin: 8px 0 0;
  padding-left: 24px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  overflow: auto;
  overscroll-behavior: contain;
}

.ranking-list li {
  padding-right: 8px;
}

.ranking-list strong {
  color: var(--ink);
}

.gameover-ranking {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

/* 横画面（短い画面=スマホ横）では縦持ちを促すオーバーレイ。iPadの横（高さ大）には出さない */
.rotate-hint {
  display: none;
}

@media (orientation: landscape) and (max-height: 540px) {
  .rotate-hint {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #0d1a27;
    color: var(--ink);
    text-align: center;
    font-size: 19px;
    font-weight: 900;
    line-height: 1.5;
  }

  .rotate-emoji {
    font-size: 40px;
    margin-bottom: 8px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-inline: 8px;
  }

  .title-panel {
    min-height: 54px;
  }

  .score-panel,
  .next-panel {
    min-height: 58px;
  }

  .next-panel canvas {
    width: 78px;
    height: 44px;
  }

  /* Keep every smartphone character expression comfortably inside its column. */
  .side-column .character .researcher {
    background-size: 72% auto;
  }

  h1 {
    font-size: 17px;
  }

  .title-panel p {
    font-size: 12px;
    line-height: 1.42;
  }

  .product-info {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 8px;
  }

  .product-info img {
    width: 56px;
    height: 48px;
  }

  .screen-modal {
    padding: 12px;
  }

  .start-copy,
  .gameover-copy {
    justify-self: center;
    margin: 0;
  }

  .start-copy {
    padding: max(7vh, 44px) 12px max(6vh, 26px);
  }

  .screen-copy {
    padding: 18px;
  }

  .screen-copy h2 {
    font-size: 24px;
  }

  #finalScore {
    font-size: 34px;
  }
}

/* ブランドスプラッシュ（起動時：白 → SYNCHROTRONロゴ → 裏でアセット先読み → タイトル） */
.brand-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: #ffffff;
  transition: opacity 700ms ease; /* フェードアウト 0.7s */
}
.brand-splash.is-hiding { opacity: 0; pointer-events: none; }
.brand-splash.is-gone { display: none; }
.brand-logo {
  width: min(62vw, 360px);
  height: auto;
  opacity: 0;
  animation: brand-logo-in 700ms ease 1s forwards; /* 1s白 → 0.7sフェードイン */
}
@keyframes brand-logo-in {
  to { opacity: 1; }
}
