/* ==========================================================
   じわり変化さがし：3手法比較 - style.css
   ========================================================== */

:root {
  --color-bg-top: #141a30;
  --color-bg-bottom: #0a0e1c;
  --color-box: #1c2340;
  --color-box-border: #3a4470;
  --color-accent: #ffd166;
  --color-accent-2: #7ad7f0;
  --color-good: #5fd68a;
  --color-danger: #ff6b6b;
  --color-text: #eef1fa;
  --color-text-muted: #9aa4c7;
  --color-border: #2c355c;
  --header-h: 56px;
  --tabs-h: 46px;
}

* {
  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);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  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: rgba(20, 26, 48, 0.85);
  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.08);
  flex: 0 0 auto;
}

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

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

.header-actions {
  display: flex;
  gap: 0.4rem;
  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.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

/* ---------- 問題カウンター ---------- */
.score-bar {
  height: var(--tabs-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--color-border);
}

.stat-box {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.stat-box__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.stat-box__value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-accent);
}

.stat-box__value--sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.stat-box__value--stars {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--color-accent);
}

/* ---------- メインステージ ---------- */
.game-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.7rem 0.8rem 0.4rem;
  min-height: 0;
  overflow-y: auto;
}

.stage-frame {
  width: 100%;
  max-width: 460px;
  position: relative;
}

.stage-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #05070f;
  border: 2px solid var(--color-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  isolation: isolate;
}

.stage-media__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}

.stage-media__reveal {
  position: absolute;
  border: 2px dashed var(--color-accent);
  border-radius: 6px;
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
}

.stage-media__reveal.is-visible { opacity: 1; }

.stage-media__hitlayer {
  position: absolute;
  inset: 0;
  z-index: 6;
  cursor: pointer;
}

.stage-media__ring {
  position: absolute;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  margin-top: -27px;
  border-radius: 50%;
  border: 3px solid var(--color-good);
  box-shadow: 0 0 18px rgba(95, 214, 138, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 7;
}

.stage-media__ring.is-correct {
  animation: ring-pop 0.7s ease-out forwards;
  border-color: var(--color-good);
  box-shadow: 0 0 18px rgba(95, 214, 138, 0.7);
}

.stage-media__ring.is-wrong {
  animation: ring-shake 0.4s ease-out forwards;
  border-color: var(--color-danger);
  box-shadow: 0 0 14px rgba(255, 107, 107, 0.6);
}

@keyframes ring-pop {
  0% { opacity: 0; transform: scale(0.4); }
  40% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.5); }
}

@keyframes ring-shake {
  0% { opacity: 0.9; transform: translate(0, 0); }
  25% { transform: translate(-6px, 0); }
  50% { transform: translate(6px, 0); }
  75% { transform: translate(-4px, 0); }
  100% { opacity: 0; transform: translate(0, 0); }
}

.stage-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -8px);
  background: rgba(10, 14, 28, 0.88);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
  z-index: 8;
}

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

.stage-desc {
  max-width: 460px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  margin: 0.6rem 0 0.2rem;
  line-height: 1.5;
}

.debug-controls {
  display: flex;
  gap: 0.5rem;
  margin: 0.6rem 0 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.debug-btn {
  border: 1px solid var(--color-border);
  background: var(--color-box);
  color: var(--color-text);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.debug-btn:active { background: var(--color-border); }
.debug-btn.is-active { border-color: var(--color-accent); color: var(--color-accent); }

/* ---------- 広告スペース ---------- */
.ad-gap { flex: 0 0 auto; height: 0.4rem; }

.ad-slot {
  flex: 0 0 auto;
  margin: 0 0.8rem 0.8rem;
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  padding: 0.9rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  overflow: hidden;
}

/* ---------- ガイドオーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.overlay__box {
  background: var(--color-box);
  border: 1px solid var(--color-box-border);
  border-radius: 18px;
  padding: 1.4rem 1.3rem;
  max-width: 420px;
  width: 100%;
  max-height: 86dvh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay__box--wide { max-width: 480px; }

.overlay__title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 0.9rem;
  text-align: center;
  color: var(--color-accent);
}

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

.guide-section { margin-bottom: 1rem; }

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

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

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

.overlay__btn {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-accent), #ff9f4a);
  color: #2a1c00;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.85rem;
  cursor: pointer;
}

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

@media (min-width: 720px) {
  .stage-frame { max-width: 520px; }
}
