/* ==========================================================
   ナンバーハント - style.css
   ========================================================== */

:root {
  --color-bg-top: #241b4e;
  --color-bg-bottom: #120c2b;
  --color-primary: #6c5ce7;
  --color-primary-2: #00d9c9;
  --color-accent: #ffd93d;
  --color-danger: #ff5d5d;
  --color-text: #f2eefc;
  --color-text-muted: #a79bd1;
  --color-border: #40339c;
  --color-panel: #2a2064;
  --header-h: 56px;
  --score-h: 52px;
  --timer-h: 26px;
  --ad-h: 64px;
  --ad-gap-h: 18px;
}

* {
  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;
}

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

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

.game-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--color-accent);
}

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

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

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

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

/* ---------- スコアバー ---------- */
.score-bar {
  height: var(--score-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  z-index: 15;
}

.stat-box {
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stat-box--next {
  border-color: var(--color-accent);
}

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

.stat-box__value {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--color-primary-2);
}

.stat-box__value--next {
  color: var(--color-accent);
  font-size: 1.2rem;
}

/* ---------- タイマーバー ---------- */
.timer-bar {
  position: relative;
  height: var(--timer-h);
  flex: 0 0 auto;
  margin: 0 0.9rem 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  z-index: 15;
}

.timer-bar__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-primary-2), var(--color-primary));
  transition: width 0.2s linear, background 0.3s ease;
}

.timer-bar__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ---------- ゲームステージ ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.grid-wrap {
  display: grid;
  gap: 6px;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
}

.tile {
  position: relative;
  border-radius: 12px;
  border: none;
  background-image: url("assets/tile.png");
  background-size: 78%;
  background-repeat: no-repeat;
  background-position: center;
  background-color: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, opacity 0.25s ease;
}

.tile__num {
  position: relative;
  font-size: clamp(0.85rem, 4.4vw, 1.4rem);
  font-weight: 900;
  color: #241b4e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.tile.is-correct {
  animation: tilePop 0.35s ease forwards;
}

.tile.is-wrong {
  animation: tileShake 0.3s ease;
}

.tile.is-cleared {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.4);
}

@keyframes tilePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(0.4); opacity: 0; }
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- ラウンドトースト ---------- */
.round-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 12;
  font-size: 1rem;
  font-weight: 900;
  color: #241b4e;
  background: var(--color-accent);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--color-text-muted);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

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

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 30, 0.72);
  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.8rem 2rem;
  background: var(--color-panel);
  border: 3px solid var(--color-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;
}

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

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

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  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);
}

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

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

/* ---------- 広告スペース ---------- */
.ad-gap {
  flex: 0 0 var(--ad-gap-h);
  background: var(--color-bg-bottom);
}

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 2px dashed var(--color-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  z-index: 20;
  overflow: hidden;
}

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