:root {
  --sky: #e0f2fe;
  --grass: #bbf7d0;
  --grass-dark: #86efac;
  --ink: #1f2937;
  --accent: #f97316;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: 'Hiragino Maru Gothic ProN', 'Rounded Mplus 1c', 'BIZ UDPGothic', system-ui, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

svg { display: block; overflow: visible; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ---------------- スタート ---------------- */
#screen-start {
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px 16px;
  background: linear-gradient(var(--sky), var(--sky) 62%, var(--grass) 62%);
}
.title {
  margin: 0;
  font-size: clamp(40px, 13vw, 64px);
  line-height: 1.15;
  text-align: center;
  color: #fff;
  -webkit-text-stroke: 2px #ef4444;
  text-shadow: 0 5px 0 #ef4444;
  letter-spacing: 0.04em;
}
.start-cars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px 10px;
  width: min(100%, 340px);
}
.start-cars span { animation: hop 1.2s ease-in-out infinite; }
.start-cars span:nth-child(5n+2) { animation-delay: 0.12s; }
.start-cars span:nth-child(5n+3) { animation-delay: 0.24s; }
.start-cars span:nth-child(5n+4) { animation-delay: 0.36s; }
.start-cars span:nth-child(5n+5) { animation-delay: 0.48s; }
.start-cars svg { width: 100%; height: auto; }

.play-btn {
  width: clamp(120px, 36vw, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: clamp(56px, 16vw, 72px);
  box-shadow: 0 8px 0 #c2410c, 0 14px 24px rgba(0, 0, 0, 0.2);
  animation: pulse 1.4s ease-in-out infinite;
}
.play-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #c2410c; animation: none; }

.credit {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  margin: 0;
  font-size: 11px;
  color: rgba(31, 41, 55, 0.55);
}

/* ---------------- ゲーム画面 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 6px;
}
.icon-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  font-size: 30px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }

/* ひだりうえの 🏠（../common/back-button.js）の ぶんの あき */
.icon-spacer { width: 60px; height: 60px; flex: 0 0 60px; }

.stars {
  font-size: 26px;
  font-weight: bold;
  white-space: nowrap;
}
.stars.pop { animation: land 0.4s ease-out; }

/* えいごの じまく。あみだに かぶらないように ばしょを とっておく */
.subband {
  position: relative;
  z-index: 2;
  height: 96px;
  padding: 0 12px;
  flex: none;
}
.short .subband { height: 80px; }
.subtitle {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
}
.subtitle.show { opacity: 1; transform: none; }
.short .subtitle { padding: 5px 10px; }
.short .sub-en { font-size: 15px; }
.short .sub-ja { font-size: 11px; margin-top: 1px !important; }
.subtitle p { margin: 0; }
.subtitle.ja .sub-ja { display: none; }
.subtitle.ja .sub-en { font-family: 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif; }
.sub-en {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: clamp(16px, 5vw, 22px);
  font-weight: 800;
  line-height: 1.25;
}
.sub-ja {
  margin-top: 3px !important;
  font-size: clamp(12px, 3.6vw, 15px);
  color: #4b5563;
  line-height: 1.35;
}

/* ---------------- あみだ ---------------- */
.board {
  position: relative;
  flex: 1;
  margin: 0 8px calc(env(safe-area-inset-bottom) + 8px);
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 40%, #fde68a 0 3px, transparent 4px) 0 0 / 70px 60px,
    radial-gradient(circle at 70% 70%, #fbcfe8 0 3px, transparent 4px) 0 0 / 90px 80px,
    var(--grass);
  box-shadow: inset 0 0 0 4px var(--grass-dark);
  overflow: hidden;
}
.ladder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.road { stroke: #9ca3af; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail { fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; transition: opacity 0.4s; }
.trail.fade { opacity: 0; }
.garage.happy { animation: bump 0.5s ease-in-out 2; transform-box: fill-box; transform-origin: 50% 100%; }

/* スタートボタン：たての れつ ぜんぶを おせる はんいに する */
.starts {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
}
.start-btn {
  flex: 1;
  height: 100%;
  display: grid;
  place-items: center;
}
.start-btn span {
  display: grid;
  place-items: center;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent);
  color: var(--accent);
  font-size: calc(var(--d) * 0.42);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: opacity 0.3s, transform 0.15s;
}
.start-btn:active span { transform: translateY(3px); box-shadow: none; }
.start-btn.tried span { opacity: 0.35; border-color: #9ca3af; color: #9ca3af; }
.start-btn.hint span { animation: hinthop 0.7s ease-in-out infinite; }
.board.locked .start-btn { pointer-events: none; }

/* くるま（JS が translate と rotate を うごかす） */
.cars { position: absolute; inset: 0; pointer-events: none; }
.car {
  position: absolute;
  left: 0;
  top: 0;
  transition: opacity 0.25s;
}
.car svg { position: absolute; transform: translate(-50%, -50%); }
.car.waiting svg { animation: idle 1s ease-in-out infinite; }
.car.gone { opacity: 0; }
.car.appear { animation: fade 0.3s ease-out; }

/* ---------------- クリア ---------------- */
.clear {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.45);
  animation: fade 0.4s ease-out;
}
.clear-star { font-size: clamp(56px, 18vw, 88px); animation: land 0.5s ease-out; }
.clear-star.none { visibility: hidden; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}

/* ---------------- アニメーション ---------------- */
@keyframes hop     { 50% { transform: translateY(-10px); } }
@keyframes pulse   { 50% { transform: scale(1.06); } }
@keyframes idle    { 50% { transform: translate(-50%, calc(-50% - 4px)); } }
@keyframes hinthop { 50% { transform: translateY(-8px) scale(1.12); } }
@keyframes fade    { from { opacity: 0; } }
@keyframes land    { from { transform: scale(1.5); } }
@keyframes bump    { 40% { transform: translateY(-6px) scale(1.08); } }

@media (prefers-reduced-motion: reduce) {
  .start-cars span, .car.waiting svg, .play-btn { animation: none; }
  .start-btn.hint span { animation: none; transform: scale(1.12); box-shadow: 0 0 0 6px #fde047; }
}
