/* ==========================================================
   崖ギリギリチキンレース - style.css
   ========================================================== */

:root {
  --color-bg-top: #2a1220;
  --color-bg-bottom: #170a14;
  --color-box: #241226;
  --color-box-border: #ff8a3d;
  --color-primary: #ff5d3d;
  --color-primary-2: #ffb347;
  --color-good: #3fe0a0;
  --color-danger: #ff3d5e;
  --color-text: #fff2ea;
  --color-text-muted: #d9b3ae;
  --color-border: #6b2f3a;
  --header-h: 56px;
  --hud-h: 60px;
  --ad-h: 60px;
}

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

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

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

img, canvas { display: block; }

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  background: rgba(23, 10, 20, 0.85);
  border-bottom: 2px solid var(--color-border);
  position: relative;
  z-index: 45;
}

.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.08);
  flex: 0 0 auto;
}

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

.game-title {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--color-primary-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

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

.icon-btn:active { background: rgba(255, 255, 255, 0.22); }
.icon-btn.is-muted { color: var(--color-text-muted); }

/* ---------- ステージ全体 ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- HUD ---------- */
.race-hud {
  flex: 0 0 var(--hud-h);
  display: flex;
  align-items: center;
  padding: 0.3rem 0.6rem;
  z-index: 15;
  pointer-events: none;
}

.hud-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

.game-stage[data-mode="collapse"] .hud-row--collapse { display: flex; }
.game-stage[data-mode="corner"] .hud-row--corner { display: flex; }
.game-stage[data-mode="dash"] .hud-row--dash { display: flex; }

.hud-box {
  background: rgba(23, 10, 20, 0.75);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  padding: 0.2rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.hud-box__label {
  font-size: 0.56rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.hud-box__value {
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--color-primary-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.guts-gauge, .heat-gauge {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 200px;
}

.guts-gauge__label, .heat-gauge__label {
  font-size: 0.56rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.guts-gauge__track, .heat-gauge__track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid var(--color-border);
  overflow: hidden;
}

.guts-gauge__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2));
  transition: width 0.15s linear;
}

.guts-gauge.is-max .guts-gauge__fill {
  background: linear-gradient(90deg, #fff176, #ff5d3d);
  animation: guts-pulse 0.4s ease infinite alternate;
}

@keyframes guts-pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.5); }
}

.heat-gauge__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4d7cff, var(--color-good));
  transition: width 0.2s linear, background 0.3s linear;
}

.heat-gauge.is-cold .heat-gauge__fill {
  background: linear-gradient(90deg, #4d7cff, #2a4a8a);
}

/* ---------- テロップ ---------- */
.telop-layer {
  position: absolute;
  top: calc(var(--hud-h) + 4px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 18;
  pointer-events: none;
}

.telop {
  font-size: 0.85rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 93, 61, 0.92), rgba(255, 179, 71, 0.92));
  padding: 0.4rem 1rem;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  transform: scale(0.5);
  opacity: 0;
  animation: telop-pop 1.6s ease forwards;
}

@keyframes telop-pop {
  0% { transform: scale(0.4); opacity: 0; }
  15% { transform: scale(1.12); opacity: 1; }
  25% { transform: scale(1); opacity: 1; }
  78% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0; }
}

/* ---------- ゲームキャンバス ---------- */
.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

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

.tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  z-index: 10;
}

.tap-zone--left { left: 0; }
.tap-zone--right { right: 0; }

.accel-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 12;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid var(--color-primary-2);
  background: rgba(255, 93, 61, 0.35);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.accel-btn.is-active { background: rgba(255, 93, 61, 0.75); }

body.touch-controls .accel-btn { display: flex; }

.brake-btn {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 12;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--color-danger);
  background: rgba(255, 61, 94, 0.28);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.brake-btn.is-active { background: rgba(255, 61, 94, 0.72); }

body.touch-controls .game-stage[data-mode="dash"] .brake-btn { display: flex; }

/* ---------- ガッツタイム カットイン ---------- */
.guts-cutin {
  position: fixed;
  top: 40%;
  left: 0;
  right: 0;
  z-index: 41;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
}

.guts-cutin.is-visible {
  display: flex;
  animation: guts-cutin-in 1.4s ease forwards;
}

.guts-cutin__text {
  font-size: 2.1rem;
  font-weight: 900;
  color: #1a0a00;
  background: linear-gradient(135deg, #fff176, var(--color-primary-2));
  padding: 0.3rem 1.3rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: skewX(-6deg);
}

.guts-cutin__sub {
  font-size: 0.9rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

@keyframes guts-cutin-in {
  0% { transform: translateY(-30px); opacity: 0; }
  12% { transform: translateY(0); opacity: 1; }
  82% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-30px); opacity: 0; }
}

/* ---------- 直線チキンダッシュ: スローモーリプレイ ---------- */
.dash-replay {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: radial-gradient(circle, rgba(255, 61, 94, 0.35), rgba(23, 10, 20, 0.92));
  pointer-events: none;
}

.dash-replay.is-visible {
  display: flex;
  animation: dash-replay-in 0.5s ease forwards;
}

@keyframes dash-replay-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.dash-replay__title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.03em;
  text-shadow: 0 0 20px rgba(255, 93, 61, 0.9);
}

.dash-replay__value {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--color-primary-2);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* ---------- モード選択 ---------- */
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 1rem;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  color: var(--color-text);
}

.mode-card:active {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--color-primary-2);
}

.mode-card__icon { font-size: 1.6rem; flex: 0 0 auto; }

.mode-card__title {
  display: block;
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--color-primary-2);
}

.mode-card__desc {
  display: block;
  font-size: 0.74rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.74rem;
  font-weight: bold;
  color: #fff;
  background: rgba(23, 10, 20, 0.7);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.control-hint.is-visible { opacity: 1; }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 3, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

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

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: var(--color-box);
  border: 3px solid var(--color-box-border);
  border-radius: 22px;
  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;
}

.guide-section { text-align: left; margin: 1rem 0; }

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-primary-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; }

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

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 0.88rem;
  font-weight: bold;
  white-space: pre-line;
  line-height: 1.7;
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #1a0a00;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
}

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

.overlay__btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.result-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- 広告スペース ---------- */
.ad-gap { flex: 0 0 6px; }

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.7rem 0.6rem;
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  z-index: 20;
  overflow: hidden;
}

@media (max-height: 640px) {
  .ad-slot { --ad-h: 44px; font-size: 0.65rem; }
}
