/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #ff6b35;
  --primary-dark: #e55a25;
  --primary-light: #fff4f0;
  --accent: #ffd166;
  --success: #06d6a0;
  --danger: #ef476f;
  --text: #2d2d2d;
  --text-sub: #777;
  --border: #e8e8e8;
  --bg: #f9f7f4;
  --white: #ffffff;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --locked-color: #f0c040;
}

html, body {
  height: 100%;
  font-family: -apple-system, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.screen.active { display: flex; }

/* ===== TITLE SCREEN ===== */
.title-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.title-icon {
  font-size: 72px;
  line-height: 1;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.title-heading {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.title-sub {
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 8px;
}

.recipe-count-note {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: -4px;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h2 {
  font-size: 17px;
  font-weight: 700;
}
.back-btn, .icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}
.back-btn:active, .icon-btn:active { background: var(--primary-light); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 20px;
  transition: transform 0.1s, box-shadow 0.1s;
  text-decoration: none;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,107,53,0.3);
}
.btn-primary:active { background: var(--primary-dark); }

.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-ghost {
  background: var(--bg);
  color: var(--text-sub);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-lg { width: 100%; padding: 16px; font-size: 17px; border-radius: var(--radius); }

.spin-btn { font-size: 18px; }

/* ===== GENRE FILTER ===== */
.genre-filter {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--white);
  overflow-x: auto;
  scrollbar-width: none;
}
.genre-filter::-webkit-scrollbar { display: none; }

.genre-btn {
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-sub);
  transition: all 0.15s;
  font-family: inherit;
}
.genre-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== GACHA CARDS ===== */
.gacha-cards {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.gacha-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gacha-card.locked {
  border-color: var(--locked-color);
  background: #fffdf0;
}
.gacha-card.spinning .card-content {
  animation: cardSpin 0.4s ease-out;
}
@keyframes cardSpin {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  min-width: 36px;
  text-align: center;
}

.card-content {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.card-content.empty { color: var(--text-sub); font-weight: 400; }
.card-content.no-recipe { color: var(--danger); font-size: 13px; font-weight: 400; }

.lock-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-sub);
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}
.locked .lock-btn {
  border-color: var(--locked-color);
  background: var(--locked-color);
  color: #5a4000;
}

/* ===== WARNING ===== */
.warning-box {
  margin: 0 16px;
  padding: 10px 14px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #856404;
  line-height: 1.5;
}

/* ===== GACHA ACTIONS ===== */
.gacha-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== AD PLACEHOLDER ===== */
.ad-placeholder {
  margin: 0 16px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  color: var(--text-sub);
  font-size: 12px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1;
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}
.search-input:focus { outline: none; border-color: var(--primary); }
.filter-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ===== RECIPE LIST ===== */
.recipe-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.1s;
}
.recipe-item:active { transform: scale(0.99); }

.recipe-item-icon {
  font-size: 28px;
  line-height: 1;
}
.recipe-item-body { flex: 1; min-width: 0; }
.recipe-item-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recipe-item-tags {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 2px 8px;
}
.tag-category { background: var(--primary-light); color: var(--primary); }
.tag-genre { background: #e8f4f8; color: #2980b9; }
.tag-genre-和食 { background: #ffeee8; color: #c0392b; }
.tag-genre-洋食 { background: #e8f0ff; color: #2c5aa0; }
.tag-genre-中華 { background: #fff8e0; color: #c07800; }
.tag-genre-その他 { background: #f0f0f0; color: #666; }

.recipe-item-arrow { color: var(--border); font-size: 18px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-sub);
}
.empty-icon { font-size: 56px; }

/* ===== FREE LIMIT NOTICE ===== */
.free-limit-notice {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}
.free-limit-notice.free-limit-ok {
  background: #e6f9f2;
  color: #1a7a55;
  border-bottom: 1px solid #b2e8d4;
}
.free-limit-notice.free-limit-full {
  background: #fff4e0;
  color: #a05f00;
  border-bottom: 1px solid #ffd788;
}

/* ===== RECIPE FORM ===== */
.recipe-form {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label { font-size: 14px; font-weight: 600; color: var(--text); }
.required { color: var(--danger); }
.form-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/* ===== DETAIL SCREEN ===== */
.detail-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }

.detail-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.detail-card-header {
  background: var(--primary-light);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}
.detail-card-body { padding: 14px 16px; }

.detail-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-memo {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.detail-url-link {
  color: var(--primary);
  font-size: 14px;
  word-break: break-all;
  text-decoration: none;
}
.detail-url-link:active { opacity: 0.7; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== AD MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 500;
}

.modal-sheet {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
  line-height: 1.7;
}

.ad-timer-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ad-fake-area {
  background: linear-gradient(to bottom, #cfeafd 0%, #cfeafd 70%, #d8efd9 70%, #d8efd9 100%);
  border-radius: var(--radius);
  height: 110px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 犬がフリスビーを追うアニメのCSSは index.html にインライン化（HTMLとCSSのキャッシュずれ防止） */

.ad-progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.ad-progress-fill {
  background: var(--primary);
  height: 100%;
  width: 0%;
  border-radius: 4px;
}

.ad-countdown {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-height: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

/* ===== FUKUSAI CONTROLS ===== */
.fukusai-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 4px;
}

.fukusai-btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
}

/* ===== GAISYOKU SECTION ===== */
.gaisyoku-section {
  padding: 0 16px 20px;
  text-align: center;
}

.gaisyoku-toggle {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  opacity: 0.6;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.gaisyoku-toggle:hover { opacity: 0.85; }
.gaisyoku-toggle.active {
  opacity: 1;
  color: var(--primary);
  background: var(--primary-light);
}

.gaisyoku-message {
  margin-top: 16px;
  padding: 20px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  text-align: center;
  animation: fadeIn 0.25s ease;
}

.gaisyoku-msg-icon {
  font-size: 36px;
  margin: 0 0 6px;
}

.gaisyoku-msg-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.gaisyoku-msg-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0;
}

/* ===== HEADER ACTIONS ===== */
.header-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

/* ===== BACKUP MODAL ===== */
.backup-count-note {
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
  margin-top: -8px;
}

.backup-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.backup-card-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.backup-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.backup-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.backup-card-desc {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.6;
}

.backup-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 400;
  animation: slideUpBanner 0.3s ease;
}

@keyframes slideUpBanner {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

.pwa-install-icon { font-size: 26px; flex-shrink: 0; }

.pwa-install-text { flex: 1; min-width: 0; }

.pwa-install-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.pwa-install-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 1px;
}

.pwa-install-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 0.15s;
}
.pwa-install-btn:active { background: var(--primary-dark); }

.pwa-dismiss-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  line-height: 1;
}

/* ===== SHARE BUTTON ===== */
.btn-share {
  background: linear-gradient(135deg, #1da1f2, #0ea070);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  transition: opacity 0.15s;
}
.btn-share:active { opacity: 0.8; }

/* ===== SHARE MODAL ===== */
.share-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 16px;
  color: var(--text);
}

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.share-btn {
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.share-btn:active { opacity: 0.8; }

.share-btn-x {
  background: #000;
  color: #fff;
}

.share-btn-line {
  background: #00b900;
  color: #fff;
}

.share-btn-copy {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
}

/* ===== USER VOICE ===== */
.btn-voice-trigger {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-decoration: underline;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.btn-voice-trigger:hover { opacity: 1; }
.btn-voice-trigger:active { opacity: 0.8; }

/* ===== PREMIUM ===== */
.free-limit-premium {
  background: linear-gradient(135deg, #fff8e1, #fffde7);
  border: 1.5px solid #ffd600;
  color: #7a5700;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

.premium-cta {
  text-align: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn-premium-link {
  background: none;
  border: none;
  color: #b8860b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  padding: 4px;
}
.btn-premium-link:active { opacity: 0.7; }

.premium-code-field {
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
}

.premium-code-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  padding: 6px 0 0;
  font-weight: 600;
}

.premium-buy-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
}

.premium-buy-hint a {
  color: var(--primary);
  font-weight: 600;
}

/* ===== iOS INSTALL GUIDE BANNER ===== */
.ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #1c1c1e;
  color: #fff;
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 400;
  animation: slideUpBanner 0.3s ease;
}

.ios-install-banner .pwa-install-title {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.ios-install-banner .pwa-install-desc {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  margin-top: 1px;
}

.ios-install-banner .pwa-dismiss-btn {
  color: rgba(255,255,255,0.55);
}

