:root {
  --bg-dark: #0b1412;
  --panel-bg: rgba(13, 25, 22, 0.92);
  --panel-border: rgba(74, 222, 128, 0.22);
  --accent: #34d399;
  --accent-bright: #6ee7b7;
  --gold: #fbbf24;
  --danger: #f87171;
  --text-main: #ecfdf5;
  --text-muted: #94a3b8;
  --card-bg: rgba(22, 39, 34, 0.85);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* TOP HUD */
.hud-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #0e1d19 0%, #091310 100%);
  border-bottom: 1px solid var(--panel-border);
  z-index: 20;
}

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

.brand-icon {
  font-size: 28px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-bright);
}

.planet-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pollution-panel {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.pollution-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 5px;
}

.pollution-label strong {
  color: #fca5a5;
  font-size: 15px;
  transition: color 0.3s;
}

.pollution-label.clean strong {
  color: var(--accent-bright);
}

.pollution-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.pollution-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.pollution-eta {
  font-size: 11px;
  font-weight: 700;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.pollution-bar-track {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pollution-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #eab308 45%, #ef4444 100%);
  transition: width 0.2s ease-out;
  border-radius: 999px;
}

.pollution-milestones {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0.85;
}

.phase-caption {
  font-size: 11px;
  color: var(--accent-bright);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.credits-pill {
  border-color: rgba(251, 191, 36, 0.35);
}

.papers-pill {
  border-color: rgba(52, 211, 153, 0.35);
}

.stat-icon {
  font-size: 20px;
}

.stat-value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.credits-pill .stat-value {
  color: var(--gold);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.icon-btn.active {
  background: rgba(52, 211, 153, 0.25);
  border-color: var(--accent);
  color: var(--accent-bright);
}

.icon-btn.danger:hover {
  background: rgba(248, 113, 113, 0.25);
  border-color: var(--danger);
}

/* MAIN STAGE */
.main-stage {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #1a211e;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* EVENT BANNER */
.event-banner {
  position: absolute;
  top: 12px;
  right: 14px;
  min-width: 240px;
  max-width: 310px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(250, 204, 21, 0.6);
  border-radius: 12px;
  padding: 7px 14px;
  text-align: center;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 25;
}

.event-banner.boss {
  border-color: #e879f9;
  background: rgba(46, 16, 101, 0.9);
  animation: bossPulse 0.85s infinite alternate;
}

@keyframes bossPulse {
  from { box-shadow: 0 0 10px rgba(232, 121, 249, 0.35); }
  to { box-shadow: 0 0 24px rgba(232, 121, 249, 0.78); }
}

.event-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #fef08a;
  margin-bottom: 4px;
}

.event-banner.boss .event-title {
  color: #f5d0fe;
}

.event-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.event-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fde047);
  transition: width 0.12s linear;
}

.event-banner.boss .event-bar-fill {
  background: linear-gradient(90deg, #a855f7, #f472b6);
}

/* OVERLAYS */
.overlay-top-left {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.mini-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-stat {
  background: rgba(10, 20, 17, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #cbd5e1;
}

.mini-stat strong {
  color: var(--accent-bright);
}

/* MISSION CARD */
.mission-card {
  width: 270px;
  background: rgba(11, 24, 20, 0.84);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.mission-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 5px;
}

.mission-title {
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-count {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-bright);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mission-bar-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.mission-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #6ee7b7);
  transition: width 0.18s ease-out;
}

.mission-reward {
  font-size: 10.5px;
  color: #fde68a;
  font-weight: 600;
}

.overlay-bottom-left {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.buff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.combo-badge, .frenzy-badge {
  align-self: flex-start;
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid rgba(251, 146, 60, 0.6);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fdba74;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.combo-timer-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}

#comboTimerFill {
  height: 100%;
  background: linear-gradient(90deg, #f97316, #facc15);
  width: 100%;
}

.frenzy-badge {
  border-color: #facc15;
  color: #fef08a;
  background: rgba(113, 63, 18, 0.88);
  animation: pulseGlow 0.9s infinite alternate;
}

@keyframes pulseGlow {
  from { box-shadow: 0 0 8px rgba(250, 204, 21, 0.35); }
  to { box-shadow: 0 0 20px rgba(250, 204, 21, 0.8); }
}

.ability-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.ability-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.32), rgba(6, 78, 59, 0.85));
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s, filter 0.12s;
}

.ability-btn.skill-overdrive {
  border-color: rgba(56, 189, 248, 0.55);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.32), rgba(12, 74, 110, 0.86));
}

.ability-btn.skill-overdrive.active-buff {
  border-color: #7dd3fc;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.65);
}

.ability-btn.skill-rain {
  border-color: rgba(250, 204, 21, 0.55);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.32), rgba(113, 63, 18, 0.86));
}

.ability-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

.ability-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.78);
}

.ability-key {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  letter-spacing: 0.5px;
}

.ability-cd {
  font-size: 11.5px;
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
}

.skill-overdrive .ability-cd {
  color: #7dd3fc;
}

.skill-rain .ability-cd {
  color: #fde047;
}

.controls-hint {
  background: rgba(10, 20, 17, 0.72);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11px;
  color: #cbd5e1;
}

/* TOASTS */
.toast-container {
  position: absolute;
  top: 72px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 30;
}

.toast {
  background: rgba(15, 32, 27, 0.94);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: slideIn 0.25s ease-out;
}

.toast.gold {
  border-left-color: var(--gold);
  color: #fde68a;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* SHOP SIDEBAR */
.shop-panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 15;
}

.shop-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tab-btn {
  position: relative;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

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

.tab-btn.active {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--accent-bright);
}

.tab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
}

.shop-buy-mode {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.buy-mult-group {
  display: flex;
  gap: 4px;
}

.mult-btn {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mult-btn.active {
  background: var(--accent);
  color: #052e16;
  border-color: var(--accent);
}

.shop-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-list::-webkit-scrollbar {
  width: 6px;
}

.shop-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.upgrade-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.15s, transform 0.1s;
}

.upgrade-card.affordable {
  border-color: rgba(52, 211, 153, 0.45);
}

.upgrade-card.affordable:hover {
  border-color: var(--accent-bright);
}

.upgrade-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.upgrade-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upgrade-icon {
  font-size: 22px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  flex-shrink: 0;
}

.upgrade-name {
  font-size: 13.5px;
  font-weight: 700;
}

.upgrade-level {
  font-size: 11px;
  color: var(--accent-bright);
  font-weight: 700;
  background: rgba(52, 211, 153, 0.14);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.upgrade-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.upgrade-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.upgrade-effect {
  font-size: 11.5px;
  color: #a7f3d0;
  font-weight: 600;
}

.buy-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  transition: all 0.15s;
}

.buy-btn.can-buy {
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.3);
}

.buy-btn.can-buy:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.buy-btn.maxed {
  background: rgba(52, 211, 153, 0.2);
  color: var(--accent-bright);
  cursor: default;
}

/* ACHIEVEMENTS */
.ach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.65;
}

.ach-card.unlocked {
  opacity: 1;
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
}

.ach-icon {
  font-size: 24px;
}

.ach-title {
  font-size: 13px;
  font-weight: 700;
}

.ach-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* PRESTIGE FOOTER */
.prestige-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(251, 191, 36, 0.3);
  background: linear-gradient(180deg, rgba(120, 53, 15, 0.25), rgba(69, 26, 3, 0.45));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.prestige-info {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #fde68a;
}

.prestige-info small {
  font-size: 11px;
  color: #fcd34d;
}

.prestige-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #fbbf24;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal-card {
  width: min(480px, 92vw);
  background: #0f1f1b;
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.modal-trophy {
  font-size: 52px;
  margin-bottom: 8px;
}

.modal-card h2 {
  color: var(--accent-bright);
  font-size: 22px;
  margin-bottom: 10px;
}

.modal-card p {
  font-size: 14px;
  color: #d1fae5;
  line-height: 1.5;
  margin-bottom: 16px;
}

.victory-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
  border-radius: 10px;
  font-size: 12.5px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #022c22;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hud-top {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .main-stage {
    flex-direction: column;
  }
  .shop-panel {
    width: 100%;
    height: 36vh;
    border-left: none;
    border-top: 1px solid var(--panel-border);
  }
  .toast-container {
    top: 46px;
    right: 10px;
    max-width: 240px;
  }
  .mission-card {
    display: none;
  }
  .controls-hint {
    display: none;
  }
}
