* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
button, .select-btn, .nav-tab, .choice-btn, a {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
#answer-input, #nickname-input {
  user-select: text;
  -webkit-user-select: text;
}

:root {
  --bg: #0c1025;
  --bg-panel: #181c36;
  --bg-panel-hi: #22274a;
  --accent: #ffd23f;
  --accent-dark: #c68a0f;
  --accent-glow: rgba(255, 210, 63, 0.35);
  --accent-2: #5ddca8;
  --danger: #ff5d6c;
  --text: #f2f3f8;
  --text-dim: #8a90a8;
  --border: #2c3050;
  --border-gold: rgba(255, 210, 63, 0.22);
}

html, body {
  height: 100%;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(90, 70, 160, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(255, 210, 63, 0.05) 0%, transparent 45%),
    var(--bg);
  background-attachment: fixed;
  position: relative;
}

/* 星空テクスチャ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 15% 23%, rgba(255,255,255,0.45), transparent 50%),
    radial-gradient(1px   1px   at 42% 67%, rgba(255,210,63,0.4),  transparent 50%),
    radial-gradient(1px   1px   at 68% 18%, rgba(255,255,255,0.3), transparent 50%),
    radial-gradient(1.5px 1.5px at 83% 52%, rgba(255,255,255,0.35),transparent 50%),
    radial-gradient(1px   1px   at 27% 78%, rgba(255,210,63,0.3),  transparent 50%),
    radial-gradient(1px   1px   at 55% 38%, rgba(255,255,255,0.25),transparent 50%),
    radial-gradient(1.5px 1.5px at 92% 81%, rgba(255,255,255,0.4), transparent 50%),
    radial-gradient(1px   1px   at 8% 60%,  rgba(255,210,63,0.3),  transparent 50%),
    radial-gradient(1px   1px   at 74% 90%, rgba(255,255,255,0.2), transparent 50%);
  background-size: 700px 700px;
  background-repeat: repeat;
  opacity: 0.7;
}
#app { z-index: 1; }

#app {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px max(20px, env(safe-area-inset-left)) 24px max(20px, env(safe-area-inset-right));
  position: relative;
  flex: 1;
}

/* 共通ヘッダー */
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(14, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding:
    calc(10px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    10px max(20px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.app-logo { justify-self: start; text-decoration: none; }
.app-nav  { justify-self: center; }
.audio-toggles { justify-self: end; display: flex; gap: 6px; }
.app-logo {
  font-family: "Cinzel", "Shippori Mincho", serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  /* 横方向の虹色グラデに白いハイライト帯を埋め込み、position を動かしてキラッと流す */
  background: linear-gradient(
    100deg,
    var(--accent-dark) 0%,
    var(--accent) 18%,
    #fff2a0 38%,
    #ffffff 50%,
    #fff2a0 62%,
    var(--accent) 82%,
    var(--accent-dark) 100%
  );
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 6px var(--accent-glow));
  animation:
    logoShine 4.5s linear infinite,
    logoGlow 3s ease-in-out infinite alternate;
}
@keyframes logoShine {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}
@keyframes logoGlow {
  from { filter: drop-shadow(0 0 4px rgba(255, 210, 63, 0.3)); }
  to   { filter: drop-shadow(0 0 14px rgba(255, 210, 63, 0.7)); }
}
.app-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  font-weight: bold;
  letter-spacing: 1px;
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  transition: color 0.15s, background 0.15s, border-color 0.15s, text-shadow 0.15s, box-shadow 0.15s;
}
.nav-tab .nav-icon { margin-right: 4px; font-size: 0.95em; }
.nav-tab:hover {
  color: var(--text);
  background: rgba(255, 210, 63, 0.06);
  border-color: rgba(255, 210, 63, 0.18);
}
.nav-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.18) 0%, rgba(255, 210, 63, 0.04) 100%);
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.6);
  box-shadow: inset 0 -2px 0 var(--accent-dark), 0 0 14px rgba(255, 210, 63, 0.2);
}

/* 共通フッター */
.app-footer {
  padding:
    16px max(20px, env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  align-items: center;
}
.app-footer .link-btn {
  margin: 0;
  display: inline-block;
}

/* ヘッダー/フッター非表示（規約/プレイ画面） */
body.no-chrome .app-header,
body.no-chrome .app-footer {
  display: none;
}

/* 画面見出し（統一・RPG風装飾つき） */
.screen-heading {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  margin: 12px 0 6px;
  border: none;
  padding: 0;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 210, 63, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.screen-heading::before,
.screen-heading::after {
  content: "";
  flex: 0 0 auto;
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent));
  position: relative;
}
.screen-heading::after {
  background: linear-gradient(90deg, var(--accent), transparent);
}
.screen-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 28px;
  text-align: center;
  letter-spacing: 1px;
}
.section-heading {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--accent-2);
  border: none;
  padding: 0 0 6px;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(93, 220, 168, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::before {
  content: "❖";
  color: var(--accent-2);
  font-size: 14px;
}

/* オーディオトグル（ヘッダー/規約画面 共通） */
.audio-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 20px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.12s, border-color 0.12s, background 0.12s, opacity 0.12s;
}
.audio-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(255, 210, 63, 0.08);
}
.audio-btn.off {
  color: var(--text-dim);
  border-color: var(--border);
  opacity: 0.55;
}
/* オーディオオフ時: アイコンに斜線を重ねて視覚的に "切" を明示（SFX/BGM共通） */
.audio-btn.off .audio-icon {
  position: relative;
  display: inline-block;
}
.audio-btn.off .audio-icon::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 2px;
  background: #e06060;
  transform: translateY(-50%) rotate(-22deg);
  transform-origin: center;
  box-shadow: 0 0 3px rgba(224, 96, 96, 0.6);
  border-radius: 2px;
  pointer-events: none;
}

/* 規約画面の音声トグル */
.terms-audio-toggles {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.terms-audio-toggles .audio-btn {
  font-size: 15px;
  padding: 10px 18px;
}

/* モバイル: ヘッダーのグリッド調整 */
@media (max-width: 600px) {
  .app-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 10px 14px;
  }
  .app-logo       { grid-column: 1; grid-row: 1; }
  .audio-toggles  { grid-column: 2; grid-row: 1; }
  .app-nav        { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; width: 100%; }
  .nav-tab { flex: 1; padding: 8px 6px; font-size: 12px; text-align: center; }
}

/* ランキング画面のフィルタ */
.ranking-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  flex: 1;
  min-width: 160px;
}
.filter-label select {
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-panel);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.filter-label select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ランキング画面のランキングbox余白調整 */
#screen-ranking .ranking-box {
  max-width: none;
  margin: 0;
}

/* 問題数表示 */
.pool-count {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: 20px 0 8px;
  letter-spacing: 1px;
}
.pool-count strong {
  color: var(--accent);
  font-family: "Cinzel", serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 4px;
  text-shadow: 0 0 6px rgba(255, 210, 63, 0.3);
}

/* 自己ベスト表示 */
.personal-best {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.personal-best .pb-label {
  color: var(--accent-2);
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
}
#pb-text {
  color: var(--accent);
  font-family: "Cinzel", serif;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(255, 210, 63, 0.3);
  letter-spacing: 1px;
}
#pb-text.empty {
  color: var(--text-dim);
  font-size: 13px;
  text-shadow: none;
}

/* X（Twitter）シェアボタン */
#share-x-btn {
  background: linear-gradient(180deg, #26303a 0%, #0d0d0d 100%);
  border-color: #444;
  color: #fff;
}
#share-x-btn:hover {
  background: linear-gradient(180deg, #3a4452 0%, #1a1a1a 100%);
  border-color: #fff;
}


/* 画面切替 */
.screen { display: none; }
.screen.active { display: block; }
.screen.overlay.active {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* タイトル */
.logo {
  font-size: 56px;
  text-align: center;
  margin-top: 80px;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255, 210, 63, 0.4);
}
.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin: 12px 0 48px;
}
.hint-footer {
  text-align: center;
  color: var(--text-dim);
  margin-top: 32px;
  font-size: 12px;
}

/* 見出し */
h2 {
  font-size: 18px;
  margin: 28px 0 12px;
  color: var(--accent-2);
  border-left: 4px solid var(--accent-2);
  padding-left: 10px;
}

/* ボタン（ファンタジーRPG風） */
.primary-btn, .secondary-btn {
  display: inline-block;
  padding: 14px 28px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1.5px;
  transition: transform 0.08s, filter 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
/* 光の筋（hoverで横切る） */
.primary-btn::before, .secondary-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -70%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.22) 45%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0.22) 55%,
    transparent 100%
  );
  transform: skewX(-22deg);
  pointer-events: none;
  transition: left 0.6s cubic-bezier(0.2, 0.8, 0.3, 1);
  z-index: 1;
}
.primary-btn:hover::before, .secondary-btn:hover::before { left: 130%; }
.primary-btn:disabled, .secondary-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.3); }
.primary-btn:disabled::before, .secondary-btn:disabled::before { display: none; }

.primary-btn {
  background: linear-gradient(180deg, #fff0a0 0%, var(--accent) 45%, #d09518 100%);
  color: #1a1420;
  border: 1px solid var(--accent-dark);
  box-shadow:
    0 5px 0 #8a6409,
    0 8px 18px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 3px rgba(138, 100, 9, 0.3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.primary-btn:hover:not(:disabled) {
  filter: brightness(1.1) saturate(1.12);
  transform: translateY(-1px);
  box-shadow:
    0 6px 0 #8a6409,
    0 10px 26px rgba(255, 210, 63, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 3px rgba(138, 100, 9, 0.3);
}
.primary-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #8a6409,
    0 2px 6px rgba(0, 0, 0, 0.55),
    inset 0 2px 5px rgba(138, 100, 9, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.2);
  filter: brightness(0.96);
  transition: transform 0.04s, box-shadow 0.04s, filter 0.04s;
}

.secondary-btn {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow:
    0 4px 0 #0a0d1c,
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.secondary-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #282d56 0%, #1e2240 100%);
  border-color: var(--border-gold);
  transform: translateY(-1px);
  box-shadow:
    0 5px 0 #0a0d1c,
    0 8px 18px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.secondary-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #0a0d1c,
    inset 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.04s, box-shadow 0.04s;
}

#to-setup, #start-game {
  display: block;
  margin: 24px auto 0;
  min-width: 200px;
}

.button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 32px;
}

/* 難易度・方向選択 */
.grid-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.select-btn {
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1), border-color 0.12s, box-shadow 0.18s, background 0.15s;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
/* シャインスイープ（hoverで光の筋が横切る） */
.select-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 45%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 45%,
    rgba(255, 230, 130, 0.22) 50%,
    rgba(255, 255, 255, 0.12) 55%,
    transparent 100%
  );
  transform: skewX(-18deg);
  pointer-events: none;
  transition: left 0.55s ease;
  z-index: 1;
}
.select-btn:hover:not(:disabled)::before {
  left: 120%;
}
.select-btn:hover:not(:disabled) {
  border-color: var(--border-gold);
  transform: translateY(-2px) perspective(600px) rotateX(3deg);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.5),
    0 2px 0 rgba(255, 210, 63, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.select-btn:active:not(:disabled) {
  transform: translateY(1px) perspective(600px) rotateX(-1deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.06s, box-shadow 0.06s;
}
.select-btn.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.22) 0%, rgba(255, 210, 63, 0.05) 100%);
  box-shadow:
    0 0 18px rgba(255, 210, 63, 0.3),
    0 4px 14px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.select-btn.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: radial-gradient(ellipse at top, rgba(255, 210, 63, 0.15), transparent 60%);
  pointer-events: none;
  animation: selectedShine 2.4s ease-in-out infinite alternate;
}
@keyframes selectedShine {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}
.select-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.coming {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-dim);
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 14px;
  font-size: 14px;
  gap: 10px;
  background: linear-gradient(180deg, rgba(30, 34, 64, 0.7) 0%, rgba(20, 23, 46, 0.5) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.hud-left, .hud-center, .hud-right { min-width: 0; }
.hud-center { text-align: center; flex: 1; }
.lives {
  font-size: 22px;
  letter-spacing: 3px;
}
.life {
  display: inline-block;
  transition: color 0.3s, filter 0.3s, opacity 0.3s;
}
.life.alive {
  color: #ff6b9d;
  filter: drop-shadow(0 0 5px rgba(255, 107, 157, 0.65));
}
.life.lost {
  color: #ffffff;
  opacity: 0.45;
}
/* 喪失アニメ（損失瞬間のみ） */
.life.breaking {
  animation: lifeBreak 0.6s ease-out forwards;
}
@keyframes lifeBreak {
  0%   { color: #ff6b9d; filter: drop-shadow(0 0 5px rgba(255,107,157,0.7)); transform: scale(1); }
  20%  { color: #ffffff; filter: drop-shadow(0 0 14px rgba(255,255,255,0.95)); transform: scale(1.45); }
  45%  { color: #ff5d6c; filter: drop-shadow(0 0 10px rgba(255,93,108,0.9)); transform: scale(1.1) rotate(-14deg); }
  100% { color: #ffffff; filter: none; opacity: 0.4; transform: scale(0.85) rotate(0deg); }
}
/* 残機ピンチ（残1のとき）— HUDのハート群が脈動 */
.lives.critical {
  animation: livesCritical 0.75s ease-in-out infinite alternate;
}
@keyframes livesCritical {
  from { filter: drop-shadow(0 0 2px rgba(255, 93, 108, 0.3)); }
  to   { filter: drop-shadow(0 0 10px rgba(255, 93, 108, 0.95)); }
}

/* ハートの破片 */
.heart-shard {
  position: fixed;
  font-size: 14px;
  color: #ff5d6c;
  pointer-events: none;
  z-index: 99;
  text-shadow: 0 0 6px rgba(255, 93, 108, 0.8);
  animation: shardFly 0.75s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes shardFly {
  0%   { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% {
    transform:
      translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
      scale(0.4) rotate(var(--spin, 240deg));
    opacity: 0;
  }
}
.progress {
  color: var(--text-dim);
  font-family: "Cinzel", serif;
  letter-spacing: 2px;
  font-weight: 600;
}
.score {
  color: var(--accent);
  font-weight: bold;
  font-family: "Cinzel", serif;
  letter-spacing: 1px;
  font-size: 13px;
}
.score span {
  font-size: 18px;
  text-shadow: 0 0 6px rgba(255, 210, 63, 0.45);
}
.time-left {
  font-size: 18px;
  font-weight: bold;
  color: var(--accent-2);
  font-family: "Cinzel", serif;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(93, 220, 168, 0.4);
}
.time-left.danger {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(255, 93, 108, 0.6);
}
.combo { color: var(--accent); font-weight: bold; font-size: 16px; transition: transform 0.2s; }
.combo.flame-3 {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.9), 0 0 16px rgba(255, 150, 0, 0.5);
  animation: flamePulse 0.6s ease-in-out infinite alternate;
}
.combo.flame-5 {
  color: #ff8c1a;
  text-shadow: 0 0 10px rgba(255, 140, 26, 0.9), 0 0 22px rgba(255, 60, 0, 0.6);
  animation: flamePulse 0.45s ease-in-out infinite alternate;
  font-size: 18px;
}
.combo.flame-10 {
  color: #ff5d6c;
  text-shadow: 0 0 14px rgba(255, 93, 108, 1), 0 0 28px rgba(255, 0, 50, 0.7);
  animation: flamePulse 0.3s ease-in-out infinite alternate;
  font-size: 20px;
}
@keyframes flamePulse {
  from { transform: scale(1); }
  to   { transform: scale(1.14); }
}

/* モード別 HUD 出し分け */
#time-left, #combo { display: none; }
#screen-play.mode-timeattack #lives,
#screen-play.mode-timeattack #progress { display: none; }
#screen-play.mode-timeattack #time-left,
#screen-play.mode-timeattack #combo { display: inline; }

/* モード選択ボタンの補助テキスト */
.mode-desc {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 4px;
}
.select-btn.selected .mode-desc { color: var(--text); }

/* 正誤フラッシュ（タイムアタック用） */
.prompt.flash-ok { animation: flashOk 0.5s; }
.prompt.flash-ng { animation: flashNg 0.5s; }
@keyframes flashOk {
  0%   { color: var(--text); transform: scale(1); }
  40%  { color: var(--accent-2); transform: scale(1.08); }
  100% { color: var(--text); transform: scale(1); }
}
@keyframes flashNg {
  0%   { color: var(--text); transform: scale(1); }
  40%  { color: var(--danger); transform: scale(0.95); }
  100% { color: var(--text); transform: scale(1); }
}

/* タイマー */
.timer-bar {
  width: 100%;
  height: 10px;
  background: rgba(10, 12, 28, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
.timer-fill {
  height: 100%;
  width: 100%;
  /* 手前: 光の筋（シマー） / 奥: 本体グラデーション */
  background:
    linear-gradient(
      100deg,
      transparent 35%,
      rgba(255, 255, 255, 0.38) 48%,
      rgba(255, 255, 255, 0.55) 50%,
      rgba(255, 255, 255, 0.38) 52%,
      transparent 65%
    ),
    linear-gradient(90deg, var(--accent-2), var(--accent));
  background-size: 220% 100%, 100% 100%;
  background-repeat: no-repeat;
  background-position: 200% 0, 0 0;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(255, 210, 63, 0.4);
  animation: timerShimmer 2.4s linear infinite;
}
@keyframes timerShimmer {
  from { background-position: 220% 0, 0 0; }
  to   { background-position: -120% 0, 0 0; }
}
.timer-fill.danger {
  background:
    linear-gradient(
      100deg,
      transparent 35%,
      rgba(255, 255, 255, 0.4) 48%,
      rgba(255, 255, 255, 0.6) 50%,
      rgba(255, 255, 255, 0.4) 52%,
      transparent 65%
    ),
    linear-gradient(90deg, #ff8c1a, var(--danger));
  background-size: 220% 100%, 100% 100%;
  background-repeat: no-repeat;
  background-position: 200% 0, 0 0;
  animation:
    timerShimmer 1.6s linear infinite,
    dangerPulse 0.6s ease-in-out infinite alternate;
}
@keyframes dangerPulse {
  from { box-shadow: 0 0 4px rgba(255, 93, 108, 0.3); }
  to   { box-shadow: 0 0 18px rgba(255, 93, 108, 0.8); }
}

/* 出題エリアの入れ替えアニメ */
.question-area.slide-in {
  animation: questionSlideIn 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.question-area.slide-out {
  animation: questionSlideOut 0.22s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes questionSlideIn {
  0%   { transform: translateX(28px); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translateX(0);    opacity: 1; }
}
@keyframes questionSlideOut {
  0%   { transform: translateX(0);    opacity: 1; }
  100% { transform: translateX(-24px); opacity: 0; }
}
/* 選択肢も一緒にフェードイン */
.choices.slide-in {
  animation: questionSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* 出題エリア */
.question-area {
  background:
    radial-gradient(ellipse at top, rgba(255, 210, 63, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  padding: 36px 20px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 0 40px rgba(255, 210, 63, 0.03);
}
/* 四隅の装飾 */
.question-area::before,
.question-area::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  opacity: 0.7;
}
.question-area::before {
  top: -1px; left: -1px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 14px;
}
.question-area::after {
  bottom: -1px; right: -1px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 14px;
}

/* パーティクル（キラキラ） */
.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #fff 0%, var(--accent) 55%, transparent 75%);
  border-radius: 50%;
  pointer-events: none;
  animation: sparkleMove 0.75s ease-out forwards;
  z-index: 3;
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
}
@keyframes sparkleMove {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  70%  { opacity: 0.8; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* 画面シェイク（不正解時） — .screen:not(.overlay).active より優先されるよう ID で特異度を上げる */
#screen-play.shake {
  animation: screenShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* コンボ大ポップアップ（3/5/10達成時） */
.combo-popup {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  font-family: "Cinzel", serif;
  font-size: 56px;
  font-weight: bold;
  color: var(--accent);
  text-shadow:
    0 0 20px rgba(255, 210, 63, 0.95),
    0 0 40px rgba(255, 140, 26, 0.6),
    0 4px 14px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
  z-index: 100;
  letter-spacing: 3px;
  text-align: center;
  white-space: nowrap;
}
.combo-popup.show { animation: comboPopup 0.95s cubic-bezier(0.25, 1.2, 0.5, 1) forwards; }
.combo-popup.tier-5 {
  color: #ff8c1a;
  text-shadow: 0 0 22px rgba(255,140,26,1), 0 0 44px rgba(255,60,0,0.75), 0 4px 14px rgba(0,0,0,0.7);
  font-size: 62px;
}
.combo-popup.tier-10 {
  color: #ff5d6c;
  text-shadow: 0 0 26px rgba(255,93,108,1), 0 0 52px rgba(255,0,50,0.85), 0 4px 14px rgba(0,0,0,0.75);
  font-size: 72px;
}
@keyframes comboPopup {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.25) rotate(4deg);  opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1.0) rotate(0deg);   opacity: 1; }
  80%  { transform: translate(-50%, -50%) scale(1.0) rotate(0deg);   opacity: 1; }
  100% { transform: translate(-50%, -95%) scale(0.85) rotate(0deg);  opacity: 0; }
}
@media (max-width: 600px) {
  .combo-popup { font-size: 40px; letter-spacing: 2px; }
  .combo-popup.tier-5 { font-size: 46px; }
  .combo-popup.tier-10 { font-size: 54px; }
}

/* 正解時の大型バースト（星・剣） */
.burst-particle {
  position: fixed;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 99;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.85)) drop-shadow(0 0 12px rgba(255, 140, 0, 0.5));
  animation: burstFly 0.85s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}
@keyframes burstFly {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 0; }
  12%  { transform: translate(-50%, -50%) scale(1.1) rotate(var(--spin-mid, 60deg)); opacity: 1; }
  100% {
    transform:
      translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
      scale(0.55) rotate(var(--spin, 180deg));
    opacity: 0;
  }
}

/* 画面フェード遷移 */
.screen:not(.overlay).active {
  animation: screenFade 0.22s ease-out;
}
@keyframes screenFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* フッター */
.footer-sep { color: var(--text-dim); margin: 0 6px; font-size: 10px; }

/* 速答スコアポップアップ */
.score-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  font-weight: bold;
  color: var(--accent);
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
.score-popup.show {
  animation: scorePopup 0.8s ease-out;
}
@keyframes scorePopup {
  0%   { transform: translate(-50%, 10%);  opacity: 0; }
  20%  { transform: translate(-50%, -50%); opacity: 1; }
  100% { transform: translate(-50%, -130%); opacity: 0; }
}
.score-popup .speed-bonus {
  display: block;
  font-size: 16px;
  color: var(--accent-2);
  font-weight: bold;
  margin-top: 4px;
}
.prompt-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.prompt {
  font-size: 44px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: 1.6;
}
.prompt.phrase {
  font-size: 34px;
  letter-spacing: 1px;
}
.prompt ruby rt {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: normal;
  letter-spacing: 0;
}
.feedback-example-ja ruby rt,
.hint-display ruby rt {
  font-size: 10px;
  color: var(--text-dim);
}

/* 回答フォーム */
.answer-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

/* 4択 */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.choice-btn {
  padding: 18px 14px;
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.08s, box-shadow 0.15s;
  text-align: center;
  line-height: 1.6;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.choice-btn:hover:not(:disabled):not(.eliminated) {
  border-color: var(--accent);
  background: linear-gradient(180deg, #2b305a 0%, var(--bg-panel-hi) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 210, 63, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.choice-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.choice-btn.eliminated {
  opacity: 0.3;
  text-decoration: line-through;
  cursor: not-allowed;
}
.choice-btn.correct {
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(93, 220, 168, 0.35), rgba(30, 34, 64, 0.85));
  box-shadow: 0 0 28px rgba(93, 220, 168, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: choicePulseCorrect 0.75s ease-out;
  position: relative;
  z-index: 1;
}
@keyframes choicePulseCorrect {
  0%   { transform: scale(1);    box-shadow: 0 0 0 rgba(93,220,168,0); }
  30%  { transform: scale(1.06); box-shadow: 0 0 42px rgba(93,220,168,0.95), 0 0 72px rgba(93,220,168,0.45); }
  100% { transform: scale(1);    box-shadow: 0 0 28px rgba(93,220,168,0.55); }
}
.choice-btn.wrong {
  border-color: var(--danger);
  background: linear-gradient(180deg, rgba(255, 93, 108, 0.28), rgba(30, 34, 64, 0.85));
  box-shadow: 0 0 22px rgba(255, 93, 108, 0.5);
  animation: choiceShake 0.5s cubic-bezier(.36,.07,.19,.97);
}
@keyframes choiceShake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-7px); }
  30%      { transform: translateX(6px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(3px); }
  80%      { transform: translateX(-1px); }
}
/* 選ばなかった選択肢は薄くして正解/誤答にフォーカス */
.choice-btn:disabled:not(.correct):not(.wrong) {
  opacity: 0.42;
  filter: grayscale(0.55);
}
.choice-btn ruby rt {
  font-size: 11px;
  color: var(--text-dim);
}
@media (max-width: 480px) {
  .choices { grid-template-columns: 1fr; }
}
#answer-input {
  flex: 1;
  padding: 14px 16px;
  font-size: 18px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
}
#answer-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ヒント */
.hints {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.hint-btn {
  padding: 8px 14px;
  background: transparent;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s, opacity 0.3s, filter 0.3s;
}
.hint-btn:hover:not(.used) {
  color: var(--text);
  border-color: var(--accent-2);
  background: rgba(93, 220, 168, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(93, 220, 168, 0.2);
}
.hint-btn:active:not(.used) {
  transform: translateY(1px);
  box-shadow: none;
  background: rgba(93, 220, 168, 0.12);
}
.hint-btn.used {
  opacity: 0.48;
  cursor: default;
  border-style: solid;
  border-color: var(--text-dim);
  color: var(--text-dim);
  filter: grayscale(0.5);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.4);
  padding-left: 22px;
  animation: hintMarkUsed 0.4s ease-out;
}
.hint-btn.used::before {
  content: "✓";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 0 4px rgba(93, 220, 168, 0.6);
  animation: hintCheckPop 0.4s cubic-bezier(0.25, 1.3, 0.5, 1) both;
}
@keyframes hintMarkUsed {
  0%   { transform: scale(1.05); filter: grayscale(0) brightness(1.2); }
  100% { transform: scale(1);    filter: grayscale(0.5) brightness(1); }
}
@keyframes hintCheckPop {
  0%   { transform: translateY(-50%) scale(0) rotate(-40deg); opacity: 0; }
  60%  { transform: translateY(-50%) scale(1.35) rotate(8deg); opacity: 1; }
  100% { transform: translateY(-50%) scale(1) rotate(0deg); opacity: 1; }
}

.hint-display {
  min-height: 32px;
  padding: 8px 12px;
  text-align: center;
  color: var(--accent-2);
  font-size: 14px;
}
.hint-display .hint-line {
  margin: 3px 0;
  animation: hintFadeIn 0.25s ease-out;
}
@keyframes hintFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 利用規約 */
.terms-title {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  border: none;
  padding: 0;
  margin: 20px 0 6px;
  text-align: center;
  letter-spacing: 3px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 18px rgba(255, 210, 63, 0.2);
}
.terms-subtitle {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 16px;
}
.terms-body {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 18px 20px;
  line-height: 2;
  font-size: 13px;
  max-height: 55vh;
  overflow-y: auto;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}
.terms-body p { margin-bottom: 10px; }
.terms-body ul { padding-left: 20px; margin-bottom: 10px; }
.terms-body li { margin-bottom: 10px; }
.terms-body strong { color: var(--accent); }
.terms-body ruby rt,
.terms-msg ruby rt {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: normal;
}
.terms-msg {
  text-align: center;
  color: var(--danger);
  font-size: 13px;
  margin-top: 16px;
  min-height: 20px;
  opacity: 0;
  transition: opacity 0.2s;
}
.terms-msg.show { opacity: 1; }

.link-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-2); }

/* ルール説明 */
.rules-card {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 12px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.rule-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.rule-row:last-child { border-bottom: none; }
.rule-label {
  color: var(--accent-2);
  font-weight: bold;
  font-size: 14px;
}
.rule-body { font-size: 14px; line-height: 1.7; }
.rule-body ul { padding-left: 18px; }
.rule-body li { margin-bottom: 4px; }
.rule-body strong { color: var(--text); }
.rule-body .accent { color: var(--accent); }
.rule-body .danger { color: var(--danger); }

@media (max-width: 480px) {
  .rule-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ギブアップ */
.play-footer {
  margin-top: 24px;
  text-align: center;
}
.give-up-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 12px;
  cursor: pointer;
}
.give-up-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* 確認モーダル */
.modal-card {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  padding: 30px 26px;
  width: min(90%, 420px);
  text-align: center;
  animation: modalPop 0.15s ease-out;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 12px;
  color: var(--text);
}
.modal-message {
  color: var(--text-dim);
  margin-bottom: 24px;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.danger-btn {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 0 #a63444;
}
.danger-btn:active {
  box-shadow: 0 2px 0 #a63444;
}

/* フィードバック */
.feedback-card {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  padding: 30px 26px;
  width: min(90%, 460px);
  text-align: center;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.feedback-result {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.feedback-result.ok { color: var(--accent-2); }
.feedback-result.ng { color: var(--danger); }

.feedback-answer {
  font-size: 20px;
  margin-bottom: 16px;
}
.feedback-answer #feedback-answer-en { color: var(--accent); font-weight: bold; }
.feedback-answer #feedback-answer-ja { color: var(--text); font-weight: bold; }
.feedback-answer #feedback-answer-ja ruby rt { font-size: 11px; color: var(--text-dim); font-weight: normal; }
.feedback-eq {
  color: var(--text-dim);
  margin: 0 8px;
  font-weight: normal;
}

.speak-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 6px;
  font-size: 16px;
}
.speak-btn:hover { background: var(--border); }

.feedback-full-form {
  font-family: "Cinzel", Georgia, serif;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin: -8px 0 16px;
  padding: 8px 12px;
  background: rgba(255, 210, 63, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  text-align: left;
}
.feedback-full-form::before {
  content: "= ";
  color: var(--text-dim);
  margin-right: 4px;
}

.feedback-example {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  text-align: left;
}
.feedback-example-en { color: var(--text); margin-bottom: 6px; }
.feedback-example-ja { color: var(--text-dim); font-size: 13px; }

/* 終了画面 */
#over-title {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 44px;
  font-weight: 800;
  text-align: center;
  margin: 32px 0 20px;
  color: var(--accent);
  border: none;
  padding: 0;
  letter-spacing: 4px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6), 0 0 30px rgba(255, 210, 63, 0.3);
}
.result-stats {
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  line-height: 1.8;
  font-size: 16px;
  max-width: 420px;
  margin: 0 auto 16px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.result-stats .big-score {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  letter-spacing: 2px;
}
.result-stats .big-score span {
  display: block;
  font-family: "Cinzel", serif;
  font-size: 52px;
  color: var(--accent);
  font-weight: 700;
  margin-top: 6px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 24px rgba(255, 210, 63, 0.3);
  letter-spacing: 2px;
}
.result-stats span { color: var(--accent); font-weight: bold; }
.stat-line { color: var(--text); position: relative; transition: color 0.3s; }

/* PB（マイベスト）更新時のハイライト */
.stat-line.pb-highlight {
  color: var(--accent);
  animation: pbGlow 1.1s ease-in-out infinite alternate;
}
.stat-line.pb-highlight::after {
  content: "✨ NEW!";
  display: inline-block;
  margin-left: 10px;
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: #ff8c1a;
  text-shadow: 0 0 8px rgba(255, 140, 26, 0.9);
  animation: pbBadgePop 0.7s cubic-bezier(0.25, 1.3, 0.5, 1) both;
  letter-spacing: 1px;
  vertical-align: middle;
}
@keyframes pbGlow {
  from { text-shadow: 0 0 0 rgba(255,210,63,0); }
  to   { text-shadow: 0 0 10px rgba(255,210,63,0.7), 0 0 20px rgba(255,140,26,0.45); }
}
@keyframes pbBadgePop {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.3) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* 紙吹雪 */
.confetti {
  position: fixed;
  top: -24px;
  width: 10px;
  height: 14px;
  pointer-events: none;
  z-index: 98;
  border-radius: 2px;
  opacity: 0.95;
  animation: confettiFall linear forwards;
  will-change: transform, opacity;
}
@keyframes confettiFall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% {
    transform: translate(var(--drift, 0px), 110vh) rotate(var(--spin-end, 720deg));
    opacity: 0.3;
  }
}

/* モード別表示の出し分け */
#screen-over .mode-only-ta { display: none; }
#screen-over .mode-only-normal { display: none; }
#screen-over.mode-timeattack .mode-only-ta { display: block; }
#screen-over.mode-normal .mode-only-normal { display: block; }
#screen-over.mode-timeattack .stat-line.mode-only-ta { display: block; }

/* ニックネーム入力 */
.nickname-box {
  max-width: 420px;
  margin: 0 auto 16px;
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.nickname-label {
  text-align: center;
  color: var(--accent-2);
  font-weight: bold;
  margin-bottom: 12px;
  font-size: 14px;
}
.nickname-row {
  display: flex;
  gap: 8px;
}
#nickname-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #0e1220;
  color: var(--text);
}
#nickname-input:focus {
  outline: none;
  border-color: var(--accent);
}
#nickname-input:disabled {
  opacity: 0.6;
}
#submit-score-btn {
  padding: 10px 20px;
  font-size: 14px;
}
.submit-status {
  text-align: center;
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}
.submit-status.ok { color: var(--accent-2); }
.submit-status.ng { color: var(--danger); }

/* ニックネーム入力の注意書き */
.nickname-notes {
  list-style: none;
  padding: 10px 12px 0;
  margin: 10px 0 0;
  border-top: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
}
.nickname-notes li {
  position: relative;
  padding-left: 14px;
  margin: 2px 0;
}
.nickname-notes li::before {
  content: "⚠";
  position: absolute;
  left: 0;
  top: 0;
  font-size: 10px;
  color: var(--danger);
  opacity: 0.85;
}
.nickname-notes li b {
  color: var(--danger);
  font-weight: 600;
}

/* ランキング */
.ranking-box {
  max-width: 520px;
  margin: 0 auto 16px;
  background: linear-gradient(180deg, var(--bg-panel-hi) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.ranking-header {
  text-align: center;
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 14px;
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ranking-header::before,
.ranking-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent));
  max-width: 60px;
}
.ranking-header::after { background: linear-gradient(90deg, var(--accent), transparent); }
.ranking-loading {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 16px;
}
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ranking-table th, .ranking-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.ranking-table th {
  color: var(--text-dim);
  font-weight: normal;
  font-size: 11px;
}
.ranking-table td:first-child { width: 50px; color: var(--text-dim); font-family: "Cinzel", serif; font-weight: 600; }
.ranking-table td:nth-child(3) { color: var(--accent); font-weight: bold; text-align: right; width: 80px; font-family: "Cinzel", serif; }
.ranking-table td:last-child { width: 70px; text-align: right; color: var(--text-dim); font-size: 11px; }
/* TOP 3 装飾 */
.ranking-table tbody tr:nth-child(1) td {
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.18) 0%, transparent 80%);
}
.ranking-table tbody tr:nth-child(1) td:first-child {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
}
.ranking-table tbody tr:nth-child(1) td:first-child::before { content: "👑 "; }
.ranking-table tbody tr:nth-child(2) td {
  background: linear-gradient(90deg, rgba(200, 200, 210, 0.1) 0%, transparent 80%);
}
.ranking-table tbody tr:nth-child(2) td:first-child { color: #d8d8e0; }
.ranking-table tbody tr:nth-child(2) td:first-child::before { content: "🥈 "; }
.ranking-table tbody tr:nth-child(3) td {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.15) 0%, transparent 80%);
}
.ranking-table tbody tr:nth-child(3) td:first-child { color: #d9884b; }
.ranking-table tbody tr:nth-child(3) td:first-child::before { content: "🥉 "; }
/* 自分のスコア（上の背景より優先） */
.ranking-table tr.me td { background: rgba(255, 210, 63, 0.2) !important; }
.ranking-table tr.me td:first-child { color: var(--accent); font-weight: bold; }
.ranking-table tr.empty td { text-align: center; color: var(--text-dim); padding: 16px; }

/* ===== デイリーランキング ルール / カウントダウン ===== */
.ranking-rules {
  margin-top: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255, 210, 63, 0.06), rgba(124, 77, 255, 0.06));
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}
.ranking-rules .rules-title {
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ranking-rules .rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ranking-rules .rules-list li {
  position: relative;
  padding-left: 14px;
  margin: 2px 0;
}
.ranking-rules .rules-list li::before {
  content: "◆";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-size: 9px;
  opacity: 0.7;
}
.ranking-rules .rules-list li b {
  color: var(--text);
  font-weight: 600;
}
.reset-countdown {
  display: inline-block;
  min-width: 72px;
  padding: 1px 6px;
  margin-left: 2px;
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.3);
  border-radius: 4px;
  color: var(--accent);
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
}

/* ===== モバイル対応 ===== */

/* タブレット〜中サイズ (<=600px) */
@media (max-width: 600px) {
  #app { padding-top: 18px; padding-bottom: 18px; }
  .screen-heading { font-size: 24px; gap: 10px; }
  .screen-heading::before, .screen-heading::after { width: 30px; }
  .section-heading { font-size: 16px; margin: 22px 0 10px; }
  .prompt { font-size: 36px; }
  .prompt.phrase { font-size: 28px; }
  #over-title { font-size: 38px; letter-spacing: 3px; }
  .result-stats .big-score span { font-size: 46px; }
  .feedback-result { font-size: 34px; }
  .terms-title { font-size: 22px; letter-spacing: 2px; }
  .terms-body { font-size: 12px; padding: 14px 16px; }
  .grid-buttons { grid-template-columns: 1fr; }
  .primary-btn, .secondary-btn { padding: 13px 22px; font-size: 15px; }
  .button-row { flex-wrap: wrap; }
  .button-row .primary-btn, .button-row .secondary-btn { flex: 1; min-width: 140px; }
}

/* スマートフォン (<=480px) */
@media (max-width: 480px) {
  .app-logo { font-size: 18px; letter-spacing: 2px; }
  .nav-tab { padding: 9px 10px; font-size: 13px; letter-spacing: 0.5px; }
  .nav-tab .nav-icon { margin-right: 2px; font-size: 0.9em; }
  .audio-btn { font-size: 17px; padding: 7px 10px; }

  .screen-heading { font-size: 22px; letter-spacing: 1px; }
  .screen-heading::before, .screen-heading::after { width: 24px; }
  .screen-sub { font-size: 12px; margin-bottom: 20px; }

  .prompt { font-size: 32px; letter-spacing: 1px; }
  .prompt.phrase { font-size: 24px; }
  .question-area { padding: 26px 14px; }

  .hud { padding: 8px 10px; font-size: 12px; gap: 6px; }
  .hud-center { font-size: 12px; }
  .lives { font-size: 18px; letter-spacing: 2px; }
  .score { font-size: 11px; }
  .score span { font-size: 16px; }
  .time-left { font-size: 15px; }
  .combo { font-size: 14px; }

  #answer-input { font-size: 16px; padding: 12px 14px; }
  .answer-form .primary-btn { padding: 12px 18px; font-size: 14px; }

  .choice-btn { font-size: 17px; padding: 16px 10px; line-height: 1.5; }
  .choice-btn ruby rt { font-size: 9px; }

  .hint-btn { font-size: 12px; padding: 7px 12px; }
  .hint-display { font-size: 12px; min-height: 28px; }

  .feedback-result { font-size: 30px; }
  .feedback-card, .modal-card { padding: 24px 18px; }
  .feedback-answer { font-size: 17px; }
  .feedback-example { padding: 10px; font-size: 13px; }

  #over-title { font-size: 34px; letter-spacing: 2px; margin: 24px 0 16px; }
  .result-stats { padding: 18px; font-size: 15px; }
  .result-stats .big-score span { font-size: 42px; }

  .nickname-label { font-size: 13px; }
  #nickname-input { font-size: 16px; padding: 9px 10px; }
  #submit-score-btn { padding: 9px 16px; font-size: 13px; }

  .ranking-filters { flex-direction: column; gap: 8px; }
  .filter-label { min-width: 0; }
  .ranking-header { font-size: 15px; }
  .ranking-table { font-size: 12px; }
  .ranking-table th, .ranking-table td { padding: 6px 4px; }
  /* MAX COMBO 列を省略して見やすく */
  .ranking-table th:nth-child(4),
  .ranking-table td:nth-child(4) { display: none; }
  .ranking-rules { font-size: 11px; padding: 10px 12px; }
  .reset-countdown { font-size: 10px; min-width: 64px; }

  .rules-card { padding: 16px; }
  .rule-row { padding: 10px 0; }
  .rule-label { font-size: 13px; }
  .rule-body { font-size: 13px; }

  .terms-audio-toggles .audio-btn { font-size: 14px; padding: 9px 14px; }

  .nav-tab, .select-btn, .choice-btn, .primary-btn, .secondary-btn, .audio-btn, .hint-btn { min-height: 40px; }
}

/* 小型スマホ (<=360px) */
@media (max-width: 360px) {
  .app-logo { font-size: 16px; }
  .nav-tab { padding: 8px 6px; font-size: 12px; }
  .nav-tab .nav-icon { display: none; }
  .prompt { font-size: 28px; }
  .prompt.phrase { font-size: 22px; }
  .screen-heading { font-size: 20px; }
  #over-title { font-size: 30px; }
  .choice-btn { font-size: 16px; padding: 14px 8px; }
}
