/* 逆再生チャレンジ スタイル（白ベースのテーマ） */

:root {
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-sub: #f6f7fb;
  --bg-soft: #eef0f6;
  --text: #16161d;
  --text-sub: #6b7280;
  --accent: #ff4d6d;
  --accent-2: #ffb347;
  --success: #16a34a;
  --danger: #ef4444;
  --border: #e6e8ef;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-pop: 0 8px 24px rgba(255, 77, 109, 0.20);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* タイトル画面 */
.title-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 77, 109, 0.10), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(255, 179, 71, 0.10), transparent 60%);
}
.title-logo {
  color: var(--accent);
  filter: drop-shadow(0 6px 18px rgba(255, 77, 109, 0.25));
}
.game-title {
  font-size: 56px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 900;
  color: var(--text);
}
.game-subtitle {
  color: var(--text-sub);
  font-size: 18px;
  margin-bottom: 8px;
}

/* 共通ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 28px;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.2s, box-shadow 0.2s;
  font-family: inherit;
  color: inherit;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  min-width: 200px;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover { background: #ef3c5d; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg-sub); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 8px;
}
.btn-icon:hover { background: var(--bg-sub); }

/* ヘッダー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h2 { font-size: 16px; font-weight: 700; color: var(--text); }
.app-header > span { width: 40px; }

/* ステージ選択グリッド */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 20px 16px;
  max-width: 720px;
  margin: 0 auto;
}
.stage-card {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.stage-card:hover { box-shadow: var(--shadow-md); }
.stage-card:active { transform: scale(0.96); }
.stage-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-sub);
  box-shadow: none;
}
.stage-card.cleared {
  border-color: var(--success);
  background: linear-gradient(180deg, #ffffff, #f0fdf4);
}
.stage-card .stage-num {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
}
.stage-card .stage-word {
  font-size: 14px;
  color: var(--text-sub);
  word-break: break-all;
  text-align: center;
}
.stage-card .stage-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--success);
}
.stage-card.locked .stage-word { color: transparent; }

/* ゲーム画面 */
.game-body {
  padding: 24px 16px 40px;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.word-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.word-label, .word-hint {
  color: var(--text-sub);
  font-size: 14px;
}
.word-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  display: block;
  margin: 12px auto 0;
  border-radius: 16px;
  background: var(--bg-sub);
}
.word-image[hidden] { display: none; }
.word-text {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 0.05em;
  margin: 16px 0;
  color: var(--text);
  word-break: break-all;
}

.btn-sample, .btn-hint {
  width: 100%;
  justify-content: flex-start;
  padding: 14px 20px;
}
.sample-counter {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}

/* ヒント表示エリア */
.hint-display {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}
.hint-display[hidden] { display: none; }
.hint-label {
  color: var(--text-sub);
  font-size: 13px;
}
.hint-text {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent);
  margin-top: 6px;
  letter-spacing: 0.05em;
  word-break: break-all;
}

/* 録音エリア */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
.btn-record {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 8px 24px rgba(255, 77, 109, 0.35);
}
.btn-record:active { transform: scale(0.95); }
.btn-record.recording {
  background: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 8px 32px rgba(239, 68, 68, 0.55), 0 0 0 16px rgba(239, 68, 68, 0.12); }
}
.record-status {
  color: var(--text-sub);
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

/* 採点中インジケータ（不定進捗バー） */
.loader-bar {
  width: 70%;
  max-width: 280px;
  height: 6px;
  background: var(--bg-sub);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  margin-top: 4px;
}
.loader-bar[hidden] { display: none; }
.loader-bar span {
  position: absolute;
  top: 0;
  left: -35%;
  width: 35%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loader-slide 1.2s ease-in-out infinite;
}
@keyframes loader-slide {
  0%   { left: -35%; }
  100% { left: 100%; }
}

/* 結果表示 */
.result-area {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.score-display { text-align: center; }
.score-label {
  color: var(--text-sub);
  font-size: 14px;
}
.score-value {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
}
.score-judge {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}
.score-judge.pass { color: var(--success); }
.score-judge.fail { color: var(--text-sub); }
.transcript {
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
  background: var(--bg-sub);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  word-break: break-all;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.result-actions .btn { width: 100%; }

/* Whisperモデル読み込みバナー */
.whisper-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-sub);
  box-shadow: var(--shadow-sm);
}
.whisper-banner[hidden] { display: none; }
.spinner {
  color: var(--accent);
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 29, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.modal-content h3 { font-size: 18px; color: var(--text); }
.ad-timer {
  font-size: 64px;
  font-weight: 900;
  color: var(--accent-2);
  line-height: 1;
}
.ad-hint {
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.5;
}
.modal-content .btn { width: 100%; min-width: 0; }
