/**
 * Serene Word Search - Core Layout & Component Styles
 * Built for clarity, frictionless interaction, and smooth iPad touch ergonomics.
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* App Wrapper */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-color: var(--bg-app);
}

/* Top App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 1.6rem;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-nav:hover, .btn-nav:focus-visible {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-nav.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
}

.btn-icon-only {
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  font-size: 1.2rem;
}

/* Main Content Area */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Screen Transitions */
.screen-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screen-view.active {
  display: flex;
  flex-direction: column;
}

/* Gameplay Layout */
.play-layout {
  display: flex;
  height: 100%;
  padding: 16px 20px;
  gap: 20px;
}

/* Left Board Section */
.board-section {
  flex: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.board-header-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.board-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.board-main-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
}

.board-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-subtle);
}

.btn-action:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-action.btn-hint {
  background-color: #FFF8E1;
  border-color: #FFE082;
  color: #B78103;
}

.btn-action.btn-hint:hover {
  background-color: #FFECB3;
}

/* Board Container & Grid */
.board-wrapper {
  position: relative;
  width: 100%;
  max-width: 580px;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 10px;
  touch-action: none;
}

.board-canvas {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  pointer-events: none;
  z-index: 10;
}

.board-grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 3px;
  z-index: 5;
}

.grid-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--cell-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.cell-letter {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--cell-text);
  line-height: 1;
}

/* Tap mode start indicator */
.grid-cell.tap-start-active {
  background-color: var(--accent-light);
  outline: 3px solid var(--accent-primary);
  transform: scale(1.08);
  z-index: 12;
}

/* Hint letter pulse */
@keyframes hintGlow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 179, 0, 0.9);
    background-color: #FFE082;
    border-color: #FF8F00;
  }
  50% {
    transform: scale(1.22);
    box-shadow: 0 0 0 10px rgba(255, 179, 0, 0), 0 0 16px rgba(255, 179, 0, 0.8);
    background-color: #FFF9C4;
    border-color: #FF6F00;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 179, 0, 0);
    background-color: #FFE082;
    border-color: #FF8F00;
  }
}

.grid-cell.hint-pulse,
.grid-cell.hint-active {
  animation: hintGlow 1.2s infinite ease-in-out !important;
  z-index: 25 !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 900 !important;
  color: #B78103 !important;
  border: 2px solid #FFA000 !important;
}

/* Right Word Bank Section */
.words-section {
  flex: 0.95;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  min-width: 280px;
  overflow: hidden;
}

.words-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.words-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.progress-counter {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-primary);
  background-color: var(--accent-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.word-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Word Cards in Bank */
.word-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.word-card-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.word-main {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-main);
}

.word-trans {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-word-listen {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  transition: transform 0.1s ease;
}

.btn-word-listen:active {
  transform: scale(1.2);
}

.word-check {
  font-size: 1.1rem;
  font-weight: 800;
  color: #2E7D32;
  width: 20px;
  text-align: right;
}

/* Found Word Styling */
.word-card.found {
  background-color: var(--card-found-bg);
  border-color: transparent;
  opacity: 0.65;
}

.word-card.found .word-main {
  text-decoration: line-through;
  color: var(--card-found-text);
}

.word-card.found .word-trans {
  color: var(--card-found-text);
}

@keyframes cardJustFound {
  0% { transform: scale(1); background-color: #E8F5E9; }
  50% { transform: scale(1.04); background-color: #C8E6C9; }
  100% { transform: scale(1); }
}

.word-card.just-found {
  animation: cardJustFound 0.8s ease-in-out;
}

.word-card.hint-target {
  outline: 2px solid #FFB300;
  background-color: #FFF8E1;
}

/* Bilingual Learning Toast Notification */
.bilingual-toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background-color: var(--bg-surface);
  border: 2px solid var(--accent-primary);
  box-shadow: var(--shadow-modal);
  border-radius: var(--radius-lg);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
}

.bilingual-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

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

.toast-content {
  display: flex;
  flex-direction: column;
}

.toast-word-pair {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.toast-id {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.toast-en {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

.toast-note {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 900;
  display: none;
}

.modal-backdrop.active {
  display: block;
}

.app-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 650px;
  max-height: 88vh;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
  overflow: hidden;
}

.app-modal.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Category Packs Screen */
.packs-screen-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

.packs-nav-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.pack-tab-btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.pack-tab-btn.active {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.packs-grid-scroll {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding-bottom: 20px;
}

.pack-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  cursor: pointer;
  transition: var(--transition-fast);
}

.pack-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-card);
}

.pack-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.pack-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.pack-subtitle {
  font-size: 0.88rem;
  color: var(--accent-primary);
  font-weight: 600;
  margin-bottom: 6px;
}

.pack-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex: 1;
}

.pack-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

.btn-play-pack {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: none;
  background-color: var(--accent-primary);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-play-pack:hover {
  background-color: var(--accent-hover);
}

/* Daily Challenge Hero */
.daily-screen-container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.daily-hero-card {
  max-width: 540px;
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.daily-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-primary);
  background-color: var(--accent-light);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.daily-date-heading {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
}

.daily-hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
}

.daily-stats-row {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
  margin: 10px 0;
}

.streak-badge {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  background-color: var(--bg-surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.streak-number {
  font-size: 1.3rem;
  font-weight: 800;
}

.streak-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-primary-large {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  background-color: var(--accent-primary);
  color: #FFFFFF;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-card);
}

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

/* Wordbook UI Components */
.wordbook-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.wordbook-stats-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background-color: var(--accent-light);
  border-radius: var(--radius-md);
}

.wordbook-trophy {
  font-size: 2.2rem;
}

.wordbook-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-primary);
}

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

.wordbook-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.95rem;
}

.wordbook-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.cat-pill.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
}

.wordbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
}

.wordbook-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.wordbook-id-word {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.wordbook-en-word {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.wordbook-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.wordbook-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.btn-speak-word {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-speak-word.speaking {
  background-color: #E8F5E9;
  border-color: #4CAF50;
}

.wordbook-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Settings Form Controls */
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.setting-label {
  font-weight: 600;
  font-size: 1rem;
}

.setting-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.theme-selector-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-theme-choice {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-theme-choice.active {
  border-color: var(--accent-primary);
  background-color: var(--accent-light);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #CCC;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

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

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Custom Puzzle Textarea */
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.95rem;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Victory Screen Details */
.victory-modal-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.victory-icon {
  font-size: 3.5rem;
}

.victory-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
}

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

.victory-words-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  margin: 10px 0;
}

.victory-word-pill {
  padding: 6px 12px;
  background-color: var(--accent-light);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
}

.victory-w-main {
  color: var(--accent-primary);
  font-weight: 700;
}

.victory-w-en {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1500;
}

/* =======================================================
   ACCOMPLISHMENTS & COMPLETION INDICATOR STYLES
   ======================================================= */

/* Completed Pack Card Indicator */
.pack-card.completed {
  border-color: #81C784;
  position: relative;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-alt) 100%);
}

.pack-completed-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  background-color: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-subtle);
}

.pack-completed-badge .completion-times {
  color: #1B5E20;
  font-size: 0.72rem;
  font-weight: 600;
}

.btn-play-pack.btn-replay {
  background-color: var(--bg-surface-alt);
  color: var(--accent-primary);
  border: 1.5px solid var(--accent-primary);
}

.btn-play-pack.btn-replay:hover {
  background-color: var(--accent-light);
}

/* Victory Modal Accomplishment Badge */
.victory-stat-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.95rem;
}

/* Accomplishments Dashboard UI */
.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-hero-card {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-surface-alt) 100%);
  border: 1.5px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-card);
}

.mastery-rank-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mastery-rank-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.mastery-rank-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 480px;
}

/* Stats Cards Grid */
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.stat-card {
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

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

/* Progress Bar */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Section Title */
.dashboard-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.dashboard-section-title h4 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
}

.badge-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  background-color: var(--accent-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Milestones Grid */
.milestones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.milestone-badge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  transition: var(--transition-fast);
}

.milestone-badge-card.unlocked {
  background-color: #F1F8E9;
  border-color: #C5E1A5;
}

.milestone-badge-card.locked {
  opacity: 0.55;
  filter: grayscale(0.8);
}

.milestone-icon {
  font-size: 1.8rem;
}

.milestone-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.milestone-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.milestone-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.milestone-status {
  font-size: 1.1rem;
}

/* Completed History Showcase */
.completed-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.completed-history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.completed-theme-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.completed-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-replay-history {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-replay-history:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* =======================================================
   ANIMATED & EMOJI-RICH HOW-TO GUIDE STYLES
   ======================================================= */

.guide-animated-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 22px;
}

/* Hero Banner */
.anim-hero-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-surface-alt) 100%);
  border: 1.5px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-subtle);
}

.floating-emoji {
  font-size: 2.2rem;
  animation: floatBounce 2.5s infinite ease-in-out;
}

@keyframes floatBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.08); }
}

.anim-hero-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-primary);
  margin-bottom: 2px;
}

.anim-hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.4;
}

/* Animated Guide Card */
.anim-guide-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-surface-alt);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.anim-guide-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.anim-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background-color: var(--accent-light);
  color: var(--accent-primary);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.step-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-desc {
  font-size: 0.94rem;
  color: var(--text-main);
  line-height: 1.5;
}

.step-tip-pill {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.4;
}

/* Step 1 Animated Demo: Finger Sliding */
.anim-demo-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px dashed var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin: 4px 0;
  overflow: hidden;
}

.demo-letter-cell {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--cell-bg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.demo-letter-cell.active-1 { animation: demoGlow 3.5s infinite ease-in-out; animation-delay: 0.4s; }
.demo-letter-cell.active-2 { animation: demoGlow 3.5s infinite ease-in-out; animation-delay: 0.8s; }
.demo-letter-cell.active-3 { animation: demoGlow 3.5s infinite ease-in-out; animation-delay: 1.2s; }
.demo-letter-cell.active-4 { animation: demoGlow 3.5s infinite ease-in-out; animation-delay: 1.6s; }

@keyframes demoGlow {
  0%, 15% { background-color: var(--cell-bg); transform: scale(1); }
  25%, 70% { background-color: #FFE082; color: #8C532B; transform: scale(1.08); box-shadow: 0 0 8px rgba(255, 193, 7, 0.4); }
  85%, 100% { background-color: var(--cell-bg); transform: scale(1); }
}

.sliding-finger-emoji {
  position: absolute;
  font-size: 1.8rem;
  bottom: 6px;
  left: 28%;
  pointer-events: none;
  animation: slideFinger 3.5s infinite ease-in-out;
}

@keyframes slideFinger {
  0% { left: 24%; transform: translateY(0); opacity: 0; }
  15% { left: 24%; transform: translateY(-4px); opacity: 1; }
  60% { left: 68%; transform: translateY(-4px); opacity: 1; }
  75% { left: 68%; transform: translateY(4px); opacity: 0; }
  100% { left: 24%; transform: translateY(0); opacity: 0; }
}

/* Step 2 Animated Demo: Speech Bubble */
.anim-speech-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: var(--bg-surface);
  border: 1px solid #C8E6C9;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin: 4px 0;
}

.speech-speaker-icon {
  font-size: 1.8rem;
  animation: pulseScale 2s infinite ease-in-out;
}

.speech-bubble-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #E8F5E9;
  border: 1px solid #A5D6A7;
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.speech-id-text {
  font-weight: 800;
  color: #2E7D32;
  font-size: 1rem;
}

.speech-arrow {
  color: #81C784;
  font-weight: 700;
}

.speech-en-text {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.92rem;
}

.sound-wave-emoji {
  font-size: 1.2rem;
  animation: soundPulse 1.8s infinite ease-in-out;
}

@keyframes soundPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Step 3 Animated Demo: Glowing Hint Cell */
.anim-hint-demo {
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: var(--bg-surface);
  border: 1px solid #FFE082;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin: 4px 0;
}

.hint-glow-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 44px;
  height: 44px;
  background-color: #FFF9C4;
  border: 2px solid #FBC02D;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 1.25rem;
  color: #B78103;
  animation: hintCellGlow 2s infinite ease-in-out;
}

@keyframes hintCellGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 193, 7, 0.4); }
  50% { transform: scale(1.12); box-shadow: 0 0 12px rgba(255, 193, 7, 0.8); background-color: #FFF59D; }
}

.hint-sparkle-left, .hint-sparkle-right {
  font-size: 0.8rem;
  animation: sparkleTwinkle 1.5s infinite alternate;
}

@keyframes sparkleTwinkle {
  0% { transform: scale(0.6) rotate(0deg); opacity: 0.4; }
  100% { transform: scale(1.2) rotate(25deg); opacity: 1; }
}

.hint-action-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Step 4 Feature Chips */
.anim-icons-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 4px 0;
}

.feature-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  transition: transform 0.15s ease;
}

.feature-chip:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
}

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

/* =======================================================
   CROSS-DEVICE HAVEN SYNC STYLES
   ======================================================= */

/* Navigation Sync Dot */
.sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 2px;
  background-color: #4CAF50;
  transition: background-color 0.3s ease;
}

.sync-dot.synced {
  background-color: #4CAF50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.sync-dot.syncing {
  background-color: #2196F3;
  animation: syncPulse 1s infinite alternate;
}

.sync-dot.offline {
  background-color: #FFC107;
}

.sync-dot.error {
  background-color: #F44336;
}

@keyframes syncPulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 8px #2196F3; }
}

/* Sync Modal Body */
.sync-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px;
}

/* Sync Status Banner */
.sync-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-surface-alt) 100%);
  border: 1.5px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pulse-dot {
  font-size: 1.6rem;
}

.sync-status-heading {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.sync-status-subtext {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Haven Key Showcase Card */
.sync-key-card {
  background-color: var(--bg-surface-alt);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sync-key-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sync-key-display-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-key-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-primary);
  letter-spacing: 0.06em;
  background-color: var(--bg-surface);
  padding: 4px 16px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--accent-primary);
}

.btn-copy-key {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-copy-key:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.sync-key-instruction {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.45;
}

/* Pairing Grid: 2 Columns */
.sync-pairing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.sync-pairing-card {
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.pairing-card-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.pairing-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.qr-canvas-container {
  padding: 10px;
  background-color: #FAF7EE;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  margin: 4px 0;
}

.sync-qr-canvas {
  display: block;
  width: 160px;
  height: 160px;
  border-radius: var(--radius-sm);
}

.btn-secondary-action {
  width: 100%;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary-action:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Input Group for manual linking */
.sync-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.sync-key-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.05em;
}

.sync-feedback-msg {
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 18px;
}

.pairing-devices-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.device-chip {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-full);
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px 10px;
  text-decoration: underline;
  transition: color 0.2s ease;
}

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




