/* ===================================
   pen pen English — Quiz Screen
   Kirby Air Rider style
   =================================== */

/* ---- QUIZ SCREEN ---- */
/* HUD is now integrated directly into the question card image wrap */

.quiz-image-wrap {
  width: 100%;
  position: relative;
  z-index: 10;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  border-bottom: 2px solid #8B5A2B;
}

/* Progress bar — flush at the very top of the card */
.quiz-progress-bar-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #F06A6A, #FFD700);
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

/* Badge row — flex row centered horizontally, badge straddling image top */
.quiz-badge-row {
  position: absolute;
  top: 16px;
  left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 14px 0 0;
  box-sizing: border-box;
  z-index: 90;
  pointer-events: none;
}

.question-level-badge-inline {
  font-family: var(--font-game); font-size: 11px; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: white; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 3px 12px; border-radius: 4px;
  backdrop-filter: blur(4px);
}

.quiz-counter-inline {
  font-family: var(--font-game); font-size: 14px; font-weight: 900;
  color: white; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 5px 12px; border-radius: 16px;
  letter-spacing: 0.1em;
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px black;
}

/* Keep old classes for backward compat (spell mode etc.) */
.question-level-badge {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 10;
  font-family: var(--font-game); font-size: 11px; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: white; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 3px 12px; border-radius: 4px;
  backdrop-filter: blur(4px);
}

.quiz-counter {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  font-family: var(--font-game); font-size: 14px; font-weight: 900;
  color: white; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 5px 12px; border-radius: 16px;
  letter-spacing: 0.1em;
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px black;
}

.quiz-progress-bar-integrated {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  width: 100%; height: 6px;
  background: rgba(0,0,0,0.5);
  z-index: 30;
}

/* ====================================================
   QUESTION + CHOICES — unified Air Rider card layout
   ==================================================== */

/* All quiz cards share same radius */
.question-card,
.choice-btn {
  border-radius: 16px;
}

/* ---- Question card ---- */
.question-card {
  width: 100%; max-width: 720px;
  padding: 0;
  display: flex; flex-direction: column;
  align-items: center; gap: 0px;
  margin-bottom: 20px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Remove manual corner curls since .parchment-inner-border handles it */

/* ---- Antique Book Style Quiz Image ---- */
.quiz-image-wrap {
  /* インナーカード: ベースカードに対して上・左・右15pxのマージン */
  width: calc(100% - 50px);
  margin: 10px auto 0; /* autoで左右均等センタリング、上10px (5px上詰め) */
  padding: 0; /* 画像が左右にピッタリくっつく */
  background: #fdf5e6;
  border: 4px double #8b5a2b;
  border-radius: 8px;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.15), inset 0 0 5px rgba(139, 90, 43, 0.3);
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

/* Corner ornaments */
.quiz-image-wrap::before, .quiz-image-wrap::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid #8b5a2b;
}
.quiz-image-wrap::before {
  top: 4px; left: 4px;
  border-right: none; border-bottom: none;
}
.quiz-image-wrap::after {
  bottom: 4px; right: 4px;
  border-left: none; border-top: none;
}

.quiz-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0; /* インナーカードのborder-radiusに従う */
  box-shadow: none;
  object-fit: contain; /* 改変: coverからcontainへ (絵柄を全部見せるため) */
  aspect-ratio: auto;
  z-index: 2;
}

.question-emoji {
  font-size: 90px; line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.2));
  margin-top: 24px;
  margin-bottom: 0px;
}

.question-prompt-label {
  font-family: var(--font-game); font-size: 11px; font-weight: 700;
  color: #8C6A46; letter-spacing: 0.1em;
  text-transform: uppercase;
}

.question-word {
  text-align: center; line-height: 1.1; font-weight: 900;
}
.question-word.en-word {
  font-family: var(--font-game); font-size: 52px;
  color: #3b2a1a; text-shadow: none;
  letter-spacing: -0.02em;
}
.question-word.ja-word {
  font-family: var(--font-ja); font-size: 36px;
  color: #3b2a1a; text-shadow: none;
}

/* ---- Choices grid ---- */
.choices-grid {
  width: 100%; max-width: 720px;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;       /* ← gap between buttons */
  margin-top: 12px;
  flex-shrink: 0;
}

.choice-btn {
  /* Match .parchment-card styling exactly */
  background: linear-gradient(135deg, #FFFAF0 0%, #F5E8D8 100%);
  border: 4px solid #9D754B;
  border-radius: 12px;
  padding: 18px 14px; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  position: relative; overflow: hidden;
  min-height: 84px;
  box-shadow: inset 0 0 0 2px #FFF, inset 0 0 20px rgba(139, 69, 19, 0.06), 0 4px 8px rgba(0,0,0,0.3);
  z-index: 1;
}

.choice-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 2px #FFF, 0 1px 3px rgba(0,0,0,0.3);
}

/* Number badge — parchment variant */
.choice-number {
  position: absolute; top: 8px; left: 10px;
  width: 24px; height: 24px; border-radius: 50%;
  font-family: var(--font-game); font-size: 12px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid;
}
.choice-btn:nth-child(1) .choice-number { background: rgba(200,50,50,0.1);   color: #C83232; border-color: rgba(200,50,50,0.4); }
.choice-btn:nth-child(2) .choice-number { background: rgba(50,120,200,0.1);  color: #3278C8; border-color: rgba(50,120,200,0.4); }
.choice-btn:nth-child(3) .choice-number { background: rgba(50,160,50,0.1);   color: #32A032; border-color: rgba(50,160,50,0.4); }
.choice-btn:nth-child(4) .choice-number { background: rgba(200,150,0,0.1);   color: #C89600; border-color: rgba(200,150,0,0.4); }

.choice-text {
  font-size: 17px; font-weight: 700;
  color: #3b2a1a; text-align: center; line-height: 1.3;
}
.choice-text.en-text { font-family: var(--font-game); font-size: 20px; }
.choice-text.ja-text { font-family: var(--font-ja); font-size: 16px; }

/* ---- Answer states ---- */
.choice-btn.correct {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  border-color: #2E7D32; border-width: 3px;
  box-shadow: 0 4px 6px rgba(46,125,50,0.3), inset 0 0 20px rgba(76,175,80,0.2);
  animation: bounceIn 0.35s ease;
}
.choice-btn.correct .choice-text { color: #1B5E20; }
.choice-btn.correct::before {
  content: '✓';
  position: absolute; top: 8px; right: 10px;
  font-size: 16px; color: #2E7D32; font-weight: 900;
}

.choice-btn.wrong {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
  border-color: #C62828; border-width: 3px;
  box-shadow: 0 4px 6px rgba(198,40,40,0.3), inset 0 0 20px rgba(244,67,54,0.2);
  animation: shake 0.45s ease;
}
.choice-btn.wrong .choice-text { color: #B71C1C; }
.choice-btn.wrong::before {
  content: '✗';
  position: absolute; top: 8px; right: 10px;
  font-size: 16px; color: #C62828; font-weight: 900;
}

.choice-btn.disabled { pointer-events: none; opacity: 0.65; }

/* ---- Feedback Overlay (Modal) ---- */
.feedback-banner {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80%; max-width: 400px;
  border-radius: 24px;
  padding: 40px 30px; 
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ja); font-weight: 900; font-size: 28px;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  border-width: 4px; border-style: solid;
}
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ====================================================
   TEST MODE (Intense Cyber Exam Styling) 
   ==================================================== */
.test-mode {
  background: radial-gradient(circle at top, #2C4A36 0%, #152A1C 100%) !important;
}

.test-mode .question-card {
  padding: 0;
  border-color: #b8994d;
  box-shadow: 0 4px 0 #6e5c2e, 0 0 30px rgba(184, 153, 77, 0.15), inset 0 0 40px rgba(0,0,0,0.8);
  background: linear-gradient(135deg, rgba(24,24,28,0.85) 0%, rgba(13,13,18,0.9) 100%),
              url('../../assets/images/ui/ttl_test.jpg') center/cover no-repeat;
  position: relative;
}

.test-mode .question-card::after {
  content: '';
  position: absolute;
  top: 6px; left: 6px; right: 6px; bottom: 6px;
  border: 1px solid rgba(184, 153, 77, 0.4);
  pointer-events: none;
  border-radius: inherit;
}

.test-mode .question-word.en-word {
  color: #dabb73;
  text-shadow: 0 2px 8px rgba(184, 153, 77, 0.3);
}

.test-mode .choice-btn {
  background: linear-gradient(135deg, #23232c 0%, #15151c 100%);
  border-color: #b8994d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 0 20px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0,0,0,0.4);
}

.test-mode .parchment-inner-border {
  border-color: rgba(184, 153, 77, 0.3) !important;
}

.test-mode .parchment-inner-border::before,
.test-mode .parchment-inner-border::after {
  background: #1a1a20 !important;
  border-color: rgba(184, 153, 77, 0.3) !important;
}

.test-mode .quiz-image-wrap {
  min-height: 80px;
  border-bottom: none !important;
}

.test-mode.hide-image-bg .question-card {
  min-height: 380px;
  justify-content: flex-start;
  padding-top: 80px;
  padding-bottom: 20px;
}

.test-mode.hide-image-bg .quiz-image-wrap {
  min-height: auto;
  display: block;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  margin: 0 auto;
}
.test-mode.hide-image-bg .quiz-image-wrap::before,
.test-mode.hide-image-bg .quiz-image-wrap::after {
  display: none !important;
}
.test-mode.hide-image-bg .story-audio-hud {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  width: 90%;
  max-width: 400px;
  margin: 0 auto 20px;
  border-radius: 12px;
}

/* Life pill — hidden by default, shown in test mode */
.quiz-life-pill {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-game);
  font-size: 13px;
  color: white;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 20px;
  margin-top: 8px;
  margin-bottom: 8px;
  z-index: 20;
  border: 1px solid rgba(255,255,255,0.15);
}

/* HP Bar Component */
.gh-hp-bar-wrap {
  width: 120px;
  height: 12px;
  background: rgba(0,0,0,0.5);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.3);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  position: relative;
}
.gh-hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00f5a0 0%, #00d9f5 100%);
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 12px rgba(0, 245, 160, 0.25);
}
.gh-hp-bar-fill.warning { 
  background: linear-gradient(90deg, #f1c40f, #f39c12) !important; 
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.4) !important;
}
.gh-hp-bar-fill.danger { 
  background: linear-gradient(90deg, #e74c3c, #c0392b) !important; 
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.4) !important;
}
.test-mode .quiz-life-pill {
  display: none; /* ライフ表示はスペルバトル以外のTESTモードでは不要 */
}

/* Spell Mode Stats Overlay */
.stats-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-family: var(--font-game);
  font-size: 13px;
  color: white;
  z-index: 30;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-sizing: border-box;
}
.test-mode .choice-text {
  color: #cccccc;
}
.test-mode .question-word.ja-word {
  color: #eeeeee;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.test-mode .question-word.en-word,
.test-mode .question-prompt-label {
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  font-weight: 700;
}
.test-mode .choice-text.en-text {
  color: #eeeeee;
}

.test-mode .choice-number {
  border-color: rgba(184, 153, 77, 0.5) !important;
  color: #dabb73 !important;
  background: rgba(184, 153, 77, 0.1) !important;
}

.test-mode .choice-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 1px 3px rgba(0,0,0,0.5);
}

.test-mode .question-card::before {
  background: linear-gradient(90deg, #FF0000, #FF3C3C, #FF0000);
}

.test-mode .question-level-badge {
  color: white;
  background: var(--red);
  border-color: white;
  animation: testPulse 1.2s infinite alternate;
}

@keyframes testPulse {
  0%   { box-shadow: 0 0 4px var(--red); }
  100% { box-shadow: 0 0 16px white; }
}

.test-mode .quiz-progress-fill {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
}

.feedback-banner.correct-banner {
  background: rgba(0,60,20,0.95);
  border-color: #00FF55; color: #88FFB0;
  backdrop-filter: blur(4px);
}
.feedback-banner.wrong-banner {
  background: rgba(60,0,15,0.95);
  border-color: var(--red); color: #FF9999;
  backdrop-filter: blur(4px);
}

/* ---- Point pop ---- */
.point-pop {
  position: fixed;
  font-family: var(--font-game); font-size: 26px; font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: none; z-index: 1000;
  animation: floatUp 1s ease forwards;
}

/* ---- Round complete overlay ---- */
.round-complete-overlay {
  position: fixed; inset: 0;
  background: rgba(26,48,33,0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s ease;
}

.round-complete-card {
  background:
    repeating-linear-gradient(
      -45deg, #12121C, #12121C 10px, #1A1A28 10px, #1A1A28 20px
    );
  border: 3px solid var(--yellow);
  border-radius: var(--radius-xl);
  padding: 40px 32px; max-width: 480px; width: 92%;
  text-align: center;
  animation: bounceIn 0.45s ease;
  position: relative; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  max-height: 90vh;
  box-shadow: 0 6px 0 var(--yellow-dark), var(--shadow-deep);
}

.round-complete-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg,
    #FF0000, #FF7700, #FFD700, #00CC00, #0099FF, #FF0000
  );
}

.round-complete-emoji { font-size: 70px; display: block; margin-bottom: 12px; }
.round-complete-title {
  font-family: var(--font-game); font-size: 26px; font-weight: 900;
  color: var(--yellow); text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.round-complete-score {
  font-family: var(--font-ja); font-size: 16px;
  color: rgba(255,255,255,0.8); margin-bottom: 24px; line-height: 1.8;
}
.round-complete-score span {
  font-family: var(--font-game); font-size: 38px; font-weight: 900;
  color: var(--yellow); display: inline-block;
}
.round-complete-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---- Round Complete Variants (Pass/Fail) ---- */
.round-complete-card.result-success {
  border-color: #FFCC00;
  box-shadow: 0 0 40px rgba(255,215,0,0.4), 0 6px 0 var(--yellow-dark);
}
.round-complete-card.result-success .round-complete-emoji {
  animation: pulse 1.5s infinite;
}

.round-complete-card.result-fail {
  border-color: var(--red);
  background: repeating-linear-gradient(-45deg, #221111, #221111 10px, #2A1515 10px, #2A1515 20px);
  box-shadow: 0 6px 0 #880000, 0 0 20px rgba(255,0,0,0.3);
}
.round-complete-card.result-fail::before {
  background: linear-gradient(90deg, #FF4444, #AA0000, #FF4444);
}
.round-complete-card.result-fail .round-complete-title {
  color: var(--red);
}
.round-complete-card.result-fail .round-complete-score span {
  color: #FFAAAA;
}

/* ---- Confetti ---- */
.confetti-piece {
  position: fixed; pointer-events: none; z-index: 9999;
  animation: confettiSpin linear forwards;
}

@media (max-width: 480px) {
  .en-word {
    font-size: 24px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    word-break: break-word;
  }
  #story-text-en {
    font-size: 18px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
  }
  .sg-slot {
    width: 36px !important;
    height: 44px !important;
    font-size: 24px !important;
  }
  .sg-letter-block {
    width: 38px !important;
    height: 46px !important;
    font-size: 18px !important;
  }
  .sg-ja-meaning {
    font-size: 18px !important;
  }
}

/* iPad landscape */
@media (min-width: 768px) {
  .question-emoji { font-size: 110px; }
  .question-word.en-word { font-size: 60px; }
  .question-word.ja-word { font-size: 44px; }
  .choices-grid { gap: 12px; }
  .choice-btn { min-height: 100px; }
}

@keyframes popInCenter {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.unlock-anim-icon {
  animation: lockBreak 1.5s ease-in-out forwards;
}

@keyframes lockBreak {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  20%  { transform: scale(1.2) rotate(-15deg); opacity: 1; }
  40%  { transform: scale(1.2) rotate(15deg); opacity: 1; }
  60%  { transform: scale(1.5) rotate(0deg); opacity: 1; filter: brightness(2) drop-shadow(0 0 10px white); }
  80%  { transform: scale(2); opacity: 0; filter: brightness(2) drop-shadow(0 0 20px white); }
  100% { transform: scale(2); opacity: 0; }
}

/* ====================================================
   SPELL GAME — Push & Assemble
   Premium アニメーション付きパズルUI
   ==================================================== */

/* ---- Stage 6 Writing Area ---- */
.stg6-textarea {
  font-family: 'Outfit', sans-serif;
  background: rgba(255, 255, 255, 0.9);
  color: #3b2a1a;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.stg6-textarea:focus {
  border-color: var(--sky-blue);
  box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.2);
}

.test-mode .stg6-textarea {
  background: rgba(13, 13, 18, 0.9);
  color: #dabb73;
  border: 2px solid #b8994d;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.test-mode .stg6-textarea:focus {
  border-color: #ffd700;
  box-shadow: 0 0 0 3px rgba(184, 153, 77, 0.3);
}

.test-mode .stg6-email-body {
  background: rgba(13, 13, 18, 0.9) !important;
  color: #eeeeee !important;
  border-color: #b8994d !important;
}

/* ---- Background ---- */
.sg-bg {
  background: #1e2b20 !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  min-height: 100vh;
}

/* Question card variant for spell mode */
.sg-question-card {
  padding-bottom: 0 !important;
}

/* Lower dark striped area of the card */
.sg-card-bottom-area {
  width: 100%;
  background: transparent;
  border-top: 1.5px dashed rgba(139, 69, 19, 0.4);
  padding: 16px 0 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 0 0 12px 12px;
}

/* Japanese meaning display */
.sg-ja-meaning {
  font-family: var(--font-ja);
  font-size: 20px;
  font-weight: 800;
  color: #3b2a1a;
  text-align: center;
  margin-top: 0;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
  text-shadow: none;
}

/* Progress fill variant for spell mode */
.sg-progress-fill {
  background: linear-gradient(90deg, #4CAF50, #00FF55) !important;
  box-shadow: 0 0 12px rgba(0,255,85,0.6) !important;
}

/* ---- Letter Slots Container ---- */
.sg-slots-container {
  display: flex;
  margin: 0 auto;
}

.sg-slots-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  border: 2px solid rgba(139, 69, 19, 0.2);
  background: rgba(139, 69, 19, 0.05);
  gap: 4px;
  border-radius: 8px;
  padding: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* Individual slot */
.sg-slot {
  width: 46px;
  height: 52px;
  background: rgba(139, 69, 19, 0.08);
  border: 1.5px dashed rgba(139, 69, 19, 0.4);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-game);
  font-size: 32px;
  font-weight: 900;
  color: rgba(139, 69, 19, 0.25);
  text-transform: uppercase;
}

/* Filled slot — magical emerald ink */
.sg-slot.filled {
  color: #4CAF50;
  background: rgba(46, 125, 50, 0.15);
  border: 1.5px solid #4CAF50;
  text-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
  animation: sgSnapIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Completed word — emerald magic burst */
.sg-slot.complete {
  color: #88FFB0;
  background: #00FF55;
  border-color: #00FF55;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  box-shadow: 0 0 16px rgba(0, 255, 85, 0.6);
  animation: sgSuccessPulse 0.5s ease;
}

/* Wrong letter — dark magic reject */
.sg-slot.wrong {
  animation: sgSlotShake 0.4s ease;
  background: rgba(198, 40, 40, 0.2);
  border-color: #C62828;
  color: #C62828;
}

/* Next slot indicator — subtle pulse */
.sg-slot.next {
  border-color: #2E7D32;
  box-shadow: inset 0 0 12px rgba(46, 125, 50, 0.2);
}

/* ---- Letter Blocks Container ---- */
.sg-blocks-container {
  width: 100%;
  max-width: 720px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.sg-blocks-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

/* Individual letter block (Parchment Tile) */
.sg-letter-block {
  width: 44px;
  height: 52px;
  border-radius: 6px;
  background: linear-gradient(135deg, #E6D5B8 0%, #C8B08C 100%);
  border: 1px solid #A8865B;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-game);
  font-size: 24px;
  font-weight: 900;
  color: #3b2a1a;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6), 0 4px 0 #5C3A21, 0 6px 6px rgba(0,0,0,0.4);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, box-shadow 0.1s;
}

/* Hover/active states */
.sg-letter-block:active {
  transform: translateY(4px);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6), 0 0 0 #5C3A21, 0 2px 2px rgba(0,0,0,0.4);
}

/* Used block — fades out into parchment */
.sg-letter-block.used {
  background: rgba(200, 176, 140, 0.4);
  color: rgba(59, 42, 26, 0.2);
  border-color: rgba(168, 134, 91, 0.3);
  box-shadow: none;
  pointer-events: none;
  transform: translateY(4px);
}

/* Wrong tap — dark magic reject flash */
.sg-letter-block.wrong-tap {
  animation: sgBlockReject 0.35s ease;
  background: linear-gradient(135deg, #C62828 0%, #8E0000 100%) !important;
  color: white;
  border-color: #5C0000;
}

/* Undo key modifier */
.sg-undo-key {
  background: linear-gradient(135deg, #3B2A1A 0%, #1A120B 100%);
  color: #BFA281;
  border: 1px solid #1A120B;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.1), 0 4px 0 #000, 0 6px 6px rgba(0,0,0,0.5);
}
.sg-undo-key:active {
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.1), 0 0 0 #000, 0 2px 2px rgba(0,0,0,0.5);
}

/* ---- Ability Bar ---- */
.sg-ability-bar {
  width: 100%;
  max-width: 720px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 215, 0, 0.15);
  backdrop-filter: blur(4px);
}

.sg-ability-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  border: 2px solid rgba(255, 215, 0, 0.3);
}

.sg-ability-info {
  flex: 1;
}

.sg-ability-name {
  font-family: var(--font-game);
  font-size: 11px;
  font-weight: 800;
  color: var(--yellow);
  letter-spacing: 0.05em;
}

.sg-ability-effect {
  font-family: var(--font-ja);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

/* ---- Feedback overlay ---- */
.sg-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 400px;
  border-radius: 24px;
  padding: 40px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ja);
  font-weight: 900;
  font-size: 28px;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  border-width: 4px;
  border-style: solid;
  background: rgba(0,60,20,0.95);
  border-color: #00FF55;
  color: #88FFB0;
  backdrop-filter: blur(4px);
}

/* ---- Animations ---- */

/* Snap-in: letter arrives with satisfying bounce */
@keyframes sgSnapIn {
  0% {
    transform: scale(0.3) translateY(20px);
    opacity: 0.3;
  }
  60% {
    transform: scale(1.15) translateY(-4px);
    opacity: 1;
  }
  80% {
    transform: scale(0.95) translateY(1px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

/* Success pulse when word is complete */
@keyframes sgSuccessPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Shake slot on wrong letter */
@keyframes sgSlotShake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* Block reject flash */
@keyframes sgBlockReject {
  0%   { transform: scale(1); background-color: transparent; }
  30%  { transform: scale(1.1); }
  50%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* Next-slot pulse indicator */
@keyframes sgNextPulse {
  0%   { box-shadow: 0 0 4px rgba(255, 215, 0, 0.1); }
  50%  { box-shadow: 0 0 16px rgba(255, 215, 0, 0.4), inset 0 0 6px rgba(255, 215, 0, 0.1); }
  100% { box-shadow: 0 0 4px rgba(255, 215, 0, 0.1); }
}

/* Responsive for wider screens */
@media (min-width: 768px) {
  .sg-slot { width: 48px; height: 56px; font-size: 30px; }
  .sg-letter-block { width: 60px; height: 64px; font-size: 28px; }
  .sg-ja-meaning { font-size: 38px; }
}

/* ====================================================
   STORY MODE - Audio & Karaoke
   ==================================================== */

.story-image-play-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.story-image-play-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.story-image-play-btn:active {
  transform: scale(0.95);
}

/* Karaoke highlighting */
.karaoke-word {
  color: #8A6442;
  font-family: inherit;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  transform-origin: center;
}

.karaoke-word.active {
  color: #d43232;
  text-shadow: 0 2px 4px rgba(212, 50, 50, 0.1);
  transition: all 0.15s ease-out;
}

.karaoke-word.read {
  color: #8A6442;
  transition: all 0.4s ease;
}


/* Audio Player HUD — イラストの上にオーバーレイ（コンパクト） */
.story-audio-hud {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 5px 12px;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hud-btn {
  background: white;
  border: none;
  color: #333;
  font-size: 11px;
  cursor: pointer;
  margin-right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.hud-btn:active {
  transform: scale(0.9);
}

.hud-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  margin-right: 12px;
}

.hud-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #F06A6A, #FFD700);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.hud-fill::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.hud-time {
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  min-width: 35px;
  text-align: right;
  font-family: 'Inter', sans-serif;
}

/* Story Mode UI Improvements */
#story-text-container {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 16px 20px 20px 20px !important;
  min-height: auto !important;
}

#story-text-en {
  font-family: 'Outfit', sans-serif !important;
  font-size: 22px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  color: #2c1e12 !important;
  margin-top: 4px !important;
  margin-bottom: 8px !important;
  letter-spacing: -0.01em !important;
  text-shadow: none !important;
}

#story-subtitle-ja {
  margin-top: 6px !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
  color: #8A6442 !important;
  opacity: 0.9;
}

.story-segment-wrap {
  margin-bottom: 40px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
}

#story-text-scroll-container::-webkit-scrollbar {
  display: none;
}

#story-text-scroll-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.parchment-card {
  margin-bottom: 4px !important;
  height: auto !important;
  min-height: auto !important;
}

.dq-btn {
  transition: transform 0.2s, filter 0.2s, box-shadow 0.2s !important;
}
.dq-btn:hover {
  transform: scale(1.05) translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}
.dq-btn:active {
  transform: scale(0.98);
}

/* Story navigation flat buttons */
.story-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 20px;
  background: rgba(139, 90, 43, 0.08);
  color: #8B5A2B;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  margin: 0;
  transition: all 0.2s ease;
  user-select: none;
}

.story-nav-btn:hover {
  background: rgba(139, 90, 43, 0.15);
  transform: scale(1.05);
}
.story-nav-btn:active {
  transform: scale(0.95);
}
/* ====================================================
   MOBILE OPTIMIZATION - Audio Player Positioning
   ==================================================== */
@media (max-width: 520px) {
  .quiz-image-wrap {
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-bottom: 0px;
    background: #000; /* Backdrop for contain-mode margins if any */
  }

  .story-audio-hud {
    position: relative !important;
    bottom: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    padding: 8px 12px !important;
    backdrop-filter: blur(10px) !important;
    border: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
  }

  /* Adjust integrated progress bar to bottom of HUD if needed */
  .quiz-progress-bar-integrated {
    position: relative;
    width: 100%;
    margin-top: -6px; /* Overlay slightly if desired, or just static */
    z-index: 30;
  }
}

/* ====================================================
   STAGE 5 TEST MODE OVERRIDES
   ==================================================== */
#screen-stage5.test-mode {
  background: radial-gradient(circle at top, #2C4A36 0%, #152A1C 100%) !important;
}

#screen-stage5.test-mode .stg5-hdr-section {
  color: #eeeeee !important;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8) !important;
}
#screen-stage5.test-mode .stg5-hdr-counter {
  color: #dabb73 !important;
}

#screen-stage5.test-mode .question-level-badge-inline {
  color: white !important;
  background: var(--red) !important;
  border-color: white !important;
  animation: testPulse 1.2s infinite alternate !important;
}

/* Revert Stage 5 dark global test-mode styling back to normal parchment style */
#screen-stage5.test-mode .question-card {
  background-color: #fdf5e6 !important;
  background-image: url('../assets/images/ui/paper_texture.jpg') !important;
  background-size: cover !important;
  border-color: #d4b59d !important;
  box-shadow: 0 8px 24px rgba(139, 90, 43, 0.2) !important;
  transition: none !important;
}
#screen-stage5.test-mode .question-card::before,
#screen-stage5.test-mode .question-card::after {
  display: none !important;
}
#screen-stage5.test-mode .choice-btn {
  background: linear-gradient(135deg, #FFFAF0 0%, #F5E8D8 100%) !important;
  border-color: #9D754B !important;
  border-width: 4px !important;
  box-shadow: inset 0 0 0 2px #FFF, inset 0 0 20px rgba(139, 69, 19, 0.06), 0 4px 8px rgba(0,0,0,0.3) !important;
}
#screen-stage5.test-mode .choice-btn:active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), 0 1px 3px rgba(139, 90, 43, 0.2) !important;
  transform: translateY(2px) !important;
}
#screen-stage5.test-mode .choice-text {
  color: #444 !important;
  text-shadow: none !important;
}
#screen-stage5.test-mode .parchment-inner-border {
  border-color: rgba(139, 90, 43, 0.4) !important;
}
#screen-stage5.test-mode .parchment-inner-border::before,
#screen-stage5.test-mode .parchment-inner-border::after {
  background: transparent !important;
  border-color: transparent !important;
}

/* Stage 5: Remove focus/hover shadows on all interactive elements */
#screen-stage5 .choice-btn:focus,
#screen-stage5 .choice-btn:focus-visible,
#screen-stage5 .stg5-tts-btn:focus,
#screen-stage5 .stg5-tts-btn:focus-visible,
#screen-stage5 .stg5-toggle-btn:focus,
#screen-stage5 .stg5-toggle-btn:focus-visible {
  outline: none !important;
  box-shadow: inset 0 0 0 2px #FFF, inset 0 0 20px rgba(139, 69, 19, 0.06), 0 4px 8px rgba(0,0,0,0.3) !important;
}
#screen-stage5 .question-card:focus-within {
  box-shadow: 0 8px 24px rgba(139, 90, 43, 0.2) !important;
}

/* ====================================================
   STAGE 5 — AUDIO HUD (Float + Inline)
   ==================================================== */

/* フロートHUD: #app 直下 position:fixed (viewport基準で確実に動作) */
.stg5-float-hud {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  z-index: 8000; /* グローバルヘッダー(9000)の下 */
  padding: 8px 14px 14px;
  box-sizing: border-box;
  /* グラデーションで自然にフェードイン */
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.55) 65%, transparent 100%);
  pointer-events: auto;
}

/* セーフエリア対応（iPhone等のホームバー） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .stg5-float-hud {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

/* フロートHUD内の story-audio-hud コンポーネントをオーバーライド */
.stg5-float-hud .story-audio-hud {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 14px !important;
  background: rgba(20, 20, 24, 0.72) !important;
  backdrop-filter: blur(14px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(14px) saturate(150%) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.45) !important;
  padding: 8px 14px !important;
}

/* インラインHUD: 読解エリア直下にインライン表示 */
#stg5-inline-hud .story-audio-hud {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 12px !important;
  background: rgba(0, 0, 0, 0.50) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
  padding: 7px 12px !important;
}

/* 画面下部をフロートHUD分確保 */
#screen-stage5 {
  padding-bottom: 80px;
}
