/* ==========================================================
   神谷塾 かなクイズ (Kana Quiz) - CSS Stylesheet
   Brand Colors:
   - Primary Green: #4caf50
   - Primary Dark Green: #005100
   - Accent Yellow: #ffc107
   - Accent Dark Yellow: #916400
   - Charcoal / Text: #212121
   - Soft Green / Background: #e8f5e9
   - Pure White: #ffffff
   ========================================================== */

:root {
  --color-primary: #4caf50;
  --color-primary-dark: #005100;
  --color-primary-light: #e8f5e9;
  --color-primary-hover: #43a047;
  
  --color-accent: #ffc107;
  --color-accent-dark: #916400;
  --color-accent-light: #fff8e1;
  
  --color-dark: #212121;
  --color-text-muted: #616161;
  --color-border: #c8e6c9;
  --color-card-bg: #ffffff;
  
  --color-error: #e53935;
  --color-error-light: #ffebee;
  --color-error-border: #ef5350;

  --shadow-sm: 0 2px 4px rgba(0, 81, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 81, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 81, 0, 0.16);
  --shadow-hover: 0 6px 16px rgba(76, 175, 80, 0.28);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'M PLUS Rounded 1c', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-primary-light);
  color: var(--color-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Subtle Background Watermark Logo in the Right Space */
.bg-watermark-logo {
  position: fixed;
  right: clamp(12px, 3.5vw, 65px);
  top: 50%;
  transform: translateY(-50%);
  width: min(340px, 25vw);
  height: min(340px, 25vw);
  background-image: url('logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 4px 16px rgba(0, 81, 0, 0.08));
  transition: opacity 0.3s ease;
}

@media (max-width: 1200px) {
  .bg-watermark-logo {
    opacity: 0.07;
    width: 240px;
    height: 240px;
    right: 20px;
  }
}

@media (max-width: 800px) {
  .bg-watermark-logo {
    opacity: 0.04;
    width: 160px;
    height: 160px;
    right: 12px;
    bottom: 20px;
    top: auto;
    transform: none;
  }
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background-color: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  border-left: 6px solid var(--color-primary-dark);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 81, 0, 0.25);
}

.header-titles h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  line-height: 1.1;
}

.header-titles .sub-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent-dark);
  margin-left: 0.35rem;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
}

.icon-btn {
  background-color: #f1f3f4;
  border: 1.5px solid #d5d5d5;
  border-radius: var(--radius-full);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.65;
  user-select: none;
  outline: none;
}

.icon-btn:hover {
  opacity: 0.95;
  background-color: #e8eaed;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.icon-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary-dark);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 81, 0, 0.25);
}

.icon-btn.active:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 81, 0, 0.3);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn .icon {
  pointer-events: none;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Views Management */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Section Labels */
.section-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 0.5rem;
}

/* Setup Card */
.setup-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Script Tabs */
.script-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--color-primary-light);
  padding: 0.35rem;
  border-radius: var(--radius-md);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease;
  color: var(--color-dark);
}

.tab-btn .tab-jp {
  font-size: 1.05rem;
  font-weight: 800;
}

.tab-btn .tab-en {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--color-primary-dark);
  box-shadow: 0 2px 6px rgba(0, 81, 0, 0.15);
}

.tab-btn.active .tab-en {
  color: var(--color-primary);
  font-weight: 600;
}

/* Quick Action Chips */
.selection-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-chip {
  background: #ffffff;
  border: 1px solid var(--color-border);
  color: var(--color-primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-chip:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

/* Kana Groups */
.kana-groups-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.group-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #fafdfa;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

#section-tokushu {
  border-left: 4px solid var(--color-accent);
}

.group-header h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}

.group-header .en-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-left: 0.4rem;
}

.btn-group-toggle {
  background: transparent;
  border: none;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.btn-group-toggle:hover {
  color: var(--color-primary-dark);
}

/* Rows Grid */
.rows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}

.row-card {
  background: #ffffff;
  border: 1.5px solid #dcedc8;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.row-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.row-card.selected {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.row-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent-dark);
}

.row-card-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
}

.row-kana-preview {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-dark);
  letter-spacing: 0.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.option-card {
  background: #fafdfa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.option-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  background: var(--color-primary-light);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-dark);
  transition: all 0.2s ease;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--color-primary-dark);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.select-input {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-dark);
  outline: none;
}

.select-input:focus {
  border-color: var(--color-primary);
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle-switch input {
  display: none;
}

.slider {
  width: 36px;
  height: 20px;
  background-color: #ccc;
  border-radius: 20px;
  position: relative;
  transition: 0.2s;
  flex-shrink: 0;
}

.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  top: 2px;
  left: 2px;
  transition: 0.2s;
}

.toggle-switch input:checked + .slider {
  background-color: var(--color-primary);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(16px);
}

.toggle-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-dark);
}

.option-subtitle {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  line-height: 1.25;
  margin-top: 0.15rem;
}

/* Action Bars & Buttons */
.start-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.selected-count-badge {
  font-size: 0.95rem;
  color: var(--color-primary-dark);
  font-weight: 600;
}

.selected-count-badge strong {
  color: var(--color-accent-dark);
  font-size: 1.25rem;
}

.btn-primary-large {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary-large:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.05);
}

.btn-primary-large:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary-large {
  background: var(--color-accent);
  color: var(--color-dark);
  border: none;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.35);
  transition: all 0.2s ease;
}

.btn-secondary-large:hover {
  transform: translateY(-2px);
  background: #ffca28;
}

.btn-outline-large {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary-dark);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline-large:hover {
  background: var(--color-primary-light);
}

/* ================= QUIZ PLAY VIEW ================= */
.quiz-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-card-bg);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.btn-text {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-text:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

.progress-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: var(--color-primary-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-accent-light);
  border: 1.5px solid var(--color-accent);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-weight: 800;
  color: var(--color-accent-dark);
}

.streak-icon {
  font-size: 1rem;
}

.streak-num {
  font-size: 1rem;
}

/* Quiz Arena */
.quiz-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.flashcard {
  width: 100%;
  max-width: 480px;
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid #e0f2f1;
  min-height: 260px;
  transition: all 0.25s ease;
}

.flashcard.correct-anim {
  border-color: var(--color-primary);
  background-color: #f1f8e9;
  transform: scale(1.02);
}

.flashcard.wrong-anim {
  border-color: var(--color-error);
  background-color: var(--color-error-light);
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.card-sound-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--color-primary-light);
  border: 1px solid var(--color-border);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.card-sound-btn:hover {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.1);
}

.kana-type-tag {
  position: absolute;
  top: 1.1rem;
  left: 1.2rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08rem;
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

.kana-char-wrapper {
  margin: 0.5rem 0;
}

.kana-char {
  font-size: 5.5rem;
  font-weight: 900;
  color: var(--color-dark);
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.feedback-box {
  min-height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
}

.feedback-answer {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}

.feedback-hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-error);
}

/* Typing Answer Container */
.answer-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-wrapper {
  display: flex;
  position: relative;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.romaji-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: 'Outfit', var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  border: 2.5px solid var(--color-primary);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--color-dark);
  transition: all 0.2s ease;
}

.romaji-input:focus {
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.25);
}

.btn-input-submit {
  position: absolute;
  right: 8px;
  top: 8px;
  bottom: 8px;
  width: 48px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-input-submit:hover {
  background: var(--color-primary-dark);
}

.input-helpers, .choice-helpers {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.btn-helper {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem;
}

.btn-helper:hover {
  color: var(--color-primary-dark);
}

.typing-tip {
  color: var(--color-accent-dark);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Choice Mode Grid */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.choice-btn {
  background: var(--color-card-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1rem;
  font-family: 'Outfit', var(--font-sans);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-dark);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s ease;
}

.choice-btn .key-hint {
  position: absolute;
  left: 0.75rem;
  top: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-primary-light);
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-btn:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.choice-btn.correct {
  background: #4caf50 !important;
  color: #ffffff !important;
  border-color: #005100 !important;
}

.choice-btn.wrong {
  background: #e53935 !important;
  color: #ffffff !important;
  border-color: #b71c1c !important;
}

/* ================= RESULTS VIEW ================= */
.results-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: center;
}

/* Brand header inside Results Card (Visible on screen and in screenshot) */
.results-brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding-bottom: 0.85rem;
  border-bottom: 1.5px solid var(--color-border);
  margin-bottom: 0.25rem;
}

.results-logo-badge {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.results-brand-titles {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.results-brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  line-height: 1.2;
}

.results-brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.results-card-footer {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  padding-top: 0.5rem;
  border-top: 1px dashed var(--color-border);
  opacity: 0.85;
}

.results-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.trophy-badge {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.results-header h2 {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--color-primary-dark);
}

.results-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.results-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  background: #fafdfa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 0.5rem;
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

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

.stat-val {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--color-primary-dark);
}

.stat-val.highlight {
  color: var(--color-accent-dark);
}

/* Review Grids */
.review-section {
  text-align: left;
}

.review-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-dark);
  margin-bottom: 0.5rem;
}

.kana-review-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--color-border);
  background: #ffffff;
}

.review-item.mistake {
  background: var(--color-error-light);
  border-color: var(--color-error-border);
  color: var(--color-error);
}

.review-item.correct {
  background: var(--color-primary-light);
  border-color: var(--color-border);
  color: var(--color-primary-dark);
}

.review-item .rev-char {
  font-size: 1.15rem;
  font-weight: 900;
}

.review-item .rev-romaji {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ================= RESULTS CTA SECTION (CONVERSION FUNNEL) ================= */
.results-cta-section {
  background: linear-gradient(145deg, #f0fdf4 0%, #ffffff 50%, #fffbeb 100%);
  border: 1.5px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1.35rem;
  box-shadow: 0 4px 18px rgba(16, 124, 65, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-top: 0.5rem;
}

.results-cta-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #107c41, #f59e0b);
}

.cta-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.cta-pill {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #166534;
  background: #dcfce7;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  display: inline-block;
}

.cta-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--color-primary-dark);
  margin: 0.15rem 0 0;
  line-height: 1.25;
}

.cta-desc {
  font-size: 0.85rem;
  color: #4b5563;
  margin: 0;
  line-height: 1.4;
  max-width: 520px;
}

.cta-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.cta-card-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.cta-card-btn:hover {
  transform: translateY(-2px);
}

.cta-card-btn:active {
  transform: translateY(0);
}

/* Challenge Kamiya button (Emerald signature) */
.cta-btn-challenge {
  background: linear-gradient(135deg, #107c41 0%, #065f46 100%);
  color: #ffffff;
  border: 1.5px solid #047857;
  box-shadow: 0 4px 12px rgba(16, 124, 65, 0.28);
}

.cta-btn-challenge:hover {
  background: linear-gradient(135deg, #15803d 0%, #047857 100%);
  box-shadow: 0 6px 18px rgba(16, 124, 65, 0.38);
}

/* Free Trial Lesson button (Warm Amber / Gold accent) */
.cta-btn-trial {
  background: #ffffff;
  color: var(--color-dark);
  border: 1.5px solid #f59e0b;
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.15);
}

.cta-btn-trial:hover {
  background: #fffbeb;
  border-color: #d97706;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}

.cta-icon {
  font-size: 1.7rem;
  line-height: 1;
  flex-shrink: 0;
}

.cta-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cta-btn-title {
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.cta-btn-challenge .cta-btn-title {
  color: #ffffff;
}

.cta-btn-trial .cta-btn-title {
  color: #b45309;
}

.cta-price-tag {
  font-size: 0.72rem;
  font-weight: 800;
  background: #fef08a;
  color: #854d0e;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.cta-btn-sub {
  font-size: 0.75rem;
  line-height: 1.3;
}

.cta-btn-challenge .cta-btn-sub {
  color: #d1fae5;
}

.cta-btn-trial .cta-btn-sub {
  color: #6b7280;
}

.cta-arrow {
  font-size: 1.15rem;
  font-weight: 800;
  opacity: 0.75;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.cta-card-btn:hover .cta-arrow {
  transform: translateX(4px);
  opacity: 1;
}

.results-action-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Results Share Section (Compact & Discreet) */
.results-share-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding-top: 1.1rem;
  margin-top: 0.25rem;
  border-top: 1px dashed var(--color-border);
}

.share-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.share-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-dark);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn-share .share-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.btn-share:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.btn-share:hover .share-svg {
  transform: scale(1.12);
}

.btn-share:active {
  transform: translateY(0);
}

/* Specific styling for Captura (Image download) */
.btn-image {
  border-color: #2e7d32;
  color: #1b5e20;
  background: #e8f5e9;
}

.btn-image:hover {
  background: #c8e6c9;
  border-color: #1b5e20;
  color: #004d40;
}

/* Specific styling for Threads */
.btn-threads {
  border-color: #000000;
  background: #111111;
  color: #ffffff;
}

.btn-threads:hover {
  background: #252525;
  border-color: #252525;
}

/* Specific styling for Instagram */
.btn-instagram {
  border-color: #e1306c;
  color: #bc2a8d;
  background: #ffffff;
}

.btn-instagram:hover {
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: #ffffff;
  border-color: transparent;
}

/* Specific styling for Copy */
.btn-copy {
  border-color: var(--color-border);
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
}

.btn-copy:hover {
  background: #c8e6c9;
  border-color: var(--color-primary);
}

/* Share Toast message */
.share-toast {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  display: inline-block;
  animation: toastFadeIn 0.25s ease;
  box-shadow: var(--shadow-sm);
  max-width: 90%;
  text-align: center;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.5rem 0 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-primary-dark);
  font-weight: 600;
  opacity: 0.8;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .app-container {
    padding: 0.75rem 0.5rem;
  }
  
  .results-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .start-action-bar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .btn-primary-large {
    width: 100%;
  }

  .kana-char {
    font-size: 4.2rem;
  }

  .results-cta-section {
    padding: 1.1rem 0.85rem;
  }

  .cta-title {
    font-size: 1.15rem;
  }

  .cta-buttons-grid {
    grid-template-columns: 1fr;
  }
}
