/* ==========================================================
   バイクトライアル - style.css
   ========================================================== */

:root {
  --color-bg: #1a0f2e;
  --color-sky-top: #2d1b4e;
  --color-accent: #ff6b35;
  --color-accent-2: #ffd93d;
  --color-text: #f5f0ff;
  --color-text-muted: #b8a9d9;
  --color-border: #4a3570;
  --header-h: 56px;
  --ad-h: 64px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  background: linear-gradient(180deg, #241640, #1a0f2e);
  border-bottom: 2px solid var(--color-border);
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.back-link:active {
  background: rgba(255, 255, 255, 0.15);
}

.game-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin: 0;
  color: var(--color-accent-2);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn.is-muted {
  color: var(--color-text-muted);
}

/* ---------- ゲームステージ ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--color-sky-top), #1a0f2e 75%);
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 5;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.control-hint.is-hidden {
  opacity: 0;
}

.control-hint__zone {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14%;
}

.control-hint__zone span {
  font-size: 0.75rem;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

/* ---------- 距離ゲージ ---------- */
.progress-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(70%, 360px);
  height: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  z-index: 10;
  overflow: visible;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-2));
  transition: width 0.15s linear;
}

.progress-bar__flag {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 5, 20, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay__box {
  text-align: center;
  padding: 1.6rem 2rem;
  background: #241640;
  border: 2px solid var(--color-border);
  border-radius: 18px;
  max-width: 85%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay__title {
  font-size: 1.6rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  color: var(--color-accent-2);
}

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 0.9rem;
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-accent), #ff8c5a);
  color: #fff;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.overlay__btn:active {
  filter: brightness(0.9);
}

.overlay__btn--secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-border);
  margin-top: 0.6rem;
  margin-left: 0.6rem;
}

/* ---------- ガイド画面 ---------- */
.guide-section {
  text-align: left;
  margin: 1rem 0;
}

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-accent-2);
  margin: 0 0 0.4rem;
}

.guide-section__text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.6;
}

.guide-section__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.7;
}

.guide-section__list li {
  margin-bottom: 0.3rem;
}

/* ---------- バイク選択画面 ---------- */
.bike-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin: 1.2rem 0 1.4rem;
}

@media (min-width: 420px) {
  .bike-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.bike-card {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bike-card.is-selected {
  border-color: var(--color-accent-2);
  background: rgba(255, 217, 61, 0.1);
}

.bike-card__img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  margin: 0 auto 0.4rem;
}

.bike-card__name {
  font-size: 0.78rem;
  font-weight: bold;
  margin: 0 0 0.3rem;
}

.bike-card__desc {
  font-size: 0.66rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
  line-height: 1.4;
  min-height: 2.6em;
}

.bike-card__stats {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bike-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6rem;
  color: var(--color-text-muted);
}

.bike-stat__label {
  flex: 0 0 32px;
  text-align: left;
}

.bike-stat__bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bike-stat__bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-2));
  border-radius: 999px;
}

/* ---------- ステージ名トースト ---------- */
.stage-toast {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(10, 5, 20, 0.8);
  border: 1px solid var(--color-border);
  color: var(--color-accent-2);
  font-size: clamp(0.9rem, 4.2vw, 1.2rem);
  font-weight: 900;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  white-space: nowrap;
}

.stage-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 広告スペース ---------- */
.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 2px dashed var(--color-border);
  background: #150c26;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  z-index: 20;
  overflow: hidden;
}

/* 横画面の低い高さでは操作ヒントの余白を詰める */
@media (max-height: 420px) {
  .control-hint__zone {
    padding-bottom: 6%;
  }
  .ad-slot {
    --ad-h: 44px;
    font-size: 0.65rem;
  }
}
