/* ═══════════════════════════════════════════════
   Brew Empire — 精酿帝国
   Dark theme with amber/gold accents
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  --bg: #0d0d1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --border: #2a2a4a;
  --amber: #f5a623;
  --amber-dim: #c7851a;
  --amber-glow: rgba(245, 166, 35, 0.3);
  --gold: #ffd700;
  --green: #4caf50;
  --red: #ef5350;
  --text: #e0e0e0;
  --text-dim: #888;
  --text-bright: #fff;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Layout ── */
.game-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

/* ── Header ── */
.game-header {
  text-align: center;
  padding: 16px 12px 8px;
}

.game-title {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--amber), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.game-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Location Bar ── */
.location-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
}

.location-bar .loc {
  color: var(--amber);
  font-weight: 600;
}

.location-bar .rep {
  color: var(--text-dim);
}

.location-bar .rep span {
  color: var(--gold);
  font-weight: 600;
}

/* ── Resource Bar ── */
.resource-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.resource-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  font-size: 0.75rem;
  transition: border-color 0.2s;
}

.resource-item .res-icon {
  font-size: 1.1rem;
  display: block;
  margin-bottom: 2px;
}

.resource-item .res-val {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.8rem;
}

.resource-item.money {
  grid-column: span 5;
  background: linear-gradient(135deg, #1a1a2e 0%, #2a2010 100%);
  border-color: var(--amber-dim);
  padding: 10px;
}

.resource-item.money .res-val {
  font-size: 1.5rem;
  color: var(--gold);
}

/* ── Brew Section ── */
.brew-section {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  overflow: hidden;
}

.brew-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.brew-info .recipe-name {
  color: var(--amber);
  font-weight: 600;
  font-size: 0.9rem;
}

.brew-info .stats {
  color: var(--text-dim);
}

.brew-info .stats span {
  margin-left: 8px;
}

#brew-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid var(--amber);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2a2010 0%, #1a1a2e 100%);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  z-index: 2;
  letter-spacing: 1px;
}

#brew-btn:hover {
  background: linear-gradient(135deg, #3a3020 0%, #2a2a3e 100%);
  box-shadow: 0 0 20px var(--amber-glow);
  transform: translateY(-1px);
}

#brew-btn:active {
  transform: scale(0.97) translateY(0);
  box-shadow: 0 0 10px var(--amber-glow);
}

#brew-btn.flash {
  animation: flash 0.3s ease;
}

@keyframes flash {
  0% { box-shadow: 0 0 0 var(--amber-glow); }
  50% { box-shadow: 0 0 30px var(--amber-glow); }
  100% { box-shadow: 0 0 0 var(--amber-glow); }
}

.brew-key-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.inventory-bar {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 20px;
  font-size: 0.75rem;
}

.inv-item {
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── Bubbles ── */
#bubble-area {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.bubble {
  position: absolute;
  bottom: -10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 215, 0, 0.6), rgba(245, 166, 35, 0.2));
  animation: bubble-rise linear forwards;
}

@keyframes bubble-rise {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-300px) scale(0.3); opacity: 0; }
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 10px 4px;
  font-size: 0.75rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.tab-btn.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
  background: rgba(245, 166, 35, 0.05);
}

.tab-panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  max-height: 60vh;
  overflow-y: auto;
}

.tab-panel.active {
  display: block;
}

/* ── Recipe Cards ── */
.recipe-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.recipe-card:hover {
  border-color: var(--amber-dim);
  background: var(--bg-card-hover);
}

.recipe-card.selected {
  border-color: var(--amber);
  background: rgba(245, 166, 35, 0.08);
}

.recipe-card.locked {
  opacity: 0.7;
  cursor: default;
}

.recipe-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.recipe-icon { font-size: 1.2rem; }
.recipe-name { font-weight: 600; flex: 1; }
.recipe-price { color: var(--gold); font-family: var(--mono); font-size: 0.85rem; }
.recipe-desc { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 4px; }
.recipe-stats { font-size: 0.7rem; color: var(--text-dim); display: flex; gap: 10px; }
.recipe-count { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }

.selected-badge {
  font-size: 0.7rem;
  color: var(--amber);
  margin-top: 4px;
  font-weight: 600;
}

.unlock-btn, .upgrade-btn, .buy-btn {
  width: 100%;
  padding: 8px;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  background: rgba(245, 166, 35, 0.1);
  color: var(--amber);
  cursor: pointer;
  transition: all 0.2s;
}

.unlock-btn:hover, .upgrade-btn:hover, .buy-btn:hover {
  background: rgba(245, 166, 35, 0.2);
}

.unlock-btn.disabled, .upgrade-btn.disabled, .buy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
}

/* ── Upgrade Cards ── */
.upgrade-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.upgrade-card.maxed {
  opacity: 0.6;
  border-color: var(--green);
}

.upgrade-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.upgrade-icon { font-size: 1.1rem; }
.upgrade-name { font-weight: 600; flex: 1; }
.upgrade-level { font-family: var(--mono); font-size: 0.85rem; color: var(--amber); }
.upgrade-desc { font-size: 0.75rem; color: var(--text-dim); }
.upgrade-maxed { font-size: 0.75rem; color: var(--green); margin-top: 4px; }

/* ── Resource Shop ── */
#resource-shop {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.shop-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--amber);
  margin-bottom: 6px;
  padding-bottom: 4px;
}

.resource-buy-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.8rem;
}

.resource-buy-card span:first-child { flex: 1; }
.resource-buy-card span:nth-child(2) { color: var(--text-dim); font-size: 0.75rem; }

.resource-buy-btns {
  display: flex;
  gap: 4px;
}

.buy-btn {
  width: auto;
  padding: 4px 8px;
  margin-top: 0;
  font-size: 0.7rem;
}

/* ── Achievement Cards ── */
.achievement-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 6px;
}

.achievement-card.locked {
  opacity: 0.4;
}

.achievement-icon { font-size: 1.3rem; }
.achievement-name { font-weight: 600; font-size: 0.85rem; }
.achievement-desc { font-size: 0.7rem; color: var(--text-dim); }

/* ── Inventory ── */
.inv-item {
  padding: 4px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.empty-inv {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 20px;
}

/* ── Prestige ── */
.prestige-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.prestige-section h3 {
  font-size: 0.9rem;
  color: var(--amber);
  margin-bottom: 8px;
}

#prestige-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #2a2010, #1a1a2e);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.2s;
}

#prestige-btn:hover:not(:disabled) {
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

#prestige-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.prestige-req {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 400;
}

.prestige-max {
  color: var(--gold);
  font-size: 1rem;
  padding: 20px;
}

/* ── Footer ── */
.game-footer {
  text-align: center;
  padding: 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.game-footer button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

.game-footer button:hover {
  border-color: var(--amber);
  color: var(--amber);
}

#save-indicator.saving {
  color: var(--green);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 400px;
  width: 90%;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: auto;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-info { background: #1a2a3e; border: 1px solid #2a4a6e; color: #8ab4f8; }
.toast-warning { background: #3e2a1a; border: 1px solid #6e4a2a; color: #f5a623; }
.toast-achievement { background: #1a3e1a; border: 1px solid #2a6e2a; color: #4caf50; }
.toast-prestige { background: #3e3a1a; border: 1px solid #6e6a2a; color: #ffd700; }
.toast-unlock { background: #2a1a3e; border: 1px solid #4a2a6e; color: #bb86fc; }
.toast-upgrade { background: #1a3e2a; border: 1px solid #2a6e4a; color: #03dac6; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 2px solid var(--amber);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.modal h2 {
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 12px;
}

.modal p {
  margin-bottom: 8px;
}

.offline-earned {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
  margin: 12px 0;
}

.modal-close {
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--amber);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--amber);
  cursor: pointer;
  margin-top: 8px;
}

.modal-close:hover {
  background: rgba(245, 166, 35, 0.1);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

/* ── Responsive ── */
@media (min-width: 768px) {
  .game-container {
    max-width: 540px;
    padding: 20px;
  }
  .game-title { font-size: 1.8rem; }
}

@media (max-width: 360px) {
  .resource-bar { grid-template-columns: repeat(2, 1fr); }
  .resource-item.money { grid-column: span 2; }
  .tab-btn { font-size: 0.65rem; padding: 8px 2px; }
}

/* ── Help Modal ── */
.help-modal {
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px 20px;
  text-align: left;
}

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

.help-header h2 {
  font-size: 1.05rem;
  -webkit-text-fill-color: var(--text);
  background: none;
  margin: 0;
}

.help-content h3 {
  color: var(--amber);
  font-size: 0.85rem;
  margin: 14px 0 6px;
  line-height: 1;
}

.help-content p, .help-content li {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.help-content ol, .help-content ul {
  padding-left: 18px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.78rem;
}

.help-table th,
.help-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.help-table th {
  color: var(--amber);
  font-weight: 600;
  border-bottom: 2px solid var(--amber-dim);
}

.help-table td:first-child {
  font-weight: 600;
}

.help-table td:nth-child(2),
.help-table td:nth-child(3) {
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* ═════════════════════════════════════
   V2 NEW STYLES
   ═════════════════════════════════════ */

/* ── Streak ── */
.streak-area {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  min-height: 18px;
}
.streak-info {
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 70px;
  text-align: left;
  white-space: nowrap;
}
.streak-mult { color: var(--amber); margin-left: 4px; }
.streak-track {
  flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.streak-bar {
  height: 100%; width: 0%; background: var(--amber); border-radius: 2px; transition: width 0.1s;
}
.streak-bar.fire { background: linear-gradient(90deg, var(--amber), #ff4444); }

/* ── Festival ── */
.festival-banner {
  background: linear-gradient(135deg, #3e2a1a, #5a3a2a);
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gold);
  animation: festival-pulse 1s ease-in-out infinite alternate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
@keyframes festival-pulse {
  0% { box-shadow: 0 0 5px var(--gold); }
  100% { box-shadow: 0 0 20px var(--gold); }
}
.festival-timer { font-family: var(--mono); font-size: 1rem; }

/* ── Sell All ── */
.brew-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
#sell-all-btn {
  flex: 1;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  background: rgba(76, 175, 80, 0.1);
  color: var(--green);
  cursor: pointer;
  transition: all 0.2s;
}
#sell-all-btn:hover { background: rgba(76, 175, 80, 0.2); }

/* ── Synergies ── */
#synergy-list {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.synergy-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  opacity: 0.5;
  transition: all 0.3s;
}
.synergy-card.unlocked { opacity: 1; border-color: var(--gold); background: rgba(255,215,0,0.05); }
.synergy-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.synergy-name { font-weight: 600; font-size: 0.8rem; color: var(--gold); }
.synergy-desc { font-size: 0.7rem; color: var(--text-dim); }
.synergy-progress { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.syn-req { font-size: 0.65rem; color: var(--text-dim); padding: 2px 6px; border-radius: 3px; background: rgba(255,255,255,0.03); }
.syn-req.met { color: var(--green); background: rgba(76,175,80,0.08); }

/* ── Skills ── */
.skill-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--amber);
  font-weight: 600;
}
.skill-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.skill-section.locked { opacity: 0.4; }
.skill-category-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--amber);
}
.skill-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.skill-card.owned { border-color: var(--amber-dim); }
.skill-card.maxed { border-color: var(--green); }
.skill-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.skill-icon { font-size: 1rem; }
.skill-name { flex: 1; font-weight: 600; font-size: 0.8rem; }
.skill-level { font-family: var(--mono); font-size: 0.75rem; color: var(--amber); }
.skill-desc { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 4px; }
.skill-btn {
  width: 100%;
  padding: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  background: rgba(245,166,35,0.1);
  color: var(--amber);
  cursor: pointer;
}
.skill-btn:hover { background: rgba(245,166,35,0.2); }
.skill-btn.disabled { opacity: 0.3; cursor: not-allowed; }
.skill-maxed { font-size: 0.7rem; color: var(--green); text-align: center; }
.skill-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.skill-bar-fill { height: 100%; background: var(--amber); border-radius: 2px; }

/* ── Specialization Modal ── */
.spec-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.spec-choice {
  padding: 12px;
  font-size: 0.85rem;
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  background: rgba(245,166,35,0.05);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.spec-choice:hover { background: rgba(245,166,35,0.15); border-color: var(--gold); }
#spec-btn-a { border-color: #4caf50; }
#spec-btn-a:hover { background: rgba(76,175,80,0.1); }
#spec-btn-b { border-color: #2196f3; }
#spec-btn-b:hover { background: rgba(33,150,243,0.1); }
.spec-a-name { display: block; color: #4caf50; font-weight: 600; }
.spec-b-name { display: block; color: #2196f3; font-weight: 600; }

/* ── Toast Types ── */
.toast-crit { background: #3e2a1a; border: 1px solid #ff5722; color: #ff5722; }

/* ── Modal Close ── */
.modal-close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
}
.modal-close-btn:hover { border-color: var(--amber); color: var(--amber); }
