:root {
  --bg-page: #dcece5;
  --ink: #283c46;
  --ink-soft: #5a6e78;
  --card-bg: rgba(255, 255, 255, 0.84);
  --card-border: rgba(145, 178, 188, 0.9);
  --accent-rain: #468cdc;
  --accent-amber: #e28e2b;
  --accent-gold: #e6b83a;
  --accent-coral: #e45d4a;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 25%, #ebf5f0 0%, #cfe3da 100%);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.desktop-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(140, 172, 182, 0.65);
  font-size: 11px;
  color: var(--ink-soft);
  z-index: 50;
}

.toolbar-title {
  font-weight: 700;
  color: var(--ink);
}

.size-btn {
  border: 1px solid rgba(120, 160, 175, 0.6);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  cursor: pointer;
}

.size-btn.active {
  background: #3d7d8c;
  color: #fff;
  border-color: #3d7d8c;
}

.seed-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  opacity: 0.85;
}

.phone-shell {
  width: 375px;
  height: 667px;
  max-width: 100vw;
  max-height: calc(100dvh - 44px);
  border-radius: 22px;
  box-shadow: 0 18px 46px rgba(32, 62, 72, 0.24);
  overflow: hidden;
  position: relative;
  background: #e9f3ee;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.22s ease;
}

.phone-shell.compact-preview {
  height: 560px;
}

.phone-shell.no-height-transition {
  transition: none;
}

.game-stage {
  position: relative;
  width: 375px;
  height: 667px;
  flex-shrink: 0;
  transform: scale(var(--stage-scale, 1));
  transform-origin: center center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.game-stage.short-layout {
  height: 560px;
}

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

/* 水入れ替えトランジション */
.water-wipe {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(160, 224, 240, 0.85), rgba(90, 168, 214, 0.92));
  transform: translateY(105%);
  pointer-events: none;
  z-index: 40;
}

.water-wipe.active {
  animation: waterSweep 0.34s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes waterSweep {
  0% { transform: translateY(100%); opacity: 0.95; }
  45% { transform: translateY(0%); opacity: 0.95; }
  100% { transform: translateY(-105%); opacity: 0; }
}

/* HUD 上部（SPEC_V2 §10：左上SCORE、右上NEXT2個、中央は空けてジウの顔を見せる） */
.hud-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  z-index: 15;
}

.hud-card {
  background: rgba(255, 255, 255, 0.90);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 4px 10px 3px;
  box-shadow: 0 2px 8px rgba(45, 80, 92, 0.08);
}

.hud-score {
  min-width: 112px;
  height: 50px;
}

.hud-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.1;
  letter-spacing: 0.03em;
}

.hud-value {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.hud-right-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.hud-next {
  width: 86px;
  height: 50px;
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#nextCanvas {
  display: block;
  width: 74px;
  height: 32px;
  margin-top: 1px;
}

.sound-toggle {
  pointer-events: auto;
  touch-action: manipulation;
  width: 28px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.90);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.sound-toggle.muted {
  opacity: 0.65;
}

/* 水鉢下の独立ドック（進化の雫バー＋慈雨ボタン） */
.bottom-dock {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 22;
}

.evo-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(145, 185, 195, 0.78);
  box-shadow: 0 2px 8px rgba(40, 75, 88, 0.10);
  pointer-events: none;
}

.evo-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(70, 95, 105, 0.55);
  background: rgba(220, 232, 236, 0.7);
  position: relative;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease;
}

.evo-dot.reached {
  transform: scale(1.16);
  border-color: #fff;
  box-shadow: 0 0 0 1px rgba(60, 85, 95, 0.5);
}

.evo-dot.next-target {
  animation: targetPulse 1.4s ease-in-out infinite;
}

@keyframes targetPulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.26); opacity: 1; }
}

/* ジウの声（吹き出し） */
.jiu-speech {
  position: absolute;
  top: 62px;
  left: 10px;
  max-width: 148px;
  padding: 5px 10px;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid #96c3bd;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(45, 80, 90, 0.14);
  opacity: 0;
  transform: translateY(6px) scale(0.94);
  transition: opacity 0.2s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 16;
}

.jiu-speech.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.jiu-speech.visible.pop {
  animation: jiuSpeechPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jiu-speech.tone-rain {
  border-color: #4aa8d8;
  background: rgba(244, 251, 255, 0.96);
  box-shadow: 0 4px 12px rgba(52, 130, 178, 0.18);
}

.jiu-speech.tone-cheer {
  border-color: #e6b83a;
  background: rgba(255, 252, 240, 0.96);
  box-shadow: 0 4px 12px rgba(196, 148, 36, 0.20);
}

.jiu-speech.tone-warm {
  border-color: #6bb58b;
  background: rgba(246, 253, 248, 0.96);
  box-shadow: 0 4px 12px rgba(62, 130, 92, 0.16);
}

@keyframes jiuSpeechPop {
  0% {
    opacity: 0.72;
    transform: translateY(5px) scale(0.86);
  }
  55% {
    opacity: 1;
    transform: translateY(-2px) scale(1.06);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 初誕生 水彩リボン帯 */
.discovery-banner {
  position: absolute;
  left: 50%;
  bottom: 68px;
  transform: translateX(-50%) scale(0.9);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(242, 252, 248, 0.96), rgba(255, 255, 255, 0.94));
  border: 2px solid rgba(110, 180, 170, 0.85);
  box-shadow: 0 6px 18px rgba(35, 75, 85, 0.18);
  opacity: 0;
  pointer-events: none;
  z-index: 18;
  white-space: nowrap;
  transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.discovery-banner.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.discovery-new,
.chorus-new {
  display: none;
  background: linear-gradient(135deg, #f7c948, #e68a2e);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  margin-right: 5px;
}

.discovery-banner.is-lifetime-new .discovery-new,
.chorus-banner.is-lifetime-new .chorus-new {
  display: inline-block;
}

.discovery-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

/* 大合唱 帯 */
.chorus-banner {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 8px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 48, 46, 0.92), rgba(28, 72, 62, 0.94));
  border: 2px solid #f0cb69;
  color: #fff8df;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chorus-banner.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.chorus-sub {
  font-size: 11px;
  color: #a8f0b8;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chorus-main {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #ffe48a;
}

/* 慈雨ボタン＆しずくチャージゲージ（割合表示・数字なし） */
.rain-btn-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border-radius: 999px;
  --charge-deg: 0deg;
}

.rain-charge-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: conic-gradient(
    from -90deg,
    #52b8f5 0deg var(--charge-deg),
    rgba(165, 198, 214, 0.42) var(--charge-deg) 360deg
  );
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.jiu-rain-btn {
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  touch-action: manipulation;
  height: 44px;
  min-width: 112px;
  padding: 0 13px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: radial-gradient(circle at 32% 28%, #77bdf5 0%, #468cdc 65%, #3470ba 100%);
  color: #fff;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(42, 98, 168, 0.34);
  cursor: pointer;
  z-index: 22;
  transition: transform 0.18s ease, opacity 0.2s ease, filter 0.2s ease;
}

.rain-charge-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--charge-pct, 0%);
  background: linear-gradient(180deg, rgba(132, 212, 255, 0.45), rgba(66, 152, 232, 0.62));
  pointer-events: none;
  transition: height 0.22s ease;
}

.rain-drop-icon,
.rain-title,
.rain-dir-arrow,
.rain-sub {
  position: relative;
  z-index: 1;
}

.rain-drop-icon {
  font-size: 13px;
  line-height: 1;
}

.rain-dir-arrow {
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: #e6f6ff;
}

.jiu-rain-btn:active:not(:disabled) {
  transform: scale(0.93);
}

.jiu-rain-btn.locked,
.jiu-rain-btn.charging {
  background: radial-gradient(circle at 32% 28%, #9fb3bf 0%, #7d93a1 100%);
  box-shadow: 0 3px 8px rgba(55, 75, 85, 0.22);
  opacity: 0.92;
  cursor: default;
}

.jiu-rain-btn.used {
  background: #8aa0ad;
  opacity: 0.55;
  box-shadow: none;
  cursor: default;
}

.jiu-rain-btn.unlock-pop {
  animation: rainUnlockPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jiu-rain-btn.nudge-ready {
  animation: rainNudge 1.6s ease-in-out infinite;
}

@keyframes rainUnlockPop {
  0% { transform: scale(0.8); }
  45% { transform: scale(1.16); box-shadow: 0 0 0 8px rgba(85, 168, 240, 0.32); }
  100% { transform: scale(1); }
}

@keyframes rainNudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5px); }
}

.rain-ripple {
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 2px solid rgba(120, 200, 255, 0);
  pointer-events: none;
}

.jiu-rain-btn.unlock-pop .rain-ripple {
  animation: rippleExpand 0.65s ease-out;
}

@keyframes rippleExpand {
  0% { transform: scale(0.9); border-color: rgba(120, 200, 255, 0.9); }
  100% { transform: scale(1.35); border-color: rgba(120, 200, 255, 0); }
}

.rain-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.rain-sub {
  font-size: 10.5px;
  font-weight: 700;
  color: #e6f2ff;
}

.aim-hint {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(40, 60, 70, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 14;
  transition: opacity 0.25s ease;
}

.aim-hint.hidden {
  opacity: 0;
}

.quick-retry-btn {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 8px;
  height: 44px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #4db584, #2f966e);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  box-shadow: 0 6px 16px rgba(47, 150, 110, 0.34);
  cursor: pointer;
  touch-action: manipulation;
  z-index: 36;
}

.quick-retry-btn.hidden {
  display: none;
}

/* リザルトオーバーレイ */
.result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 42, 48, 0.66);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  z-index: 35;
  opacity: 1;
  transition: opacity 0.22s ease;
}

.result-overlay.hidden {
  display: none;
  opacity: 0;
}

.result-card {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  background: rgba(252, 255, 253, 0.97);
  border: 2px solid #9dc5be;
  border-radius: 20px;
  padding: 12px 14px 14px;
  box-shadow: 0 14px 36px rgba(15, 36, 44, 0.35);
  animation: slideUpCard 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUpCard {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-badge {
  font-size: 11px;
  font-weight: 800;
  color: #356e65;
  background: #e1f3ee;
  padding: 2px 9px;
  border-radius: 999px;
}

.result-reason {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* リザルト画面 ジウのミニポートレート帯（v3.4 Phase 3） */
.result-jiu-strip {
  --result-jiu-pos: 50% 24%;
  --result-jiu-scale: 1.75;
  --result-jiu-origin: 50% 26%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  min-height: 56px;
  padding: 2px 8px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid #96c3bd;
  background: #f4faf7;
}

.result-jiu-strip.tone-cheer {
  border-color: #e6b83a;
  background: #fffbef;
}

.result-jiu-strip.tone-warm {
  border-color: #6bb58b;
  background: #f2fbf5;
}

.result-jiu-strip.tone-relief {
  border-color: #7ab8b2;
  background: #eef9f8;
}

.result-jiu-avatar {
  width: 50px;
  height: 50px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #96c3bd;
  background: #fbf9ef;
  box-shadow: 0 2px 6px rgba(38, 68, 76, 0.14);
  animation: resultJiuPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.result-jiu-strip.tone-cheer .result-jiu-avatar {
  border-color: #e6b83a;
}

.result-jiu-strip.tone-warm .result-jiu-avatar {
  border-color: #6bb58b;
}

.result-jiu-strip.tone-relief .result-jiu-avatar {
  border-color: #7ab8b2;
}

.result-jiu-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: var(--result-jiu-pos, 50% 24%);
  transform: scale(var(--result-jiu-scale, 1.75));
  transform-origin: var(--result-jiu-origin, 50% 26%);
}

.result-jiu-bubble {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@keyframes resultJiuPop {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

.parade-wrap {
  background: #eef7f4;
  border-radius: 12px;
  padding: 6px 8px;
  margin-bottom: 10px;
}

.parade-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  flex-wrap: wrap;
}

.parade-item {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: paradeHop 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.parade-item img,
.parade-item canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.parade-next-silhouette {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px dashed #7aa3a8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #5b858b;
  background: rgba(255, 255, 255, 0.7);
}

@keyframes paradeHop {
  from { transform: translateY(8px) scale(0.7); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.result-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.hero-frog-box {
  width: 82px;
  height: 76px;
  border-radius: 14px;
  background: radial-gradient(circle, #f3faf7 0%, #ddf0ea 100%);
  border: 1.5px solid #b8dcd4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
}

.hero-frog-box img,
.hero-frog-box canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.hero-stats {
  flex: 1;
  min-width: 0;
}

.hero-species {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 2px;
}

.hero-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hero-score-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
}

.hero-score {
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.hero-best {
  font-size: 11px;
  font-weight: 700;
  color: #5c7a75;
  margin-top: 2px;
}

.hero-benchmark {
  font-size: 11px;
  font-weight: 800;
  color: #2f7282;
  margin-top: 1px;
}

.result-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.meta-pill {
  background: #eef7f4;
  border: 1px solid #c7e0d9;
  border-radius: 10px;
  padding: 4px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.meta-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.meta-val {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.closeness-msg {
  background: linear-gradient(90deg, #fff6dc, #fff0c4);
  border: 1.5px solid #ecc664;
  border-radius: 11px;
  padding: 7px 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  color: #6b4b09;
  margin-bottom: 9px;
}

.closeness-msg.is-record {
  background: linear-gradient(90deg, #ffeaa8, #ffd970);
  border-color: #d89b1c;
  color: #5a3800;
}

.sound-nudge {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #467887;
  margin-bottom: 7px;
}

.sound-nudge.hidden {
  display: none;
}

.retry-btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #4db584, #2f966e);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.05em;
  box-shadow: 0 6px 16px rgba(47, 150, 110, 0.34);
  cursor: pointer;
  touch-action: manipulation;
}

.retry-btn:active {
  transform: scale(0.98);
}

@media (max-width: 430px), (max-height: 600px) {
  .desktop-toolbar {
    display: none;
  }
  .phone-shell {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

.game-stage.short-layout .bottom-dock {
  bottom: 4px;
  height: 46px;
}

.game-stage.short-layout .jiu-rain-btn {
  height: 44px;
  min-width: 100px;
  padding: 0 12px;
}

.game-stage.short-layout .aim-hint {
  bottom: 56px;
}

.game-stage.short-layout .discovery-banner {
  bottom: 62px;
}

.game-stage.short-layout .quick-retry-btn {
  bottom: 5px;
  height: 44px;
}

.phone-shell.compact-preview .result-overlay,
.game-stage.short-layout .result-overlay {
  padding: 8px 10px;
}

.phone-shell.compact-preview .result-card,
.game-stage.short-layout .result-card {
  padding: 8px 11px 9px;
  border-radius: 16px;
}

.phone-shell.compact-preview .result-head,
.game-stage.short-layout .result-head {
  margin-bottom: 5px;
  gap: 6px;
}

.phone-shell.compact-preview .result-badge,
.game-stage.short-layout .result-badge {
  font-size: 10.5px;
  line-height: 1.25;
  padding: 2px 8px;
  white-space: nowrap;
}

.phone-shell.compact-preview .result-reason,
.game-stage.short-layout .result-reason {
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-shell.compact-preview .result-jiu-strip,
.game-stage.short-layout .result-jiu-strip {
  height: 46px;
  min-height: 46px;
  padding: 1px 7px;
  margin-bottom: 5px;
  gap: 8px;
}

.phone-shell.compact-preview .result-jiu-avatar,
.game-stage.short-layout .result-jiu-avatar {
  width: 42px;
  height: 42px;
}

.phone-shell.compact-preview .result-jiu-bubble,
.game-stage.short-layout .result-jiu-bubble {
  font-size: 11px;
  line-height: 1.28;
}

.phone-shell.compact-preview .parade-wrap,
.game-stage.short-layout .parade-wrap {
  padding: 3px 6px;
  margin-bottom: 5px;
  border-radius: 10px;
}

.phone-shell.compact-preview .parade-row,
.game-stage.short-layout .parade-row {
  min-height: 28px;
  gap: 5px;
}

.phone-shell.compact-preview .parade-item,
.game-stage.short-layout .parade-item {
  width: 26px;
  height: 26px;
}

.phone-shell.compact-preview .parade-next-silhouette,
.game-stage.short-layout .parade-next-silhouette {
  width: 25px;
  height: 25px;
  font-size: 11px;
}

.phone-shell.compact-preview .result-hero,
.game-stage.short-layout .result-hero {
  gap: 10px;
  margin-bottom: 5px;
}

.phone-shell.compact-preview .hero-frog-box,
.game-stage.short-layout .hero-frog-box {
  width: 60px;
  height: 58px;
  padding: 3px;
}

.phone-shell.compact-preview .hero-species,
.game-stage.short-layout .hero-species {
  font-size: 13.5px;
  line-height: 1.25;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-shell.compact-preview .hero-score-label,
.game-stage.short-layout .hero-score-label {
  font-size: 10px;
  line-height: 1.1;
}

.phone-shell.compact-preview .hero-score,
.game-stage.short-layout .hero-score {
  font-size: 21px;
  line-height: 1.08;
}

.phone-shell.compact-preview .hero-best,
.game-stage.short-layout .hero-best {
  font-size: 10.5px;
  line-height: 1.25;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-shell.compact-preview .hero-benchmark,
.game-stage.short-layout .hero-benchmark {
  font-size: 10.5px;
  line-height: 1.25;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-shell.compact-preview .result-meta-grid,
.game-stage.short-layout .result-meta-grid {
  gap: 5px;
  margin-bottom: 5px;
}

.phone-shell.compact-preview .meta-pill,
.game-stage.short-layout .meta-pill {
  padding: 3px 5px;
  gap: 0;
  border-radius: 8px;
}

.phone-shell.compact-preview .meta-label,
.game-stage.short-layout .meta-label {
  font-size: 9px;
  line-height: 1.25;
}

.phone-shell.compact-preview .meta-val,
.game-stage.short-layout .meta-val {
  font-size: 12px;
  line-height: 1.25;
}

.phone-shell.compact-preview .closeness-msg,
.game-stage.short-layout .closeness-msg {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1.25;
  margin-bottom: 6px;
  border-radius: 9px;
}

.phone-shell.compact-preview .sound-nudge,
.game-stage.short-layout .sound-nudge {
  font-size: 10.5px;
  line-height: 1.25;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-shell.compact-preview .retry-btn,
.game-stage.short-layout .retry-btn {
  height: 44px;
  font-size: 16px;
  border-radius: 12px;
}


/* ===== v3.9 トップ画面・全員ランキング・リザルト追記 ===== */
.title-overlay {
  position: absolute;
  inset: 0;
  background: rgba(24, 52, 58, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 14px;
  z-index: 34;
}

.title-overlay.hidden {
  display: none;
}

.title-card {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  background: rgba(252, 255, 253, 0.94);
  border: 2px solid #9dc5be;
  border-radius: 22px;
  padding: 18px 16px 16px;
  box-shadow: 0 14px 36px rgba(15, 36, 44, 0.28);
  text-align: center;
}

.title-jiu-wrap {
  width: 104px;
  height: 104px;
  margin: 0 auto 10px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #8fc0b7;
  background: #fbf9ef;
  box-shadow: 0 5px 14px rgba(32, 66, 74, 0.18);
}

.title-jiu-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 24%;
  transform: scale(1.65);
  transform-origin: 50% 26%;
}

.title-heading {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.title-seed {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #356e65;
  background: #e4f4ef;
  border: 1px solid #b8dcd4;
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

.title-best {
  font-size: 12.5px;
  font-weight: 800;
  color: #3a5d66;
  background: #f2f9f6;
  border: 1px solid #cde4dd;
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 12px;
}

.title-name-field {
  text-align: left;
  margin-bottom: 14px;
}

.title-name-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.name-input {
  width: 100%;
  height: 36px;
  border: 1.5px solid #9cc4bc;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
  outline: none;
  font-family: inherit;
}

.name-input:focus {
  border-color: #3d9a7a;
  box-shadow: 0 0 0 2px rgba(61, 154, 122, 0.18);
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.title-play-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #4db584, #2f966e);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 16px rgba(47, 150, 110, 0.34);
  cursor: pointer;
  touch-action: manipulation;
}

.title-play-btn:active {
  transform: scale(0.98);
}

.title-ranking-btn {
  width: 100%;
  height: 40px;
  border: 1.5px solid #7ab1ba;
  border-radius: 12px;
  background: #fff;
  color: #2c6d7a;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.title-ranking-btn:active {
  transform: scale(0.98);
}

/* ランキングオーバーレイ */
.ranking-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 42, 48, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 38;
}

.ranking-overlay.hidden {
  display: none;
}

.ranking-card {
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(252, 255, 253, 0.98);
  border: 2px solid #9dc5be;
  border-radius: 20px;
  padding: 12px 14px 14px;
  box-shadow: 0 14px 36px rgba(15, 36, 44, 0.38);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ranking-title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
}

.ranking-close-btn {
  border: 1px solid #9cc2c8;
  border-radius: 999px;
  background: #f2f8f7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.ranking-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.ranking-tab {
  height: 34px;
  border: 1.5px solid #a8ccc6;
  border-radius: 10px;
  background: #eef7f4;
  color: #3a636b;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.ranking-tab.active {
  background: #2f8b75;
  border-color: #2f8b75;
  color: #fff;
}

.ranking-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 8px;
  min-height: 15px;
}

.ranking-body {
  flex: 1;
  min-height: 220px;
  max-height: 410px;
  overflow-y: auto;
  background: #f5faf8;
  border: 1px solid #cde3dd;
  border-radius: 12px;
  padding: 6px;
}

.ranking-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 12px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.ranking-status.hidden {
  display: none;
}

.ranking-retry-btn {
  border: none;
  border-radius: 999px;
  background: #2f7b8a;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 18px;
  cursor: pointer;
  touch-action: manipulation;
}

.ranking-retry-btn.hidden {
  display: none;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #dcebe7;
  font-size: 12.5px;
}

.ranking-row.is-self {
  background: #fff8de;
  border-color: #e6ba4c;
  box-shadow: 0 1px 4px rgba(208, 152, 24, 0.16);
}

.ranking-rank {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-weight: 900;
  color: #3a756c;
  font-variant-numeric: tabular-nums;
}

.ranking-row.rank-top3 .ranking-rank {
  color: #c97d12;
}

.ranking-name-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ranking-name {
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-date {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.ranking-score {
  flex-shrink: 0;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* リザルト画面：名前設定＆ランキング状態＆ボタン行 */
.result-ranking-box {
  margin-bottom: 7px;
}

.result-name-saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #f2f8f6;
  border: 1px solid #cde2dc;
  border-radius: 9px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.result-name-saved.hidden,
.result-name-input-wrap.hidden {
  display: none;
}

.result-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-name-edit-btn {
  flex-shrink: 0;
  border: 1px solid #96bec4;
  border-radius: 999px;
  background: #fff;
  color: #2f7282;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  cursor: pointer;
}

.result-name-input {
  height: 30px;
  font-size: 11.5px;
  border-radius: 8px;
  padding: 0 8px;
}

.result-ranking-status {
  font-size: 10.5px;
  font-weight: 800;
  color: #2c7a5c;
  text-align: center;
  min-height: 0;
  margin-top: 3px;
}

.result-ranking-status:empty {
  display: none;
}

.result-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-ranking-btn {
  flex: 0 0 108px;
  height: 46px;
  border: 1.5px solid #7ab1ba;
  border-radius: 14px;
  background: #fff;
  color: #2c6d7a;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.result-ranking-btn:active {
  transform: scale(0.98);
}

.result-action-row .retry-btn {
  flex: 1;
}

/* 短画面（375×560）対応 */
.phone-shell.compact-preview .title-overlay,
.game-stage.short-layout .title-overlay {
  padding: 10px 12px;
}

.phone-shell.compact-preview .title-card,
.game-stage.short-layout .title-card {
  padding: 12px 14px 12px;
  border-radius: 18px;
}

.phone-shell.compact-preview .title-jiu-wrap,
.game-stage.short-layout .title-jiu-wrap {
  width: 78px;
  height: 78px;
  margin-bottom: 6px;
}

.phone-shell.compact-preview .title-heading,
.game-stage.short-layout .title-heading {
  font-size: 18px;
  margin-bottom: 4px;
}

.phone-shell.compact-preview .title-seed,
.game-stage.short-layout .title-seed {
  font-size: 10px;
  margin-bottom: 6px;
}

.phone-shell.compact-preview .title-best,
.game-stage.short-layout .title-best {
  font-size: 11.5px;
  padding: 4px 8px;
  margin-bottom: 8px;
}

.phone-shell.compact-preview .title-name-field,
.game-stage.short-layout .title-name-field {
  margin-bottom: 10px;
}

.phone-shell.compact-preview .name-input,
.game-stage.short-layout .name-input {
  height: 32px;
  font-size: 12px;
}

.phone-shell.compact-preview .title-play-btn,
.game-stage.short-layout .title-play-btn {
  height: 42px;
  font-size: 16px;
}

.phone-shell.compact-preview .title-ranking-btn,
.game-stage.short-layout .title-ranking-btn {
  height: 36px;
  font-size: 13px;
}

.phone-shell.compact-preview .ranking-body,
.game-stage.short-layout .ranking-body {
  min-height: 170px;
  max-height: 330px;
}

.phone-shell.compact-preview .result-ranking-box,
.game-stage.short-layout .result-ranking-box {
  margin-bottom: 4px;
}

.phone-shell.compact-preview .result-name-input,
.game-stage.short-layout .result-name-input {
  height: 26px;
  font-size: 11px;
}

.phone-shell.compact-preview .result-ranking-btn,
.game-stage.short-layout .result-ranking-btn {
  flex: 0 0 96px;
  height: 44px;
  font-size: 12px;
  border-radius: 12px;
}
