/* Free The Fish Simulator (放生模擬器) - Modern 2D Cartoon Style */

:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --accent-color: #f59e0b;
  --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
  --panel-bg: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(255, 255, 255, 0.7);
  --text-dark: #1e293b;
  --text-muted: #475569;
  --shadow-lg: 0 10px 25px -5px rgba(14, 165, 233, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --font-family: 'Fredoka', 'Noto Sans TC', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  position: relative;
}

/* Header Bar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  font-size: 1.8rem;
  animation: floatBounce 3s ease-in-out infinite;
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(90deg, #0284c7, #0d9488);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #cbd5e1;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.sound-only-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
}

.icon-btn:hover, .icon-btn:active {
  transform: translateY(-1px);
  background: #ffffff;
  border-color: var(--primary-color);
}

.lang-select {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #cbd5e1;
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

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

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  width: 100%;
  position: relative;
}

.step-screen {
  display: none;
  width: 100%;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.step-screen.active {
  display: flex;
  justify-content: center;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: none;
  border-bottom: 2px solid var(--panel-border);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  position: relative;
}

.wide-card {
  width: 100%;
}

.step-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.step-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.step-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Step 1: Scenes Grid & 2-Line Scene Titles */
.scenes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.scene-card {
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  min-height: 125px;
}

.scene-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: #38bdf8;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.25);
}

.scene-card.selected {
  border-color: var(--primary-color);
  background: #f0f9ff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.scene-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary-color);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.scene-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.flag-svg {
  width: 52px;
  height: 35px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  display: block;
  transition: transform 0.2s ease;
}

.scene-card:hover .flag-svg {
  transform: scale(1.08);
}

#currentSceneIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#currentSceneIcon .flag-svg {
  width: 26px;
  height: 18px;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.scene-name-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.scene-main-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.scene-sub-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Step 2: Animal Grid & Counter/Reset/Random */
.step-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.counter-and-reset {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-outline-sm {
  background: #ffffff;
  border: 1.5px solid #ef4444;
  color: #dc2626;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline-sm:hover {
  background: #fef2f2;
  transform: translateY(-1px);
}

.btn-random {
  border-color: #8b5cf6;
  color: #7c3aed;
}

.btn-random:hover {
  background: #f5f3ff;
}

.selection-counter-badge {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #b45309;
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 50px;
}

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 4px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
}

.cat-tab {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.8);
  border: 1.5px solid #cbd5e1;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-tab.active {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.animals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 440px;
  overflow-y: auto;
  padding: 8px 8px 8px 4px;
  margin-bottom: 20px;
}

.animal-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.animal-card:hover {
  transform: translateY(-4px);
  border-color: #38bdf8;
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
  z-index: 10;
}

.animal-card.selected {
  border-color: var(--success-color);
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.animal-card.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--success-color);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.animal-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.animal-mini-canvas {
  width: 54px;
  height: 54px;
  display: block;
  margin: 0 auto;
}

.animal-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
  word-break: break-word;
}

.animal-cat-badge {
  font-size: 0.7rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Step 3: Preparation Scene Bucket Layout (4 - 4 - 2 Rows) */
.bucket-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px 0 24px;
}

.bucket-body {
  width: 240px;
  height: 170px;
  background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
  border-radius: 10px 10px 40px 40px;
  position: relative;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  border: 4px solid #475569;
  overflow: hidden;
  padding-top: 6px;
}

.bucket-water {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  border-radius: 0 0 30px 30px;
  position: relative;
  overflow: hidden;
}

.bucket-animals-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  padding: 6px;
}

.bucket-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.bucket-animal-canvas {
  width: 36px;
  height: 36px;
  display: inline-block;
  animation: floatSwim 2s ease-in-out infinite alternate;
}

.selected-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.summary-chip {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.blessing-box {
  background: #fffbebf5;
  border: 2px dashed #f59e0b;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blessing-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: #92400e;
}

.blessing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blessing-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 2px solid #fde68a;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.blessing-option:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}

.blessing-option.selected {
  border-color: #d97706;
  background: #fef3c7;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.blessing-option input[type="radio"] {
  accent-color: #d97706;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.blessing-text {
  font-size: 0.9rem;
  color: #78350f;
  line-height: 1.3;
}

/* Step 4: Simulation View */
.simulation-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.simulation-view {
  width: 100%;
  height: calc(100vh - 110px);
  min-height: 500px;
  position: relative;
  background: #0284c7;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: none;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

#simCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.sim-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.location-badge, .merit-badge {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}

.merit-badge {
  background: rgba(254, 243, 199, 0.95);
  color: #92400e;
  border: 2px solid #f59e0b;
}

.hud-bottom-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  pointer-events: auto;
  margin-bottom: 8px;
}

.blessing-banner {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  padding: 8px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0369a1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  border: 2px solid #38bdf8;
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.4s ease;
  text-align: center;
  max-width: 90%;
}

.blessing-banner.active {
  opacity: 1;
  transform: translateY(0);
}

.sim-tips {
  background: rgba(15, 23, 42, 0.7);
  color: #f1f5f9;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 30px;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.hud-bottom {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-dark);
  border: 2px solid #cbd5e1;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
}

.btn-action {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.4);
}

/* "重新放生" Button Pink Background Theme */
.btn-restart {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(219, 39, 119, 0.4);
}

.btn-restart:hover {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  box-shadow: 0 8px 20px rgba(225, 29, 72, 0.45);
}

.btn-large {
  padding: 14px 32px;
  font-size: 1.1rem;
}

.btn.disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-pulse {
  animation: pulseGlow 2s infinite;
}

.step-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.split-actions {
  justify-content: space-between;
}

/* Auto Feed Toggle Switch */
.auto-feed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 8px 18px;
  border-radius: 50px;
  border: 2px solid #cbd5e1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
  user-select: none;
}

.auto-feed-toggle:hover {
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.auto-feed-toggle input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  width: 38px;
  height: 22px;
  background-color: #cbd5e1;
  border-radius: 20px;
  position: relative;
  transition: background-color 0.25s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.auto-feed-toggle input:checked + .toggle-slider {
  background-color: #10b981;
}

.auto-feed-toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

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

/* Website Description Card (Intro Before Footer) */
.app-intro-card {
  margin: 20px auto 4px;
  width: calc(100% - 32px);
  max-width: 1100px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.08);
  text-align: center;
}

.app-intro-card p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #334155;
  font-weight: 500;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Keyframes & Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(-5deg); }
}

@keyframes floatSwim {
  0% { transform: translateY(0) rotate(-5deg); }
  100% { transform: translateY(-8px) rotate(5deg); }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Responsive Rules */
@media (max-width: 640px) {
  .app-header {
    padding: 10px 14px;
  }
  .logo-title {
    font-size: 1.1rem;
  }
  .glass-panel {
    padding: 16px 14px;
  }
  .step-title {
    font-size: 1.3rem;
  }
  .scenes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .scene-main-title {
    font-size: 1.1rem;
  }
  .scene-sub-title {
    font-size: 0.75rem;
  }
  .animals-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 380px;
    padding: 6px 4px;
  }
  .animal-name {
    font-size: 0.75rem;
  }
  .simulation-view {
    height: calc(100vh - 100px);
    border-radius: 0;
  }
  .hud-top {
    flex-direction: row;
    font-size: 0.85rem;
  }
  .location-badge, .merit-badge {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
  .blessing-banner {
    font-size: 0.85rem;
    padding: 6px 16px;
  }
  .sim-tips {
    font-size: 0.75rem;
    padding: 4px 12px;
  }
  .hud-bottom {
    flex-direction: row;
    gap: 10px;
  }
  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  .btn-large {
    padding: 12px 20px;
    font-size: 0.95rem;
  }
}
