/* JLPT Learning Platform - Minimalist Monochrome */

/* ===== CSS Variables ===== */
:root {
  /* Monochrome Palette */
  --primary-color: #000000;
  --primary-dark: #333333;
  --secondary-color: #666666;
  --accent-color: #111111;

  /* Text - High Contrast */
  --text-primary: #111111;
  --text-secondary: #666666;

  /* Backgrounds */
  --bg-primary: #FFFFFF;
  --bg-secondary: #FAFAFA;
  --bg-tertiary: #F5F5F5;

  /* Borders */
  --border-color: #E5E5E5;

  /* Shadows - Minimal */
  --shadow-sm: none;
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.04);

  /* Radius - Clean & Sharp */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  /* Changed to primary white for cleaner look */
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

::selection {
  background: var(--primary-color);
  color: white;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.header {
  background: #000000;
  border-bottom: 1px solid #111;
  padding: 1.5rem 0;
  box-shadow: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.logo-text {
  color: white;
  display: inline-block;
}

.logo-blue {
  color: #007bff;
}

.logo-sub {
  font-weight: 500;
  font-size: 0.9em;
  opacity: 0.9;
  margin-left: 0.4rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: white;
}

.logo-icon {
  display: none;
  /* Removed icon for cleaner look */
}

/* ===== Navigation ===== */
.nav-bar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0;
}

.nav-content {
  display: flex;
  gap: 2rem;
  padding: 0;
}

.nav-btn {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.25rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-btn:hover {
  background: transparent;
  color: var(--primary-color);
}

.nav-btn.active {
  background: transparent;
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.nav-icon {
  font-size: 1.1rem;
  filter: grayscale(100%);
}

/* ===== Main Content ===== */
.main-content {
  padding: 2rem 0;
  min-height: calc(100vh - 200px);
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-header h2 {
  font-size: 2rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.section-description {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* ===== Search & Filters ===== */
/* ===== Jisho Search Bar ===== */
.search-container {
  max-width: 800px;
  margin: 0 auto 2rem;
}

.search-input-group {
  display: flex;
  align-items: stretch;
  background: var(--bg-primary);
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  height: 48px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  /* Subtle depth */
}

.search-input-group:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.search-dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: #f0f0f0;
  border-right: 1px solid #ccc;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: default;
}

.dropdown-arrow {
  font-size: 0.7rem;
  opacity: 0.6;
}

.jisho-main-input {
  flex: 1;
  border: none;
  padding: 0 1rem;
  font-size: 1.1rem;
  outline: none;
  background: transparent;
  width: 100%;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text-primary);
}

.clear-btn-jisho {
  background: transparent;
  border: none;
  color: #999;
  font-size: 1.5rem;
  padding: 0 0.5rem;
  cursor: pointer;
  line-height: 1;
}

.clear-btn-jisho:hover {
  color: #666;
}

.search-submit-btn {
  background: #f0f0f0;
  border: none;
  border-left: 1px solid #ccc;
  width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.search-submit-btn:hover {
  background: #e0e0e0;
  color: var(--primary-color);
}

/* ===== Grammar Toolbar ===== */
.grammar-controls-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.grammar-search-group {
  flex: 1;
  min-width: 250px;
}

.grammar-filters-group {
  display: flex;
  gap: 0.75rem;
}

.search-input-group.compact {
  height: 40px;
  /* Slightly smaller for grammar toolbar */
  background: white;
}

.search-icon-wrapper {
  display: flex;
  align-items: center;
  padding-left: 0.75rem;
  color: var(--text-secondary);
}

/* Custom Selects */
.custom-select-wrapper {
  position: relative;
  min-width: 140px;
}

.custom-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 0 2rem 0 1rem;
  height: 40px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Noto Sans JP', sans-serif;
}

.custom-select:hover {
  border-color: #999;
}

.custom-select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.select-arrow {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Polish for Grammar Cards */
.grammar-card:hover {
  background: var(--bg-secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-bottom-color: transparent;
  /* Seamless shadow fix */
  z-index: 1;
  position: relative;
}

.filter-select {
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* ===== Jisho Style Layout ===== */
.vocab-results {
  margin-top: 2rem;
}

.jisho-results-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.results-count {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-primary);
}

.count-divider {
  color: var(--text-secondary);
  margin: 0 0.5rem;
}

.count-number {
  color: var(--text-secondary);
}

.jisho-results-list {
  display: flex;
  flex-direction: column;
}

.jisho-result-item {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
  transition: var(--transition);
  animation: slideUpFade 0.4s ease forwards;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.jisho-result-item:last-child {
  border-bottom: none;
}

/* Jisho Grid System */
.jisho-entry-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 600px) {
  .jisho-entry-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Left Column: Word */
.jisho-entry-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.jisho-word-block {
  margin-bottom: 0.5rem;
}

.jisho-furigana {
  font-size: 0.9rem;
  color: var(--text-primary);
  min-height: 1.2em;
  /* Keep space if empty */
  margin-bottom: -0.2rem;
  font-family: 'Noto Sans JP', sans-serif;
}

.jisho-word-main {
  font-size: 3rem;
  font-weight: 500;
  line-height: 1.1;
  color: var(--text-primary);
  font-family: 'Noto Sans JP', sans-serif;
  letter-spacing: -0.02em;
}

.jisho-romaji {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: italic;
}

.jisho-word-link:hover .jisho-word-main {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.jisho-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.jisho-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: white;
  font-weight: 500;
  text-transform: lowercase;
  white-space: nowrap;
}

.jisho-tag-common {
  background-color: #4CAF50;
  /* Jisho Green */
}

.jisho-tag-jlpt {
  background-color: #888;
  /* Neutral Gray/Blue style */
}

.jisho-audio-link {
  font-size: 0.8rem;
  color: var(--primary-color);
  margin-top: 0.5rem;
  cursor: pointer;
  text-decoration: underline;
  opacity: 0;
  /* Hidden placeholder for now unless implemented */
  pointer-events: none;
}

/* Right Column: Meanings */
.jisho-entry-right {
  position: relative;
  padding-top: 1.2rem;
  /* Align roughly with Kanji center visually */
}

.jisho-pos-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.jisho-meanings-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jisho-meaning-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.jisho-meaning-num {
  color: var(--text-secondary);
  font-size: 0.9rem;
  min-width: 1.2rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.jisho-meaning-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.jisho-meaning-text {
  font-size: 1.1rem;
  color: var(--text-primary);
  line-height: 1.5;
  font-weight: 400;
}

.jisho-pos-inline {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
  margin-bottom: 0.25rem;
}

.jisho-meaning-tags {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 0.25rem;
}

.jisho-meaning-info {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 3px;
  display: inline-block;
}

/* Example sentences */
.jisho-examples {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.jisho-examples-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.jisho-example-item {
  margin-bottom: 0.75rem;
  padding-left: 1rem;
  border-left: 2px solid var(--primary-color);
}

.jisho-example-jp {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  line-height: 1.6;
}

.jisho-example-en {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Related words */
.jisho-related {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.jisho-related-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

.jisho-related-word {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.jisho-related-word:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
}

/* Usage notes */
.jisho-notes {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.jisho-note-item {
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--primary-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.jisho-details-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.jisho-details-link:hover {
  color: var(--primary-color);
}

/* Badge Updates */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
}

.badge-level {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.badge-common {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.badge-api {
  display: none;
}

/* ===== Grammar List Layout (Jisho Style) ===== */
.grammar-list-wrapper {
  margin-top: 1rem;
}

.grammar-list-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.grammar-list {
  display: flex;
  flex-direction: column;
}

.grammar-card {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
  transition: all 0.2s ease;
  cursor: pointer;
  /* Use Jisho Grid System - match vocabulary layout */
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  align-items: start;
  position: relative;
}

@media (max-width: 600px) {
  .grammar-card {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.25rem 1rem;
  }

  .grammar-pattern-text {
    font-size: 2.25rem;
  }

  .grammar-meaning-preview {
    font-size: 1.1rem;
  }

  .grammar-formation-preview {
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
  }

  .grammar-detail-inner {
    padding: 1.5rem 1rem;
  }

  .example-box-modern {
    padding: 1rem;
  }

  .example-jp {
    font-size: 1.1rem;
  }

  .example-en {
    font-size: 0.95rem;
  }
}

.grammar-card:last-child {
  border-bottom: none;
}

.grammar-card:hover {
  background: var(--bg-secondary);
}

.grammar-card.active {
  background: var(--bg-secondary);
}

/* Grammar Left Column */
.grammar-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.grammar-pattern-text {
  font-size: 2.5rem;
  /* Large like Kanji */
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'Noto Sans JP', sans-serif;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.grammar-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* Grammar Right Column */
.grammar-card-right {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  padding-top: 0.5rem;
}

.grammar-meaning-preview {
  font-size: 1.2rem;
  color: var(--text-primary);
  line-height: 1.5;
  font-weight: 400;
}

.grammar-formation-preview {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-family: monospace;
}

.grammar-details-link {
  font-size: 0.85rem;
  color: var(--primary-color);
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.grammar-card-detail {
  grid-column: 1 / -1;
  /* Span full width when expanded */
  border-top: 1px dashed var(--border-color);
  background: transparent;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}

.grammar-detail-inner {
  padding: 1.5rem;
}

.grammar-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.detail-block {
  position: relative;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.detail-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.example-box-modern {
  border-left: 3px solid var(--primary-color);
  padding-left: 1rem;
  background: transparent;
}

.example-jp {
  font-size: 1.1rem;
  font-family: 'Noto Sans JP', sans-serif;
  margin-bottom: 0.3rem;
  color: var(--text-primary);
}

.example-en {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== Quiz Section ===== */
.quiz-type-selection {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-type-selection h3 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.5rem;
}

.quiz-type-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.quiz-type-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

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

.quiz-type-btn.selected {
  border-color: var(--primary-color);
  background: var(--bg-tertiary);
}

.quiz-type-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
  filter: grayscale(100%);
}

.quiz-type-label {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.quiz-type-desc {
  display: block;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.quiz-settings {
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.quiz-settings h3 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== Quiz Active ===== */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
}

.quiz-progress {
  flex: 1;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

.quiz-question-container {
  max-width: 700px;
  margin: 0 auto;
}

.quiz-question {
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.question-kanji {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 1rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--primary-color);
}

.question-text,
.question-instruction {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.question-sentence {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 2rem;
  font-family: 'Noto Sans JP', sans-serif;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

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

.quiz-option {
  padding: 1.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
  font-family: 'Noto Sans JP', sans-serif;
  text-align: center;
}

.quiz-option:hover:not(.disabled) {
  background: var(--bg-secondary);
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

.quiz-option.correct {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.quiz-option.incorrect {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-color);
  text-decoration: line-through;
  opacity: 0.8;
}

.quiz-option.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.answer-explanation {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
}

.explanation-text {
  color: var(--text-primary);
  line-height: 1.6;
}

/* ===== Quiz Results ===== */
.results-container {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: none;
  border: 1px solid var(--border-color);
  text-align: center;
}

.results-header {
  margin-bottom: 2rem;
}

.results-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  filter: grayscale(100%);
}

.results-header h2 {
  font-size: 2rem;
  color: var(--text-primary);
}

.results-score {
  margin: 2rem 0;
}

.score-circle {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--border-color);
  background: var(--bg-primary);
}

.score-circle.passed {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}

.score-circle.failed {
  border-color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.score-percentage {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.score-fraction {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}

.stat-item {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary,
.btn-secondary-small {
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-primary);
}

.btn-secondary-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ===== Welcome & Empty States ===== */
/* Word of the Day */
.word-of-day-container {
  max-width: 800px;
  margin: 2rem auto;
}

.word-of-day-header {
  text-align: center;
  margin-bottom: 2rem;
}

.word-of-day-header h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.word-of-day-date {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.word-of-day-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.word-of-day-main {
  text-align: center;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.word-of-day-meanings h4 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.search-prompt {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.welcome-message,
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: none;
  border: 1px solid var(--border-color);
}

.welcome-message h3 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.welcome-message p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* ===== Loading & Error States ===== */
.loading-container,
.error-container {
  text-align: center;
  padding: 3rem 2rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-message {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-message {
  color: var(--accent-color);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 1002;
}

.modal-close:hover {
  background: var(--accent-color);
  color: white;
}

.modal-body {
  padding: 2rem;
}

/* ===== Vocabulary Detail Modal ===== */
.vocab-detail {
  max-width: 600px;
}

.vocab-detail-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.vocab-detail-header h2 {
  font-size: 2.5rem;
  font-family: 'Noto Sans JP', sans-serif;
  margin-bottom: 1rem;
}

.reading-large {
  font-size: 1.5rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text-primary);
}

.romaji-large {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-style: italic;
}

.meanings-list {
  list-style: none;
  padding: 0;
}

.meanings-list li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.meanings-list li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
}

.tags,
.related-words {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag,
.related-word {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

/* ===== Review Modal ===== */
.review-container {
  max-width: 800px;
}

.review-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.review-questions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.review-question {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
}

.review-header {
  margin-bottom: 1rem;
}

.review-number {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.review-kanji {
  font-size: 3rem;
  text-align: center;
  margin: 1rem 0;
  font-family: 'Noto Sans JP', sans-serif;
}

.review-sentence {
  font-size: 1.3rem;
  text-align: center;
  margin: 1rem 0;
  font-family: 'Noto Sans JP', sans-serif;
}

.review-answers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.review-answer {
  padding: 1rem;
  border-radius: var(--radius-md);
}

.review-answer.correct {
  background: rgba(80, 200, 120, 0.1);
  border: 2px solid var(--secondary-color);
}

.review-answer.incorrect {
  background: rgba(255, 107, 107, 0.1);
  border: 2px solid var(--accent-color);
}

.answer-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.answer-value {
  display: block;
  font-size: 1.2rem;
  font-family: 'Noto Sans JP', sans-serif;
}

.review-explanation {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
}

/* ===== Notifications ===== */
.notification {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--bg-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.notification-exit {
  animation: slideOut 0.3s ease;
}

@keyframes slideOut {
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.notification-info {
  border-left: 4px solid var(--primary-color);
}

.notification-success {
  border-left: 4px solid var(--secondary-color);
}

.notification-error {
  border-left: 4px solid var(--accent-color);
}

.notification-warning {
  border-left: 4px solid #FFA500;
}

.notification-icon {
  font-size: 1.5rem;
}

.notification-text {
  flex: 1;
}

.notification-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.notification-close:hover {
  color: var(--accent-color);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  margin-top: 4rem;
  text-align: center;
}

.footer-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.footer-contact {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-contact a {
  color: var(--primary-color);
  text-decoration: none;
}

.footer-contact a:hover {
  text-decoration: underline;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  .logo {
    font-size: 1.2rem;
  }

  .logo-icon {
    font-size: 1.5rem;
  }

  .nav-content {
    gap: 0.25rem;
  }

  .nav-btn {
    padding: 0.5rem;
    font-size: 0.8rem;
  }

  .nav-icon {
    font-size: 1.2rem;
  }

  .section-header h2 {
    font-size: 1.5rem;
  }

  .vocab-grid {
    grid-template-columns: 1fr;
  }

  .grammar-table-wrapper {
    overflow-x: auto;
  }

  .grammar-table {
    min-width: 600px;
  }

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

  .quiz-options {
    grid-template-columns: 1fr;
  }

  .results-stats {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 95%;
    margin: 1rem;
  }

  .notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .grammar-controls {
    flex-direction: column;
  }

  .grammar-controls .search-box {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .question-kanji {
    font-size: 3rem;
  }

  .question-sentence {
    font-size: 1.2rem;
  }

  .score-circle {
    width: 150px;
    height: 150px;
  }

  .score-percentage {
    font-size: 2rem;
  }

  .results-actions {
    flex-direction: column;
  }

  .results-actions button {
    width: 100%;
  }
}

/* ===== Skeleton Loading ===== */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.skeleton-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.skeleton-line {
  height: 20px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.skeleton-title {
  height: 30px;
  width: 70%;
}

.skeleton-text {
  width: 100%;
}

.skeleton-text.short {
  width: 60%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== Print Styles ===== */
@media print {

  .header,
  .nav-bar,
  .footer,
  .search-container,
  .grammar-controls {
    display: none;
  }

  .section {
    display: block !important;
  }

  .vocab-card,
  .grammar-table {
    break-inside: avoid;
  }
}

/* ===== Kotoba-Style Typing Quiz ===== */
.quiz-input-container {
  display: flex;
  gap: 1rem;
  margin: 2rem 0;
  align-items: stretch;
}

.quiz-input {
  flex: 1;
  padding: 1rem 1.5rem;
  font-size: 1.3rem;
  border: 3px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-family: 'Noto Sans JP', sans-serif;
  transition: var(--transition);
}

.quiz-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.quiz-input:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
}

.quiz-input.correct-input {
  border-color: var(--secondary-color);
  background: rgba(80, 200, 120, 0.1);
}

.quiz-input.incorrect-input {
  border-color: var(--accent-color);
  background: rgba(255, 107, 107, 0.1);
}

.submit-answer-btn {
  padding: 1rem 2rem;
  white-space: nowrap;
}

.quiz-hint {
  background: rgba(74, 144, 226, 0.1);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  border-left: 4px solid var(--primary-color);
}

.hint-text {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0;
}

.quiz-readings-hint {
  text-align: center;
  margin-top: 1rem;
}

.readings-hint-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-style: italic;
}

/* ===== Answer Feedback ===== */
.answer-feedback {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.correct-feedback {
  background: rgba(80, 200, 120, 0.1);
  border: 2px solid var(--secondary-color);
}

.incorrect-feedback {
  background: rgba(255, 107, 107, 0.1);
  border: 2px solid var(--accent-color);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.feedback-icon {
  font-size: 2rem;
}

.feedback-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.feedback-correct-answer {
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.feedback-correct-answer p {
  margin: 0.5rem 0;
}

.correct-readings {
  font-size: 1.1rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--primary-color);
  font-weight: 600;
}

.feedback-explanation {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.feedback-explanation p {
  margin: 0;
  line-height: 1.6;
}


/* ===== Enhanced Vocabulary Cards (Jisho-style) ===== */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem 0;
}

.vocab-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vocab-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.vocab-card-header {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.vocab-card-main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vocab-word {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.vocab-reading {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.vocab-romaji {
  font-size: 1rem;
  color: var(--text-secondary);
  font-style: italic;
}

.vocab-card-meaning {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.5;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* ===== JLPT Level Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-level {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.badge-level[data-level="N5"],
.badge-level:contains("N5") {
  background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
}

.badge-level[data-level="N4"] {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.badge-level[data-level="N3"] {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.badge-level[data-level="N2"] {
  background: linear-gradient(135deg, #ff6a00 0%, #ee0979 100%);
}

.badge-level[data-level="N1"] {
  background: linear-gradient(135deg, #8e2de2 0%, #4a00e0 100%);
}

.badge-common {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.badge-api {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ===== Enhanced Vocabulary Detail Modal ===== */
.vocab-detail {
  max-width: 800px;
  margin: 0 auto;
}

.vocab-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
}

.vocab-detail-header h2 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.vocab-detail-header .badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 2rem;
}

.detail-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.reading-large {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.romaji-large {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-style: italic;
}

.meanings-list {
  list-style: none;
  padding: 0;
}

.meanings-list li {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.meanings-list li:before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

/* ===== Kanji Breakdown ===== */
.kanji-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.kanji-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.kanji-item:hover {
  background: var(--bg-primary);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.kanji-char {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.5rem;
}

.kanji-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kanji-meanings {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  text-align: center;
}

.kanji-reading {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Tags & Related Words ===== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.tag:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.related-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.related-word {
  padding: 0.75rem 1.25rem;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.related-word:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .vocab-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .vocab-word {
    font-size: 1.75rem;
  }

  .vocab-reading {
    font-size: 1.125rem;
  }

  .vocab-detail-header h2 {
    font-size: 2rem;
  }

  .reading-large {
    font-size: 1.5rem;
  }

  .kanji-breakdown {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .kanji-char {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  .vocab-card {
    padding: 1rem;
  }

  .vocab-word {
    font-size: 1.5rem;
  }

  .vocab-detail-header {
    flex-direction: column;
  }

  .kanji-breakdown {
    grid-template-columns: 1fr;
  }
}

/* ===== Modal Enhancements ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-secondary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text-secondary);
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  background: var(--accent-color);
  color: white;
  transform: rotate(90deg);
}

/* Mobile modal full-screen */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    padding: 1.5rem;
    padding-top: 3rem;
  }
}

/* ===== Smooth Transitions ===== */
.vocab-card,
.kanji-item,
.tag,
.related-word,
.modal-overlay,
.modal-content {
  will-change: transform, opacity;
}

/* ===== Accessibility Features ===== */

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: 1000;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Enhanced focus indicators */
*:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
.nav-btn:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

.vocab-card:focus-visible,
.grammar-row:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  border-color: var(--primary-color);
}

.modal-close:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #0056b3;
    --text-primary: #000000;
    --bg-primary: #FFFFFF;
    --border-color: #000000;
  }

  button,
  .nav-btn,
  .vocab-card,
  .grammar-row {
    border: 2px solid currentColor;
  }
}

/* Keyboard navigation indicators */
.vocab-card[tabindex="0"],
.grammar-row[tabindex="0"] {
  cursor: pointer;
}

.vocab-card:focus,
.grammar-row:focus {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* Color-independent status indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.status-indicator::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-correct::before {
  content: '✓';
  width: auto;
  height: auto;
  background: none;
  color: var(--secondary-color);
  font-weight: bold;
}

.status-incorrect::before {
  content: '✗';
  width: auto;
  height: auto;
  background: none;
  color: var(--accent-color);
  font-weight: bold;
}

/* ARIA live region styling */
[aria-live] {
  position: relative;
}

[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

[aria-busy="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Disabled state */
[aria-disabled="true"],
button:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Focus Indicators (Legacy support) */
.vocab-card:focus,
.kanji-item:focus,
.tag:focus,
.related-word:focus,
.modal-close:focus {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* ===== Loading States ===== */
.vocab-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.vocab-card.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* ===================================
   ENHANCED GRAMMAR STYLES
   =================================== */

/* Grammar Filter Section */
.grammar-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.grammar-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.grammar-filter-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
}

#grammar-category-filter {
  padding: 0.5rem;
  border: 1px solid #cbd5e0;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

#grammar-category-filter:hover {
  border-color: #4299e1;
}

#grammar-category-filter:focus {
  outline: none;
  border-color: #4299e1;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Grammar Table Enhancements */
.grammar-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background-color: white;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.grammar-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.grammar-table thead th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grammar-table tbody tr.grammar-row {
  border-bottom: 1px solid #e2e8f0;
  transition: background-color 0.2s;
}

.grammar-table tbody tr.grammar-row:hover {
  background-color: #f7fafc;
}

.grammar-table tbody td {
  padding: 1rem;
  vertical-align: top;
}

/* Grammar Pattern Cell */
.grammar-pattern {
  font-size: 1.125rem;
}

.grammar-pattern strong {
  color: #2d3748;
  font-weight: 700;
}

/* Category Tags */
.category-tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.25rem 0.75rem;
  background-color: #edf2f7;
  color: #4a5568;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* Grammar Level Badges - Enhanced Colors */
.grammar-level .badge-level {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-n5 {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(72, 187, 120, 0.3);
}

.badge-n4 {
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.badge-n3 {
  background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(237, 137, 54, 0.3);
}

.badge-n2 {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(245, 101, 101, 0.3);
}

.badge-n1 {
  background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(159, 122, 234, 0.3);
}

/* Expand Button */
.expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: #4a5568;
  transition: all 0.2s;
  border-radius: 0.375rem;
}

.expand-btn:hover {
  background-color: #edf2f7;
  color: #2d3748;
}

.expand-btn.expanded .expand-icon {
  transform: rotate(180deg);
}

.expand-icon {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 1rem;
}

/* Grammar Detail Row */
.grammar-detail-row {
  background-color: #f7fafc;
  border-bottom: 1px solid #e2e8f0;
}

.grammar-detail-content {
  padding: 1.5rem;
}

.grammar-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.detail-section {
  background-color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  border-left: 4px solid #4299e1;
}

.detail-section h4 {
  margin: 0 0 0.75rem 0;
  color: #2d3748;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-section p {
  margin: 0;
  color: #4a5568;
  line-height: 1.6;
}

.pattern-large {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
}

/* Example Box */
.example-box {
  background-color: #edf2f7;
  padding: 1rem;
  border-radius: 0.375rem;
  border-left: 4px solid #48bb78;
}

.example-jp {
  font-size: 1.125rem;
  color: #2d3748;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.example-en {
  font-size: 0.875rem;
  color: #718096;
  font-style: italic;
}

/* Grammar Statistics */
.grammar-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 150px;
  background: white;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
}

.stat-label {
  font-size: 0.875rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Responsive Design for Grammar */
@media (max-width: 768px) {
  .grammar-filters {
    flex-direction: column;
  }

  .grammar-filter-group {
    width: 100%;
  }

  .grammar-table-wrapper {
    overflow-x: auto;
  }

  .grammar-table {
    font-size: 0.875rem;
  }

  .grammar-table thead th,
  .grammar-table tbody td {
    padding: 0.75rem 0.5rem;
  }

  .grammar-pattern {
    font-size: 1rem;
  }

  .category-tag {
    display: block;
    margin-left: 0;
    margin-top: 0.5rem;
    width: fit-content;
  }

  .detail-section {
    padding: 0.75rem;
  }

  .pattern-large {
    font-size: 1.25rem;
  }
}

/* Loading and Empty States for Grammar */
.grammar-loading {
  text-align: center;
  padding: 3rem;
  color: #718096;
}

.grammar-empty {
  text-align: center;
  padding: 3rem;
  color: #a0aec0;
}

.grammar-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Grammar Search Highlight */
.grammar-highlight {
  background-color: #fef5e7;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-weight: 600;
}

/* ===== Enhanced Responsive Design ===== */

/* Tablet Optimization (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 100%;
    padding: 0 24px;
  }

  .vocab-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quiz-type-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Optimization (max-width: 768px) */
@media (max-width: 768px) {

  /* Typography adjustments */
  body {
    font-size: 14px;
  }

  .logo {
    font-size: 1.25rem;
  }

  .logo-icon {
    font-size: 1.5rem;
  }

  /* Navigation - Stack on mobile */
  .nav-content {
    flex-direction: row;
    justify-content: space-around;
  }

  .nav-btn {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .nav-icon {
    font-size: 1.25rem;
  }

  .nav-label {
    font-size: 0.7rem;
  }

  /* Search boxes - Full width on mobile */
  .search-box {
    width: 100%;
  }

  .search-input {
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 0.75rem 1rem;
  }

  /* Grammar controls - Stack vertically */
  .grammar-controls {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select {
    width: 100%;
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  /* Quiz configuration - Stack vertically */
  .quiz-type-buttons {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .quiz-type-btn {
    padding: 1.5rem;
  }

  .setting-group {
    width: 100%;
  }

  .setting-group select {
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  /* Quiz active - Optimize for mobile */
  .quiz-header {
    flex-direction: column;
    gap: 1rem;
  }

  .quiz-progress {
    width: 100%;
  }

  .question-kanji {
    font-size: 4rem;
  }

  .answer-input {
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 1rem;
  }

  /* Buttons - Full width on mobile */
  .btn-primary,
  .btn-secondary {
    width: 100%;
    padding: 1rem;
  }

  /* Modal - Full screen on mobile */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-body {
    padding: 1rem;
  }

  /* Vocabulary cards - Single column */
  .vocab-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .vocab-card {
    padding: 1rem;
  }

  /* Grammar table - Horizontal scroll */
  .grammar-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .grammar-table {
    min-width: 600px;
  }

  /* Footer - Stack on mobile */
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}

/* Small Mobile Optimization (max-width: 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }

  .section-header h2 {
    font-size: 1.5rem;
  }

  .section-description {
    font-size: 0.875rem;
  }

  .question-kanji {
    font-size: 3rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .vocab-word {
    font-size: 1.5rem;
  }

  .vocab-reading {
    font-size: 1rem;
  }

  .quiz-type-icon {
    font-size: 2rem;
  }

  .quiz-type-label {
    font-size: 1rem;
  }

  /* Reduce padding on small screens */
  .section {
    padding: 1rem 0;
  }

  .quiz-question-container {
    padding: 1rem;
  }

  .results-summary {
    padding: 1.5rem;
  }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {

  /* Increase touch targets */
  .nav-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .vocab-card {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(74, 144, 226, 0.1);
  }

  .expand-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .quiz-type-btn {
    min-height: 60px;
  }

  /* Remove hover effects on touch devices */
  .vocab-card:hover {
    transform: none;
  }

  .nav-btn:hover {
    background: transparent;
  }

  /* Add active states for touch */
  .vocab-card:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  .btn-primary:active,
  .btn-secondary:active {
    transform: scale(0.98);
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .question-kanji {
    font-size: 3rem;
  }

  .quiz-header {
    padding: 0.5rem 0;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

  /* Ensure crisp text rendering */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #E2E8F0;
    --text-secondary: #A0AEC0;
    --bg-primary: #1A202C;
    --bg-secondary: #2D3748;
    --bg-tertiary: #4A5568;
    --border-color: #4A5568;
  }

  body {
    background: var(--bg-secondary);
  }

  .vocab-card,
  .grammar-table,
  .quiz-type-btn,
  .modal-content {
    background: var(--bg-primary);
    color: var(--text-primary);
  }

  .search-input,
  .filter-select,
  .answer-input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
  }
}

/* Print optimization */
@media print {

  .header,
  .nav-bar,
  .footer,
  .search-container,
  .grammar-controls,
  .quiz-config,
  .quiz-header,
  .btn-primary,
  .btn-secondary {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .vocab-card,
  .grammar-table {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .section {
    page-break-before: always;
  }

  .section:first-child {
    page-break-before: avoid;
  }
}


/* ===== Shiritori Game Styles ===== */
.shiritori-game {
  max-width: 900px;
  margin: 0 auto;
}

.shiritori-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

/* Shiritori Menu */
.shiritori-menu {
  text-align: center;
}

.menu-header h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.menu-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.menu-rules {
  text-align: left;
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
}

.menu-rules h3 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.menu-rules ul {
  list-style: none;
  padding: 0;
}

.menu-rules li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.menu-rules li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--secondary-color);
  font-weight: bold;
}

.menu-settings {
  margin-bottom: 2rem;
}

.btn-large {
  padding: 1rem 3rem;
  font-size: 1.2rem;
}

/* Shiritori Game Active */
.shiritori-game-active {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.shiritori-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.shiritori-stats {
  display: flex;
  gap: 2rem;
}

.shiritori-stats .stat-item {
  font-size: 1rem;
  color: var(--text-secondary);
}

.shiritori-stats .stat-item strong {
  color: var(--primary-color);
  font-size: 1.2rem;
}

/* Bot's Word Display */
.shiritori-bot-word {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
}

.bot-label {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 1rem;
}

.word-display {
  margin: 1rem 0;
}

.word-kanji {
  font-size: 3rem;
  font-weight: 700;
  font-family: 'Noto Sans JP', sans-serif;
  margin-bottom: 0.5rem;
}

.word-reading {
  font-size: 1.5rem;
  font-family: 'Noto Sans JP', sans-serif;
  opacity: 0.9;
}

.word-meaning {
  font-size: 1.1rem;
  margin-top: 1rem;
  opacity: 0.95;
}

/* Next Character Hint */
.shiritori-hint {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  text-align: center;
  border: 2px solid var(--primary-color);
}

.hint-label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.hint-character {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: 'Noto Sans JP', sans-serif;
}

/* Shiritori Input */
.shiritori-input-container {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}

.shiritori-input {
  flex: 1;
  padding: 1rem 1.5rem;
  font-size: 1.3rem;
  border: 3px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-family: 'Noto Sans JP', sans-serif;
  transition: var(--transition);
}

.shiritori-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.shiritori-input:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
}

/* Shiritori Feedback */
.shiritori-feedback {
  padding: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideDown 0.3s ease;
}

.shiritori-feedback.success {
  background: rgba(80, 200, 120, 0.1);
  border: 2px solid var(--secondary-color);
  color: var(--secondary-color);
}

.shiritori-feedback.error {
  background: rgba(255, 107, 107, 0.1);
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
}

.feedback-icon {
  font-size: 1.5rem;
}

.feedback-text {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Game History */
.shiritori-history {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
}

.shiritori-history h4 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.history-entry.bot {
  border-left: 4px solid #667eea;
}

.history-entry.user {
  border-left: 4px solid var(--secondary-color);
}

.entry-number {
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 30px;
}

.entry-player {
  font-size: 1.2rem;
}

.entry-word {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.entry-meaning {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.empty-history {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

/* Shiritori Results */
.shiritori-results {
  text-align: center;
}

.shiritori-results .results-header {
  margin-bottom: 2rem;
}

.shiritori-results .results-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.shiritori-results h2 {
  font-size: 2rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.results-message {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.shiritori-results .results-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.shiritori-results .stat-card {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
}

.shiritori-results .stat-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.shiritori-results .stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.shiritori-results .results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* Responsive Shiritori */
@media (max-width: 768px) {
  .shiritori-container {
    padding: 1rem;
  }

  .word-kanji {
    font-size: 2rem;
  }

  .word-reading {
    font-size: 1.2rem;
  }

  .hint-character {
    font-size: 2rem;
  }

  .shiritori-input-container {
    flex-direction: column;
  }

  .shiritori-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .shiritori-results .results-actions {
    flex-direction: column;
  }

  .shiritori-results .results-actions button {
    width: 100%;
  }
}

/* ===== Simplified Shiritori Styles (Matching Website Theme) ===== */

/* Menu */
.shiritori-menu-simple {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.shiritori-intro {
  margin-bottom: 2rem;
}

.shiritori-intro h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.shiritori-intro p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.shiritori-rules-simple {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.rule-item {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 0.5rem;
  border-left: 3px solid var(--primary-color);
  text-align: left;
}

.shiritori-level-select {
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.shiritori-level-select label {
  color: var(--text-primary);
  font-weight: 500;
}

/* Game Active */
.shiritori-game-simple {
  max-width: 700px;
  margin: 0 auto;
}

.shiritori-stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.shiritori-stats-bar .stat {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.shiritori-stats-bar .stat strong {
  color: var(--primary-color);
  font-size: 1.1rem;
  margin-left: 0.25rem;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  transition: color 0.2s;
}

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

/* Word Card */
.shiritori-word-card {
  background: var(--bg-primary);
  border: 2px solid var(--primary-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.word-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.word-main {
  margin-bottom: 1rem;
}

.word-kanji {
  font-size: 2.5rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.word-reading {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.word-meaning {
  color: var(--text-secondary);
  font-size: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Next Character */
.shiritori-next-char {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.next-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.next-char {
  font-size: 2rem;
  color: var(--primary-color);
  font-weight: 600;
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

/* Input Area */
.shiritori-input-area {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.shiritori-input-simple {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.shiritori-input-simple:focus {
  outline: none;
  border-color: var(--primary-color);
}

.shiritori-input-simple:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
}

/* Feedback */
.shiritori-feedback-simple {
  padding: 1rem;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shiritori-feedback-simple.success {
  background: rgba(80, 200, 120, 0.1);
  color: var(--secondary-color);
  border: 1px solid var(--secondary-color);
}

.shiritori-feedback-simple.error {
  background: rgba(255, 107, 107, 0.1);
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
}

/* History */
.shiritori-history-simple {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.history-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.history-list-simple {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}

.history-item.user {
  border-left-color: var(--primary-color);
}

.history-item.bot {
  border-left-color: var(--text-secondary);
}

.history-num {
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-width: 1.5rem;
}

.history-word {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.history-reading {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.empty-history {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
  font-style: italic;
}

/* Results */
.shiritori-results-simple {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.results-title {
  margin-bottom: 2rem;
}

.results-title h3 {
  font-size: 1.8rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.results-msg {
  color: var(--text-secondary);
  font-size: 1rem;
}

.results-stats-simple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
}

.stat-num {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-lbl {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.results-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .shiritori-input-area {
    flex-direction: column;
  }

  .shiritori-stats-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .results-stats-simple {
    grid-template-columns: 1fr;
  }

  .results-buttons {
    flex-direction: column;
  }

  .results-buttons button {
    width: 100%;
  }
}


/* ===================================
   JISHO.ORG STYLE VOCABULARY
   =================================== */

/* Results Header */
.jisho-results-header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

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

.results-count strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Results List */
.jisho-results-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Individual Result Item */
.jisho-result-item {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
  transition: var(--transition);
}

.jisho-result-item:hover {
  background: var(--bg-secondary);
}

.jisho-result-item:first-child {
  padding-top: 0;
}

/* Concept Container */
.jisho-concept {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Concept Header (Word + Tags) */
.jisho-concept-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Word Wrapper */
.jisho-word-wrapper {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex: 1;
}

.jisho-word-link {
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.jisho-word-link:hover {
  color: var(--primary-color);
}

.jisho-word-kanji {
  font-size: 2rem;
  font-weight: 400;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  line-height: 1.2;
  color: var(--text-primary);
}

.jisho-word-reading {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  font-weight: 400;
}

/* Tags Container */
.jisho-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.jisho-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.jisho-tag-jlpt {
  background: #f0f0f0;
  color: #555;
  border: 1px solid #ddd;
}

.jisho-tag-common {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

/* Meanings Wrapper */
.jisho-meanings-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-left: 0.5rem;
}

/* Meaning Group */
.jisho-meaning-group {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.jisho-meaning-number {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
  min-width: 24px;
  padding-top: 0.125rem;
}

.jisho-meaning-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Parts of Speech Tags */
.jisho-pos-tags {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.jisho-pos-tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #f5f5f5;
  color: #666;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* Meaning Text */
.jisho-meaning-text {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Responsive Design for Jisho Style */
@media (max-width: 768px) {
  .jisho-result-item {
    padding: 1.25rem 0;
  }

  .jisho-word-kanji {
    font-size: 1.5rem;
  }

  .jisho-word-reading {
    font-size: 1rem;
  }

  .jisho-word-wrapper {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .jisho-concept-header {
    flex-direction: column;
  }

  .jisho-tags {
    width: 100%;
  }

  .jisho-meanings-wrapper {
    padding-left: 0;
  }
}

@media (max-width: 480px) {
  .jisho-word-kanji {
    font-size: 1.25rem;
  }

  .jisho-word-reading {
    font-size: 0.875rem;
  }

  .jisho-meaning-text {
    font-size: 0.9375rem;
  }
}

/* Enhanced Detail Modal (Jisho Style) */
.vocab-detail {
  max-width: 700px;
}

.vocab-detail-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.vocab-detail-word-section {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.vocab-detail-header h2 {
  font-size: 2.5rem;
  font-weight: 400;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color: var(--text-primary);
  margin: 0;
}

.vocab-detail-header .badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Clean section styling */
.detail-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.detail-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-section h4 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.reading-large {
  font-size: 1.5rem;
  font-weight: 400;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.romaji-large {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-style: normal;
}

/* Meanings List (Jisho Style) */
.meanings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.meanings-list li {
  padding: 0.625rem 0;
  padding-left: 1.75rem;
  position: relative;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  border-bottom: 1px solid var(--bg-secondary);
}

.meanings-list li:last-child {
  border-bottom: none;
}

.meanings-list li:before {
  content: counter(list-item) ".";
  counter-increment: list-item;
  position: absolute;
  left: 0;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
}

/* Kanji Breakdown (Enhanced) */
.kanji-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.kanji-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.kanji-item:hover {
  background: var(--bg-primary);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.kanji-char {
  font-size: 2.5rem;
  font-weight: 400;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1;
}

.kanji-info {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.kanji-meanings {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
}

.kanji-reading {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
}

/* Tags (Jisho Style) */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.375rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.tag:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Related Words */
.related-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.related-word {
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.related-word:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(74, 144, 226, 0.05);
}

/* Welcome Message (Updated) */
.welcome-message {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.8;
}

.welcome-message h3 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.welcome-message p {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

.search-examples {
  margin-top: 2.5rem;
}

.search-examples p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.example-searches {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.example-btn {
  padding: 0.625rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color: var(--text-primary);
}

.example-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Print Styles for Vocabulary */
@media print {
  .jisho-result-item {
    page-break-inside: avoid;
  }

  .jisho-word-link {
    color: var(--text-primary);
    text-decoration: none;
  }

  .jisho-tags,
  .jisho-pos-tags {
    display: none;
  }
}


/* ===== Enhanced Vocabulary Detail Modal Styles ===== */
.vocab-detail .detail-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.vocab-detail .detail-section:last-child {
  border-bottom: none;
}

.vocab-detail .detail-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.vocab-detail .meanings-list {
  list-style: none;
  padding: 0;
}

.vocab-detail .meanings-list li {
  padding: 0.75rem 0;
  font-size: 1.1rem;
  line-height: 1.6;
  display: flex;
  gap: 0.75rem;
}

.vocab-detail .meaning-number {
  color: var(--text-secondary);
  font-weight: 600;
  min-width: 1.5rem;
}

.vocab-detail .kanji-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.vocab-detail .kanji-item {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  text-align: center;
  transition: var(--transition);
}

.vocab-detail .kanji-item:hover {
  background: var(--bg-tertiary);
  transform: translateY(-2px);
}

.vocab-detail .kanji-char {
  font-size: 3rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.vocab-detail .kanji-info {
  text-align: left;
}

.vocab-detail .kanji-meanings {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.vocab-detail .kanji-reading {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.25rem 0;
  font-family: 'Noto Sans JP', sans-serif;
}

.vocab-detail .kanji-reading strong {
  color: var(--text-primary);
  margin-right: 0.25rem;
}

.vocab-detail .kanji-strokes {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-style: italic;
}

.vocab-detail .examples-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.vocab-detail .example-item {
  background: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-color);
}

.vocab-detail .example-jp {
  font-size: 1.15rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.vocab-detail .example-en {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.vocab-detail .tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.vocab-detail .tag {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.vocab-detail .tag:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
}

.vocab-detail .tag-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.vocab-detail .related-words {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.vocab-detail .related-word {
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.vocab-detail .related-word:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.vocab-detail .badge-source {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* Responsive adjustments for detail modal */
@media (max-width: 768px) {
  .vocab-detail .kanji-breakdown {
    grid-template-columns: 1fr;
  }
  
  .vocab-detail .kanji-char {
    font-size: 2.5rem;
  }
  
  .vocab-detail-header h2 {
    font-size: 2rem;
  }
}


/* ===== Enhanced Grammar Card Transitions ===== */
.grammar-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.grammar-card-detail {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.grammar-card.active .grammar-card-detail {
  max-height: 2000px;
  opacity: 1;
}

.grammar-details-link {
  transition: all 0.2s ease;
}

.grammar-card:hover .grammar-details-link {
  color: var(--primary-color);
  transform: translateX(3px);
}

.grammar-card.active .grammar-details-link {
  transform: rotate(90deg);
}

/* Enhanced example formatting */
.example-box-modern {
  border-left: 3px solid var(--primary-color);
  padding-left: 1.5rem;
  background: var(--bg-secondary);
  padding: 1.25rem;
  padding-left: 1.5rem;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
  transition: var(--transition);
}

.example-box-modern:hover {
  background: var(--bg-tertiary);
  border-left-width: 4px;
}

.example-jp {
  font-size: 1.2rem;
  font-family: 'Noto Sans JP', sans-serif;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  line-height: 1.7;
  font-weight: 500;
}

.example-en {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

.detail-block {
  margin-bottom: 1.5rem;
}

.detail-block.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.detail-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* Grammar filter transitions */
.grammar-list-wrapper {
  animation: fadeIn 0.3s ease;
}

.grammar-card {
  animation: slideUpFade 0.4s ease forwards;
  animation-delay: calc(var(--index, 0) * 0.05s);
}

/* Add staggered animation */
.grammar-card:nth-child(1) { --index: 0; }
.grammar-card:nth-child(2) { --index: 1; }
.grammar-card:nth-child(3) { --index: 2; }
.grammar-card:nth-child(4) { --index: 3; }
.grammar-card:nth-child(5) { --index: 4; }
.grammar-card:nth-child(6) { --index: 5; }
.grammar-card:nth-child(7) { --index: 6; }
.grammar-card:nth-child(8) { --index: 7; }
.grammar-card:nth-child(9) { --index: 8; }
.grammar-card:nth-child(10) { --index: 9; }


/* ===== Quiz Feedback Actions (Manual Progression) ===== */
.feedback-actions {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 200px;
}

.answer-feedback {
  margin-top: 2rem;
  padding: 2rem;
  border-radius: var(--radius-lg);
  animation: fadeIn 0.3s ease;
}

.answer-feedback.correct-feedback {
  background: rgba(76, 175, 80, 0.1);
  border: 2px solid #4CAF50;
}

.answer-feedback.incorrect-feedback {
  background: rgba(244, 67, 54, 0.1);
  border: 2px solid #F44336;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.feedback-icon {
  font-size: 2.5rem;
}

.feedback-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.feedback-correct-answer {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
}

.feedback-correct-answer p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.feedback-correct-answer strong {
  color: var(--text-primary);
  font-weight: 600;
}

.correct-readings {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-top: 0.5rem;
}

.feedback-explanation {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.feedback-explanation p {
  line-height: 1.7;
  color: var(--text-primary);
}

.quiz-input.correct-input {
  border-color: #4CAF50;
  background: rgba(76, 175, 80, 0.05);
}

.quiz-input.incorrect-input {
  border-color: #F44336;
  background: rgba(244, 67, 54, 0.05);
}

/* Quiz hint styling */
.quiz-hint {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  text-align: center;
}

.hint-text {
  color: var(--text-secondary);
  font-size: 1rem;
}

.quiz-readings-hint {
  margin-top: 1rem;
  text-align: center;
}

.readings-hint-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Enhanced Animations and Transitions ===== */

/* Smooth fade-in for content */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth scale animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Smooth bounce for buttons */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Enhanced card hover effects */
.jisho-result-item,
.grammar-card,
.quiz-type-btn,
.example-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.jisho-result-item:hover,
.grammar-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.quiz-type-btn:hover,
.example-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Button press effect */
.btn-primary:active,
.btn-secondary:active,
.quiz-type-btn:active {
  transform: scale(0.98);
}

/* Loading state animations */
.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Smooth expand/collapse for grammar cards */
.grammar-card.active .grammar-card-detail {
  animation: fadeInUp 0.4s ease;
}

/* Staggered animation for list items */
.jisho-result-item {
  animation: fadeInUp 0.4s ease;
  animation-fill-mode: both;
}

.jisho-result-item:nth-child(1) { animation-delay: 0.05s; }
.jisho-result-item:nth-child(2) { animation-delay: 0.1s; }
.jisho-result-item:nth-child(3) { animation-delay: 0.15s; }
.jisho-result-item:nth-child(4) { animation-delay: 0.2s; }
.jisho-result-item:nth-child(5) { animation-delay: 0.25s; }

/* Grammar card staggered animation */
.grammar-card {
  animation: fadeInUp 0.4s ease;
  animation-fill-mode: both;
}

.grammar-card:nth-child(1) { animation-delay: 0.05s; }
.grammar-card:nth-child(2) { animation-delay: 0.1s; }
.grammar-card:nth-child(3) { animation-delay: 0.15s; }
.grammar-card:nth-child(4) { animation-delay: 0.2s; }
.grammar-card:nth-child(5) { animation-delay: 0.25s; }

/* Smooth modal animations */
.modal-overlay {
  animation: fadeIn 0.2s ease;
}

.modal-content {
  animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced feedback animations */
.answer-feedback {
  animation: fadeInUp 0.4s ease;
}

.feedback-icon {
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Progress bar smooth transition */
.progress-fill {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth filter transitions */
.filter-select,
.search-input {
  transition: all 0.2s ease;
}

.filter-select:focus,
.search-input:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Loading spinner enhancement */
@keyframes spinEnhanced {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  animation: spinEnhanced 0.8s linear infinite;
}

/* Notification slide animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.notification {
  animation: slideInRight 0.3s ease;
}

.notification.notification-exit {
  animation: slideOutRight 0.3s ease;
}

/* Smooth tab transitions */
.nav-btn {
  position: relative;
  overflow: hidden;
}

.nav-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: var(--primary-color);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.nav-btn.active::after {
  width: 100%;
}

/* Enhanced hover states for links */
.jisho-word-link,
.jisho-details-link,
.grammar-details-link {
  position: relative;
  transition: all 0.2s ease;
}

.jisho-word-link:hover,
.jisho-details-link:hover,
.grammar-details-link:hover {
  transform: translateX(2px);
}

/* Smooth badge animations */
.jisho-tag,
.badge {
  transition: all 0.2s ease;
}

.jisho-tag:hover,
.badge:hover {
  transform: scale(1.05);
}

/* Enhanced input focus states */
.quiz-input,
.search-input,
.shiritori-input {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-input:focus,
.search-input:focus,
.shiritori-input:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Smooth score circle animation */
.score-circle {
  animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Enhanced card expansion */
.grammar-card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.grammar-card.active .grammar-card-detail {
  max-height: 1000px;
}

/* Smooth opacity transitions for dynamic content */
.fade-transition {
  transition: opacity 0.3s ease;
}

.fade-transition.fade-out {
  opacity: 0;
}

.fade-transition.fade-in {
  opacity: 1;
}

/* Enhanced button ripple effect */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.btn-primary,
.btn-secondary {
  position: relative;
  overflow: hidden;
}

.btn-primary::before,
.btn-secondary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before,
.btn-secondary:active::before {
  width: 300px;
  height: 300px;
}

/* Smooth skeleton loading */
@keyframes shimmerEnhanced {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-loader {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--border-color) 50%,
    var(--bg-tertiary) 100%
  );
  background-size: 200% 100%;
  animation: shimmerEnhanced 1.5s ease-in-out infinite;
}

/* Enhanced quiz question transitions */
.quiz-question {
  animation: fadeInUp 0.5s ease;
}

.question-kanji {
  animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Smooth history entry animations */
.history-entry {
  animation: fadeInUp 0.3s ease;
  animation-fill-mode: both;
}

.history-entry:nth-child(1) { animation-delay: 0.05s; }
.history-entry:nth-child(2) { animation-delay: 0.1s; }
.history-entry:nth-child(3) { animation-delay: 0.15s; }
.history-entry:nth-child(4) { animation-delay: 0.2s; }
.history-entry:nth-child(5) { animation-delay: 0.25s; }

/* Enhanced accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Enhanced focus visible for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Remove default focus outline */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ===== Accessibility Enhancements ===== */

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 4px 0;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-secondary: #1a1a1a;
    --bg-primary: #ffffff;
    --border-color: #000000;
  }

  .btn-primary,
  .btn-secondary {
    border: 2px solid currentColor;
  }

  .jisho-result-item,
  .grammar-card {
    border: 2px solid var(--border-color);
  }
}

/* Focus indicators for better keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.jisho-result-item:focus-visible,
.grammar-card:focus-visible,
.quiz-type-btn:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Ensure sufficient color contrast for text */
.text-muted,
.text-secondary {
  color: #4a5568; /* WCAG AA compliant */
}

/* Enhanced button contrast */
.btn-primary {
  background: #2563eb; /* Darker blue for better contrast */
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* Ensure links have sufficient contrast */
a {
  color: #2563eb;
}

a:hover {
  color: #1d4ed8;
}

a:visited {
  color: #7c3aed;
}

/* Error and success states with good contrast */
.error-message,
.incorrect-feedback {
  color: #dc2626; /* WCAG AA compliant red */
}

.success-message,
.correct-feedback {
  color: #059669; /* WCAG AA compliant green */
}

/* Ensure form inputs have visible borders */
input,
select,
textarea {
  border: 1px solid #d1d5db;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Disabled state with clear visual indication */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f3f4f6;
}

/* Loading state accessibility */
[aria-busy="true"] {
  cursor: wait;
}

/* Ensure modals are properly announced */
.modal-overlay[role="dialog"] {
  /* Already has proper ARIA attributes */
}

/* Keyboard-only focus (not mouse) */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* Touch target size for mobile accessibility */
@media (max-width: 768px) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"],
  .nav-btn,
  .quiz-type-btn {
    min-height: 44px; /* WCAG 2.1 Level AAA */
    min-width: 44px;
  }
}

/* Ensure sufficient spacing for readability */
p,
li {
  line-height: 1.6; /* WCAG recommendation */
}

/* Heading hierarchy visual distinction */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.125rem; font-weight: 600; }

/* Ensure tables are accessible */
table {
  border-collapse: collapse;
}

th {
  text-align: left;
  font-weight: 600;
}

/* Status indicators with icons and text */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Ensure proper contrast for badges */
.badge,
.jisho-tag {
  background: #e5e7eb;
  color: #1f2937;
  border: 1px solid #d1d5db;
}

.badge-primary,
.jisho-tag-jlpt {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.badge-success,
.jisho-tag-common {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

/* Ensure progress indicators are accessible */
.progress-bar {
  background: #e5e7eb;
}

.progress-fill {
  background: var(--primary-color);
}

/* Add role and aria-label to progress bars */
.progress-bar[role="progressbar"] {
  /* Ensure aria-valuenow, aria-valuemin, aria-valuemax are set in JS */
}

/* Ensure tooltips are accessible */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem;
  background: #1f2937;
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 1000;
}

/* Ensure proper focus order */
[tabindex="-1"]:focus {
  outline: none;
}

/* Announce dynamic content changes */
[aria-live="polite"],
[aria-live="assertive"] {
  /* Screen readers will announce changes */
}

/* ===== Additional Mobile Responsiveness Enhancements ===== */

/* Improve touch interactions */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .jisho-result-item:hover,
  .grammar-card:hover,
  .quiz-type-btn:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  /* Increase tap target sizes */
  button,
  a,
  .nav-btn,
  .quiz-type-btn,
  .jisho-word-link {
    min-height: 48px;
    min-width: 48px;
    padding: 0.75rem 1rem;
  }

  /* Improve input field sizes */
  input,
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 48px;
  }
}

/* Optimize for very small screens */
@media (max-width: 360px) {
  .container {
    padding: 0 8px;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  .jisho-word-main {
    font-size: 1.25rem;
  }

  .grammar-pattern-text {
    font-size: 1rem;
  }

  .btn-primary,
  .btn-secondary {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
}

/* Optimize for tablets in portrait */
@media (min-width: 481px) and (max-width: 768px) {
  .jisho-results-list {
    padding: 0 1rem;
  }

  .grammar-list {
    padding: 0 1rem;
  }

  .quiz-question {
    padding: 1.5rem;
  }
}

/* Optimize for tablets in landscape */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
  .container {
    max-width: 90%;
  }

  .jisho-entry-grid {
    grid-template-columns: 300px 1fr;
  }

  .grammar-card {
    grid-template-columns: 250px 1fr;
  }
}

/* Improve scrolling on mobile */
@media (max-width: 768px) {
  body {
    -webkit-overflow-scrolling: touch;
  }

  .modal-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }

  /* Prevent horizontal scroll */
  body,
  html {
    overflow-x: hidden;
  }

  /* Optimize search input for mobile */
  .search-input-group {
    flex-wrap: wrap;
  }

  .jisho-main-input {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* Stack filters vertically on mobile */
  .grammar-controls-toolbar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .filter-select {
    width: 100%;
  }

  /* Improve quiz layout on mobile */
  .quiz-input-container {
    flex-direction: column;
    gap: 0.75rem;
  }

  .quiz-input {
    width: 100%;
  }

  .submit-answer-btn {
    width: 100%;
  }

  /* Optimize results display */
  .results-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Improve shiritori game on mobile */
  .shiritori-input-container {
    flex-direction: column;
    gap: 0.75rem;
  }

  .shiritori-input {
    width: 100%;
  }

  /* Optimize navigation for mobile */
  .nav-content {
    justify-content: space-around;
    gap: 0.25rem;
  }

  .nav-btn {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 0.5rem;
  }

  .nav-label {
    font-size: 0.875rem;
  }

  /* Improve modal on mobile */
  .modal-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
  }

  .modal-close {
    top: 0.5rem;
    right: 0.5rem;
  }

  /* Optimize card spacing */
  .jisho-result-item,
  .grammar-card {
    margin-bottom: 0.75rem;
  }

  /* Improve badge display */
  .jisho-tags-row {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .jisho-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Optimize for landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .header {
    padding: 0.75rem 0;
  }

  .nav-bar {
    padding: 0.5rem 0;
  }

  .section-header {
    margin-bottom: 1rem;
  }

  .question-kanji {
    font-size: 2.5rem;
  }

  .modal-content {
    max-height: 85vh;
  }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .header,
  .nav-bar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .modal-content {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* Prevent text size adjustment on orientation change */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
}

/* Optimize images for mobile */
@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
  }
}

/* Improve table responsiveness */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Print styles */
@media print {
  .header,
  .nav-bar,
  .search-container,
  .grammar-controls-toolbar,
  button,
  .modal-overlay {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .jisho-result-item,
  .grammar-card {
    page-break-inside: avoid;
    border: 1px solid #000;
    margin-bottom: 1rem;
  }
}
