/* ==========================================================
   ボートグランプリ -BOAT GRAND PRIX- - style.css
   ========================================================== */

:root {
  --color-bg-top: #0a2a4a;
  --color-bg-bottom: #06182e;
  --color-box: #0e2e4e;
  --color-box-border: #3fc6e8;
  --color-primary: #ff6b3d;
  --color-primary-2: #ffb347;
  --color-good: #3fe0a0;
  --color-danger: #ff4d5e;
  --color-text: #eaf6ff;
  --color-text-muted: #9fc4dd;
  --color-border: #1c5d86;
  --header-h: 56px;
  --hud-h: 76px;
  --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 {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- ヘッダー ---------- */
.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(6, 24, 46, 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);
}

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

.race-hud {
  flex: 0 0 var(--hud-h);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  gap: 0.5rem;
  z-index: 15;
  pointer-events: none;
}

.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.lap-box {
  background: rgba(6, 24, 46, 0.75);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  padding: 0.2rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

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

.lap-box__value {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--color-primary-2);
  font-variant-numeric: tabular-nums;
}

.minimap {
  width: 60px;
  height: 80px;
  background: rgba(6, 24, 46, 0.75);
  border: 2px solid var(--color-border);
  border-radius: 8px;
}

.hud-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(6, 24, 46, 0.75);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
  min-width: 92px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.rank-row.is-player {
  color: #fff;
}

.rank-row__pos {
  width: 1.1em;
  text-align: right;
  color: var(--color-primary-2);
}

.rank-row__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  flex: 0 0 auto;
}

/* ---------- 実況テロップ ---------- */
.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, 107, 61, 0.92), rgba(255, 179, 71, 0.92));
  padding: 0.45rem 1.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.8s 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;
}

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

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

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

body.mode-wake .tap-zone {
  display: block;
}

/* ---------- モード2: 競艇式大時計 ---------- */
/* ボートは助走中オーバルをほぼ1周する（コースの内側＝中央付近を通らない）ため、
   canvas四隅のどこかに置けばレース中いつボートがどこにいてもかぶらない。左上に固定表示する。 */
.start-clock {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 16;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.start-clock.is-visible {
  display: flex;
}

.start-clock__face {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 4px solid var(--color-primary-2);
  background: radial-gradient(circle at 50% 42%, #133458, #06182e 78%);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.25), 0 8px 22px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.start-clock.is-armed .start-clock__face {
  border-color: var(--color-good);
  box-shadow: 0 0 0 4px rgba(63, 224, 160, 0.3), 0 10px 30px rgba(0, 0, 0, 0.5);
}

.start-clock.is-flying .start-clock__face {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 4px rgba(255, 77, 94, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5);
}

.start-clock__tick {
  position: absolute;
  width: 3px;
  height: 7px;
  background: rgba(255, 255, 255, 0.55);
  left: 50%;
  top: 4px;
  margin-left: -1.5px;
  transform-origin: 1.5px 42px;
}

.start-clock__tick--0 { transform: rotate(0deg); background: var(--color-primary-2); height: 9px; }
.start-clock__tick--90 { transform: rotate(90deg); }
.start-clock__tick--180 { transform: rotate(180deg); }
.start-clock__tick--270 { transform: rotate(270deg); }

.start-clock__hand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 36px;
  background: linear-gradient(180deg, #fff, var(--color-primary-2));
  border-radius: 3px;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
  box-shadow: 0 0 6px rgba(255, 179, 71, 0.7);
}

.start-clock.is-armed .start-clock__hand { background: linear-gradient(180deg, #fff, var(--color-good)); }
.start-clock.is-flying .start-clock__hand { background: linear-gradient(180deg, #fff, var(--color-danger)); }

.start-clock__hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary-2);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 5px rgba(255, 179, 71, 0.8);
}

.start-clock__value {
  font-size: 0.85rem;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  background: rgba(6, 24, 46, 0.75);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
}

/* 大時計とは独立して、画面（.game-stage）最下部に固定表示する操作ヒント */
.start-clock-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 16;
  display: none;
  font-size: 0.65rem;
  font-weight: bold;
  color: #fff;
  background: rgba(6, 24, 46, 0.75);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}

.start-clock-hint.is-visible {
  display: block;
}

/* ---------- モード2: フライング大フラッシュ ---------- */
.flying-flash {
  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, 77, 94, 0.55), rgba(120, 6, 16, 0.92));
  pointer-events: none;
}

.flying-flash.is-visible {
  display: flex;
  animation: flying-flash-in 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.flying-flash__text {
  font-size: 3.1rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(255, 60, 60, 0.9), 0 6px 12px rgba(0, 0, 0, 0.6);
  transform: scale(0.4) rotate(-4deg);
}

.flying-flash__sub {
  font-size: 1.3rem;
  font-weight: 900;
  color: #ffe9e9;
}

@keyframes flying-flash-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.flying-flash.is-visible .flying-flash__text {
  animation: flying-text-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

@keyframes flying-text-pop {
  0% { transform: scale(0.3) rotate(-8deg); }
  60% { transform: scale(1.18) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ---------- モード2: トップスタート カットイン ---------- */
.topstart-cutin {
  position: fixed;
  top: 38%;
  left: 0;
  right: 0;
  z-index: 41;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
}

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

.topstart-cutin__text {
  font-size: 2rem;
  font-weight: 900;
  color: #1a1300;
  background: linear-gradient(135deg, #ffe082, var(--color-primary-2));
  padding: 0.35rem 1.4rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: skewX(-6deg);
}

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

@keyframes topstart-in {
  0% { transform: translateX(-60vw); opacity: 0; }
  12% { transform: translateX(0); opacity: 1; }
  82% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(60vw); opacity: 0; }
}

/* ---------- モード選択 ---------- */
.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(6, 24, 46, 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(3, 12, 24, 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: #0a1a2a;
  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; }
  .start-clock__ring { width: 116px; height: 116px; }
}
