:root {
  --bg-color: #fdf6e3;
  --panel-bg: #ffffff;
  --primary: #ffb3ba;
  --primary-dark: #ff9eaa;
  --secondary: #baffc9;
  --accent: #bae1ff;
  --gold: #ffd700;
  --text-main: #5c4a4d;
  --text-light: #8c7a7d;
  --border-color: #f0e4e6;
  --shadow: 0 4px 12px rgba(92, 74, 77, 0.08);
  --shadow-hover: 0 8px 24px rgba(92, 74, 77, 0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --success: #72c48f;
  --success-soft: #e8f8eb;
  --danger: #f47f7f;
  --danger-soft: #fff0f0;
  --accent-dark: #7bb8ee;
  --accent-soft: #eef7ff;
  --gold-soft: #fff4c2;
  --beige-deep: #f7edd8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body { height: 100%; }

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 179, 186, 0.22), transparent 34%),
    radial-gradient(circle at top right, rgba(186, 225, 255, 0.2), transparent 36%),
    radial-gradient(circle at bottom center, rgba(186, 255, 201, 0.18), transparent 30%),
    var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden;
}

#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0.15)), var(--bg-color);
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  isolation: isolate;
}

#top-bar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  z-index: 10;
  box-shadow: var(--shadow);
}

.resource-row, .stats-row, .modal-header, .settings-item, .batch-btns, .quest-item, .shop-card, .farm-controls {
  display: flex;
  align-items: center;
}

.resource-row, .stats-row { justify-content: space-between; }
.resource-row { margin-bottom: 8px; gap: 8px; }
.stats-row { gap: 10px; flex-wrap: wrap; }

.resource, .stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.resource {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.65));
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  min-width: 70px;
  box-shadow: inset 0 0 0 1px rgba(240, 228, 230, 0.7);
  transition: var(--transition);
}

.resource .icon { font-size: 16px; }
.stat { font-size: 14px; font-weight: 600; }
.progress-bar-bg, .card-progress, .tech-card .tech-progress, .quest-item .quest-progress {
  background: var(--border-color);
  overflow: hidden;
}

.progress-bar-bg {
  width: 100px;
  height: 10px;
  border-radius: 999px;
  margin-left: 8px;
}

.progress-bar-fill, .card-progress-fill, .tech-progress-fill, .quest-progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-bar-fill { background: var(--accent); }
.card-progress-fill { background: linear-gradient(90deg, #98e4ae, #c2f1ce); }
.tech-progress-fill { background: linear-gradient(90deg, #8bc7ff, #c7e5ff); }
.quest-progress-fill { background: linear-gradient(90deg, #ffd88a, #ffeaa8); }

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 120px;
  position: relative;
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 rgba(186,255,201,0.2); } 50% { box-shadow: 0 0 18px rgba(186,255,201,0.75); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-40px) scale(1.2); } }
@keyframes toastSlide { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes bannerSlide { from { opacity: 0; transform: translateY(-18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes tutorialPulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(123,184,238,0.35); } 50% { transform: scale(1.01); box-shadow: 0 0 0 10px rgba(123,184,238,0); } }
@keyframes flashUp { 0% { background: rgba(114,196,143,0); } 35% { background: rgba(114,196,143,0.35); } 100% { background: rgba(114,196,143,0); } }
@keyframes flashDown { 0% { background: rgba(244,127,127,0); } 35% { background: rgba(244,127,127,0.35); } 100% { background: rgba(244,127,127,0); } }

.section-header { text-align: center; margin-bottom: 20px; }
.section-header h2 { font-size: 24px; color: var(--text-main); margin-bottom: 4px; }
.subtitle { font-size: 14px; color: var(--text-light); }

.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.farm-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.list-container, .quest-list { display: flex; flex-direction: column; gap: 12px; }

.card, .premium-item, .tech-card, .quest-item, .settings-group {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.85));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.card {
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.card:hover, .premium-item:hover, .tech-card:hover, .quest-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card:hover { border-color: var(--primary); }
.card:active { transform: translateY(0); }
.card.locked, .tech-card.locked, .crop-option.locked { opacity: 0.85; filter: grayscale(60%); cursor: not-allowed; }
.card.producing { animation: pulseGlow 2s infinite; }
.card-icon { font-size: 40px; margin-bottom: 8px; display: inline-block; }
.card-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.card-level {
  font-size: 12px;
  color: var(--text-light);
  background: rgba(253, 246, 227, 0.95);
  padding: 2px 6px;
  border-radius: 999px;
  display: inline-block;
}
.card-progress, .tech-card .tech-progress { height: 6px; border-radius: 999px; margin-top: 8px; }

.card.level-1 { border-color: rgba(255,179,186,0.2); }
.card.level-2 { border-color: rgba(255,179,186,0.32); }
.card.level-3 { border-color: rgba(255,179,186,0.44); }
.card.level-4 { border-color: rgba(255,158,170,0.48); }
.card.level-5 { border-color: rgba(255,158,170,0.58); }
.card.level-6 { border-color: rgba(255,215,0,0.48); }
.card.level-7 { border-color: rgba(255,215,0,0.58); }
.card.level-8 { border-color: rgba(123,184,238,0.58); }
.card.level-9 { border-color: rgba(123,184,238,0.72); box-shadow: 0 0 0 1px rgba(123,184,238,0.18), var(--shadow); }
.card.level-10 { border-color: rgba(114,196,143,0.82); box-shadow: 0 0 0 2px rgba(114,196,143,0.18), 0 10px 24px rgba(114,196,143,0.18); }

.shop-card { text-align: left; padding: 16px; gap: 16px; }
.shop-icon { font-size: 48px; }
.shop-info { flex: 1; }
.shop-stats-mini { display: flex; gap: 12px; font-size: 12px; color: var(--text-light); margin-top: 4px; flex-wrap: wrap; }
.farm-controls { justify-content: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.farm-card { min-height: 120px; display: flex; flex-direction: column; justify-content: center; }
.crop-ready { animation: bounce 1s infinite; }
.crop-stage-1 { opacity: 0.55; filter: saturate(0.9); transform: scale(0.92); }
.crop-stage-2 { opacity: 0.8; filter: saturate(1.05); transform: scale(1); }
.crop-stage-3 { opacity: 1; filter: saturate(1.18); transform: scale(1.08); }

#event-banner {
  display: none;
  width: 100%;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: calc(var(--radius) + 2px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}

#event-banner.active { display: flex; animation: bannerSlide 0.35s ease forwards; }
.event-positive { background: linear-gradient(135deg, #efffe7, #fff3c6); border: 2px solid rgba(255,215,0,0.5); color: #577345; }
.event-negative { background: linear-gradient(135deg, #fff1f1, #f6dbdb); border: 2px solid rgba(244,127,127,0.42); color: #874f57; }
.event-neutral { background: linear-gradient(135deg, #eef8ff, #ddeeff); border: 2px solid rgba(123,184,238,0.42); color: #486a8e; }
.event-timer { margin-left: auto; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.55); font-weight: 800; letter-spacing: 0.04em; }

.research-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tech-card {
  padding: 14px;
  text-align: left;
  border-color: rgba(123, 184, 238, 0.28);
  background: linear-gradient(180deg, rgba(238,247,255,0.95), rgba(255,255,255,0.88));
}
.tech-card.researched { border-color: rgba(114,196,143,0.75); box-shadow: 0 0 0 2px rgba(114,196,143,0.14), 0 10px 24px rgba(114,196,143,0.18); }
.tech-card.locked { background: linear-gradient(180deg, rgba(250,248,246,0.95), rgba(244,240,236,0.92)); }
.tech-card .tech-progress { height: 8px; background: rgba(123,184,238,0.18); }

.daily-header, .achievement-header {
  margin: 22px 0 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,179,186,0.2), rgba(186,225,255,0.15));
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.quest-item {
  gap: 12px;
  padding: 14px 16px;
  justify-content: space-between;
  border-color: rgba(255, 179, 186, 0.18);
}

.quest-item .quest-progress { flex: 1; min-width: 100px; max-width: 180px; height: 7px; border-radius: 999px; background: rgba(255,179,186,0.18); }
.quest-item.completed { background: linear-gradient(180deg, rgba(232,248,235,0.95), rgba(250,255,251,0.86)); border-color: rgba(114,196,143,0.38); }
.quest-item.completed .quest-title, .quest-item.completed .quest-text, .quest-item.completed .quest-description, .quest-item.completed .quest-main { text-decoration: line-through; color: #75927f; }
.quest-reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-soft), #fff8de);
  color: #9f7c15;
  font-weight: 800;
  white-space: nowrap;
}

#tutorial-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(92, 74, 77, 0.45);
  backdrop-filter: blur(4px);
  z-index: 250;
}

#tutorial-overlay.active { display: flex; }
.tutorial-step {
  position: relative;
  width: min(92vw, 360px);
  padding: 18px 18px 16px;
  background: linear-gradient(180deg, #fffdf8, #ffffff);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(92, 74, 77, 0.2);
}
.tutorial-step::after {
  content: '';
  position: absolute;
  left: 32px;
  bottom: -12px;
  width: 24px;
  height: 24px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 4px;
}
.tutorial-highlight { position: relative; border-radius: 18px; box-shadow: 0 0 0 3px rgba(123,184,238,0.95); animation: tutorialPulse 1.8s infinite; z-index: 251; }
.tutorial-text { color: var(--text-main); font-size: 15px; margin-bottom: 14px; }
.tutorial-btn, .btn-export, .btn-import, .btn-reset {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}
.tutorial-btn { background: linear-gradient(135deg, var(--accent), #dff1ff); color: #416482; }

button { font-family: inherit; outline: none; }
.btn-primary, .btn-action, .btn-danger, .btn-gold {
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary, .btn-action { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); box-shadow: 0 4px 0 #e88d98; }
.btn-gold { background: linear-gradient(180deg, #ffdf6f, #f3c943); color: var(--text-main); box-shadow: 0 4px 0 #d4b200; }
.btn-primary:hover, .btn-action:hover, .btn-gold:hover, .btn-export:hover, .btn-import:hover, .btn-reset:hover, .tutorial-btn:hover { transform: translateY(2px); }
.btn-primary:active, .btn-action:active, .btn-gold:active, .btn-export:active, .btn-import:active, .btn-reset:active, .tutorial-btn:active { transform: translateY(4px); box-shadow: none; }
.btn-primary:disabled { background: #ccc; box-shadow: 0 4px 0 #999; cursor: not-allowed; }
.btn-sell { background: linear-gradient(180deg, #ffe37d, #ffd24b); color: var(--text-main); box-shadow: 0 4px 0 #d4b200; }
.btn-danger, .btn-reset { background: linear-gradient(180deg, #ff8e8e, #ff6b6b); box-shadow: 0 4px 0 #cc5555; }
.btn-small { padding: 4px 12px; font-size: 12px; border-radius: 12px; }
.btn-export { background: linear-gradient(180deg, #ccebd4, #a7dbb6); color: #345e41; box-shadow: 0 4px 0 #85b695; }
.btn-import { background: linear-gradient(180deg, #d7ebff, #b8dcff); color: #3d6386; box-shadow: 0 4px 0 #92bbdf; }

.batch-btns { justify-content: center; gap: 8px; flex-wrap: wrap; }
.batch-btn {
  border: 1px solid rgba(255, 179, 186, 0.45);
  background: rgba(255,255,255,0.86);
  color: var(--text-light);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}
.batch-btn.active { background: linear-gradient(135deg, var(--primary), #ffc7ce); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(255, 179, 186, 0.35); }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(92, 74, 77, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  background: var(--panel-bg);
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  display: none;
  z-index: 101;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.show { display: block; opacity: 1; transform: translate(-50%, -50%); }
.modal-overlay.show { display: block; opacity: 1; }
.modal-header { justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 18px; }
.btn-close { background: none; border: none; font-size: 20px; color: var(--text-light); cursor: pointer; }
.modal-body { padding: 20px; text-align: center; }
.modal-icon { font-size: 64px; margin-bottom: 12px; }
.modal-desc { color: var(--text-light); margin-bottom: 16px; font-size: 14px; }
.modal-stats, .prestige-stats, .settings-group {
  background: linear-gradient(180deg, rgba(253,246,227,0.8), rgba(255,255,255,0.7));
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  text-align: left;
}
.stat-row { margin-bottom: 4px; font-size: 14px; }
.modal-cost { font-weight: 700; font-size: 18px; color: var(--text-main); }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); text-align: center; }

.settings-group { padding: 14px; border-color: rgba(186,225,255,0.22); }
.settings-item { justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed rgba(240,228,230,0.9); }
.settings-item:last-child { border-bottom: none; padding-bottom: 0; }
.toggle-switch { position: relative; display: inline-flex; width: 54px; height: 30px; }
.toggle-switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.toggle-switch .slider {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #e9dde0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  transition: var(--transition);
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(92,74,77,0.2);
  transition: var(--transition);
}
.toggle-switch input:checked + .slider { background: linear-gradient(135deg, #b6e9c4, #9edcb0); }
.toggle-switch input:checked + .slider::before { transform: translateX(24px); }

.crop-selection-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crop-option {
  background: var(--bg-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.crop-option:hover { border-color: var(--secondary); background: white; }
.crop-option .icon { font-size: 32px; display: block; margin-bottom: 4px; }
.crop-option .name { font-weight: 700; font-size: 14px; }
.crop-option .details { font-size: 12px; color: var(--text-light); }

.premium-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.premium-item {
  padding: 14px;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}
.diamond-pack { border-color: rgba(255,215,0,0.72); box-shadow: 0 0 0 1px rgba(255,215,0,0.24), var(--shadow); }
.vip-card { background: linear-gradient(135deg, #fff5cb, #ffd5de 55%, #dceeff); border-color: rgba(255,215,0,0.4); }
.speed-boost-item::before { content: '⏱️'; position: absolute; top: 10px; right: 12px; font-size: 16px; }

#bottom-nav {
  position: absolute;
  inset: auto 0 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  justify-content: space-around;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 10;
  gap: 4px;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  padding: 8px 6px;
  border-radius: var(--radius);
}
.nav-btn .icon { font-size: 21px; margin-bottom: 2px; filter: grayscale(100%); transition: var(--transition); }
.nav-btn .label { font-size: 11px; font-weight: 700; white-space: nowrap; }
.nav-btn.active { color: var(--primary-dark); background: rgba(253,246,227,0.95); }
.nav-btn.active .icon { filter: grayscale(0%); transform: scale(1.12); }

#floating-text-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.floating-text {
  position: absolute;
  font-weight: 800;
  font-size: 16px;
  color: var(--gold);
  text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
  animation: floatUp 1s ease-out forwards;
}
.resource-flash-up { animation: flashUp 0.75s ease; }
.resource-flash-down { animation: flashDown 0.75s ease; }

#toast-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: rgba(92, 74, 77, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastSlide 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, fadeOut 0.3s ease 2.7s forwards;
}

.city-stats, .shop-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.84);
  padding: 8px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.city-stat, .shop-stat { font-size: 12px; font-weight: 700; color: var(--text-light); }
.city-stat span, .shop-stat span { color: var(--text-main); }
.offline-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  text-align: left;
  background: var(--bg-color);
  padding: 16px;
  border-radius: var(--radius-sm);
}
.offline-stat { font-weight: 700; }
.offline-note { font-size: 12px; color: var(--text-light); }
.warning-text { color: #ff6b6b; font-size: 12px; margin-top: 16px; font-weight: 700; }

@media (max-width: 640px) {
  #top-bar, #main-content { padding-left: 12px; padding-right: 12px; }
  .research-grid, .premium-grid, .crop-selection-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quest-item, #event-banner.active { flex-wrap: wrap; }
  .event-timer { margin-left: 0; }
}

@media (max-width: 420px) {
  .resource-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resource { min-width: 0; justify-content: center; }
  .stats-row, .city-stats, .shop-stats, .farm-controls { justify-content: center; }
  .grid-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .farm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .offline-stats { grid-template-columns: 1fr; }
  .nav-btn .icon { font-size: 19px; }
  .nav-btn .label { font-size: 10px; }
  .batch-btn { padding: 6px 10px; }
}

@media (max-width: 360px) {
  #main-content { padding: 10px; padding-bottom: 120px; }
  .research-grid, .premium-grid, .crop-selection-list { gap: 10px; }
  .quest-item { padding: 12px; }
  .tutorial-step { width: 100%; }
}

#gacha-collection-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
#gacha-collection-grid .card { padding: 8px; }
#gacha-collection-grid .card-icon { font-size: 32px; margin-bottom: 4px; }
#gacha-collection-grid .card-title { font-size: 11px; }
#gacha-collection-grid .card-level { font-size: 11px; }
#gacha-result-icon { animation: bounce 0.6s ease; }
@keyframes gachaShine { 0%{filter:brightness(1)} 50%{filter:brightness(1.4)} 100%{filter:brightness(1)} }

/* ============ 社交广场 ============ */
.social-section { background: rgba(255,255,255,0.7); border-radius: var(--radius); padding: 16px; }
.social-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.social-section-header h3 { margin: 0; font-size: 16px; }
.social-count { font-size: 12px; color: var(--text-light); background: var(--beige-deep); padding: 2px 10px; border-radius: 20px; }
.social-input-row { display: flex; gap: 8px; align-items: center; }
.social-input { flex: 1; padding: 10px 14px; border: 2px solid var(--border-color); border-radius: var(--radius); font-size: 14px; background: #fff; outline: none; transition: var(--transition); }
.social-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,183,77,0.2); }
.social-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 400px; overflow-y: auto; }
.social-msg { background: #fff; border-radius: var(--radius); padding: 12px; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.social-msg .msg-avatar { font-size: 28px; flex-shrink: 0; width: 36px; text-align: center; }
.social-msg .msg-body { flex: 1; min-width: 0; }
.social-msg .msg-name { font-weight: 800; font-size: 13px; color: var(--text-main); }
.social-msg .msg-text { font-size: 13px; color: var(--text-light); margin-top: 2px; word-break: break-all; }
.social-msg .msg-footer { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 11px; color: #aaa; }
.social-msg .msg-like { cursor: pointer; transition: var(--transition); }
.social-msg .msg-like:hover { color: #e74c3c; }
.social-msg .msg-like.liked { color: #e74c3c; }
.social-msg.is-npc { background: linear-gradient(135deg, #ffeaa7 0%, #fff4d2 100%); border: 1px solid #f9ca2420; }
.social-msg.is-mine { background: linear-gradient(135deg, #dfe6e9 0%, #f0f0f0 100%); }
.social-wish-card { margin-top: 12px; padding: 20px; background: linear-gradient(135deg, #74b9ff40, #0984e320); border-radius: var(--radius); text-align: center; animation: fadeIn 0.4s ease; }
.social-wish-card .wish-avatar { font-size: 40px; }
.social-wish-card .wish-name { font-weight: 800; font-size: 14px; margin-top: 4px; }
.social-wish-card .wish-text { font-size: 14px; color: var(--text-light); margin-top: 8px; font-style: italic; }
.social-wish-card .wish-reply-row { display: flex; gap: 8px; margin-top: 12px; }
.social-wish-card .wish-reply-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius); font-size: 13px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 名片弹窗 ============ */
.social-msg .msg-avatar { transition: transform 0.2s ease; }
.social-msg .msg-avatar:hover { transform: scale(1.2); }

/* ============ 楼中楼回复 ============ */
.msg-replies { margin-top: 6px; padding: 6px 0 2px 0; border-top: 1px dashed rgba(0,0,0,0.08); }
.msg-reply-item { font-size: 12px; color: var(--text-light); padding: 2px 0; line-height: 1.5; }
.msg-reply-item .reply-name { font-weight: 700; color: var(--text-main); margin-right: 2px; }
.msg-reply-item .reply-text { color: #666; }
.msg-reply-btn { cursor: pointer; color: #aaa; transition: color 0.2s; font-size: 11px; }
.msg-reply-btn:hover { color: var(--primary-dark); }
.msg-reply-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; animation: fadeIn 0.3s ease; }
.msg-reply-row input { flex: 1; padding: 6px 10px; border: 1.5px solid var(--border-color); border-radius: var(--radius); font-size: 12px; background: #fff; outline: none; }
.msg-reply-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,183,77,0.15); }

/* ============ 孤独的美食家 ============ */
.diner-section {
  --diner-amber: #ffcc75;
  --diner-amber-deep: #f7a93b;
  --diner-night: #191725;
  --diner-night-soft: #292237;
  --diner-wood: #5f3820;
  --diner-cream: #fff3d4;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 199, 120, 0.22), transparent 32%),
    radial-gradient(circle at right center, rgba(255, 157, 66, 0.12), transparent 28%),
    linear-gradient(135deg, #181524 0%, #241d31 45%, #4a2f1d 100%);
  border: 1px solid rgba(255, 209, 138, 0.14);
  box-shadow: 0 18px 38px rgba(25, 19, 31, 0.28);
  animation: dinerGlow 4.8s ease-in-out infinite;
}
.diner-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent 35%, rgba(0,0,0,0.1));
  pointer-events: none;
}
.diner-header, .diner-subsection, .diner-table-wrap {
  position: relative;
  z-index: 1;
}
.diner-header {
  text-align: center;
  padding: 10px 4px 18px;
  color: var(--diner-cream);
}
.diner-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 202, 124, 0.14);
  color: var(--diner-amber);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.diner-header h3 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  color: #ffe8b5;
  text-shadow: 0 4px 18px rgba(255, 196, 102, 0.22);
}
.diner-header p {
  margin: 8px auto 0;
  max-width: 280px;
  color: rgba(255, 243, 212, 0.78);
  font-size: 13px;
}
.diner-level-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 12px;
  color: #ffd68e;
}
.diner-level-progress, .diner-locked-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.12);
  margin-top: 12px;
}
.diner-level-progress span, .diner-locked-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffcf70 0%, #ff9a3c 100%);
  box-shadow: 0 0 18px rgba(255, 185, 87, 0.45);
}
.diner-table-wrap, .diner-subsection {
  background: rgba(255, 244, 219, 0.06);
  border: 1px solid rgba(255, 229, 173, 0.08);
  border-radius: 20px;
  padding: 16px;
  backdrop-filter: blur(10px);
}
.diner-table-wrap {
  margin-bottom: 14px;
}
.diner-scene-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffd68e;
  margin-bottom: 10px;
}
.diner-table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
  min-height: 112px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(120, 72, 38, 0.82), rgba(85, 47, 21, 0.92));
  box-shadow: inset 0 3px 16px rgba(0,0,0,0.24);
}
.diner-dish {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  border-radius: 14px;
  background: rgba(255, 247, 229, 0.14);
  border: 1px solid rgba(255, 216, 154, 0.14);
  color: #fff5dc;
  animation: dishFloat 3.2s ease-in-out infinite;
}
.diner-dish-emoji { font-size: 28px; }
.diner-dish-name { font-size: 11px; text-align: center; color: rgba(255,243,212,0.82); }
.diner-visitors {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.diner-visitor {
  flex: 1 1 150px;
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 238, 203, 0.96), rgba(255, 218, 152, 0.74));
  color: #5c3417;
  box-shadow: 0 8px 20px rgba(0,0,0,0.14);
  position: relative;
}
.diner-visitor-avatar { font-size: 30px; }
.diner-visitor-name { margin-top: 4px; font-size: 13px; font-weight: 900; }
.diner-visitor-bubble {
  position: relative;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.7);
  color: #6b4623;
  font-size: 12px;
  line-height: 1.6;
}
.diner-visitor-bubble::after {
  content: '';
  position: absolute;
  left: 14px;
  top: -7px;
  width: 14px;
  height: 14px;
  background: rgba(255,255,255,0.7);
  transform: rotate(45deg);
}
.diner-visitor-dish { margin-top: 8px; font-size: 11px; color: rgba(92,52,23,0.72); }
.diner-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.diner-recipe-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.98), rgba(255, 230, 181, 0.88));
  color: #6a3e1c;
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
  border: 1px solid rgba(255, 183, 77, 0.18);
}
.diner-recipe-card.locked {
  filter: grayscale(0.35);
  opacity: 0.68;
  background: linear-gradient(180deg, rgba(180, 168, 152, 0.95), rgba(135, 123, 110, 0.9));
  color: rgba(255,255,255,0.88);
}
.diner-recipe-card.locked .btn-small { opacity: 0.6; }
.diner-recipe-emoji { font-size: 34px; }
.diner-recipe-name { font-size: 15px; font-weight: 900; }
.diner-recipe-desc { font-size: 12px; min-height: 36px; color: inherit; opacity: 0.82; }
.diner-recipe-cost { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; }
.diner-recipe-cost span { padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,0.45); }
.diner-recipe-value { font-size: 11px; color: #a05a1e; font-weight: 800; }
.diner-pool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.diner-pool-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 249, 235, 0.9);
  color: #6a3e1c;
}
.diner-pool-note { font-size: 12px; line-height: 1.7; color: rgba(255,243,212,0.78); margin-bottom: 12px; }
.diner-claim-btn {
  width: 100%;
  background: linear-gradient(135deg, #ffcf70, #ff8b3d);
  color: #fff7e2;
  box-shadow: 0 12px 24px rgba(255, 136, 58, 0.24);
}
.diner-history-list { position: relative; display: flex; flex-direction: column; gap: 10px; }
.diner-history-item { display: flex; gap: 10px; align-items: flex-start; }
.diner-history-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #ffd47d, #ff9a3c);
  box-shadow: 0 0 12px rgba(255, 180, 87, 0.34);
}
.diner-history-content {
  flex: 1;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 248, 228, 0.86);
  color: #6a3e1c;
}
.diner-history-title { font-size: 12px; line-height: 1.6; }
.diner-history-time { font-size: 11px; color: rgba(106, 62, 28, 0.62); margin-top: 4px; }
.diner-locked {
  padding: 28px 18px;
  text-align: center;
  color: var(--diner-cream);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(19, 17, 29, 0.96), rgba(73, 45, 24, 0.82));
  border: 1px solid rgba(255, 208, 132, 0.18);
}
.diner-locked-icon { font-size: 48px; margin-bottom: 12px; }
.diner-locked-title { font-size: 22px; font-weight: 900; color: #ffe5ac; }
.diner-locked-text { margin-top: 8px; font-size: 13px; color: rgba(255,243,212,0.74); }
.diner-locked-hint { margin-top: 4px; font-size: 13px; color: #ffc46a; }
.diner-empty {
  width: 100%;
  text-align: center;
  padding: 18px 12px;
  border-radius: 16px;
  font-size: 12px;
  color: rgba(255,243,212,0.76);
  background: rgba(255,255,255,0.05);
}
.diner-subsection + .diner-subsection, .diner-table-wrap + .diner-subsection {
  margin-top: 14px;
}
@keyframes dinerGlow {
  0%, 100% { box-shadow: 0 18px 38px rgba(25, 19, 31, 0.28), 0 0 0 rgba(255, 184, 82, 0); }
  50% { box-shadow: 0 22px 44px rgba(25, 19, 31, 0.34), 0 0 24px rgba(255, 184, 82, 0.12); }
}
@keyframes dishFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@media (min-width: 700px) {
  .diner-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .diner-header h3 { font-size: 24px; }
  .diner-table { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .diner-pool-grid { grid-template-columns: 1fr; }
}