:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", Roboto, sans-serif;
  --bg: #060b14;
  --bg-2: #0f1b2d;
  --panel: #121f33;
  --panel-2: #172a43;
  --border: #2c4666;
  --text: #f4f7ff;
  --muted: #8fa6c4;
  --accent: #7cf0b4;
  --accent-2: #6da8ff;
  --warning: #ffbe45;
  --danger: #ff6f6f;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(109, 168, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(124, 240, 180, 0.14), transparent 24%),
    linear-gradient(140deg, var(--bg) 0%, var(--bg-2) 45%, #0b1324 100%);
  color: var(--text);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: linear-gradient(135deg, var(--accent), #35b989);
  color: #03110b;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  box-shadow: 0 10px 24px rgba(53, 185, 137, 0.15);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 26px rgba(66, 211, 146, 0.22);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: linear-gradient(135deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(18, 31, 51, 0.95), rgba(11, 21, 38, 0.9));
  backdrop-filter: blur(20px);
  margin-bottom: 1.2rem;
  box-shadow: 0 18px 50px var(--shadow);
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 800;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.hero-copy {
  margin: 0.6rem 0 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  overflow: visible;
}

.hero-glow {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 168, 255, 0.22), transparent 72%);
  filter: blur(10px);
  animation: pulseGlow 2.4s ease-in-out infinite;
}

.purchase-particle {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(124, 240, 180, 0.95), rgba(109, 168, 255, 0.9));
  box-shadow: 0 0 10px rgba(124, 240, 180, 0.6);
  opacity: 0;
  animation: purchaseBurst 900ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.floating-feedback {
  position: fixed;
  z-index: 9999;
  transform: translate(-50%, 0);
  pointer-events: none;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #e9f7ff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  animation: feedbackRise 900ms cubic-bezier(0.18, 0.74, 0.24, 1) forwards;
}

.floating-feedback.purchase {
  color: var(--accent);
}

.floating-feedback.upgrade {
  color: var(--accent-2);
}

.floating-feedback.ascend {
  color: #ffd97b;
}

.factory-illustration {
  position: relative;
  width: 140px;
  height: 100px;
}

.factory-base {
  position: absolute;
  bottom: 8px;
  left: 18px;
  width: 104px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2f496c, #16263d);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.factory-tower {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 40px;
  width: 52px;
  height: 48px;
  border-radius: 12px 12px 10px 10px;
  background: linear-gradient(135deg, var(--accent-2), #1f4d87);
  box-shadow: 0 0 24px rgba(109, 168, 255, 0.25);
}

.factory-smoke {
  position: absolute;
  left: 56%;
  bottom: 74px;
  width: 10px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  filter: blur(3px);
  animation: drift 2.6s ease-in-out infinite;
  opacity: 0.7;
}

.smoke-2 {
  left: 64%;
  animation-delay: -1.2s;
}

@keyframes drift {
  0% { transform: translateY(0) scale(1); opacity: 0.3; }
  50% { transform: translateY(-10px) scale(1.08); opacity: 0.75; }
  100% { transform: translateY(-22px) scale(1.25); opacity: 0; }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(0.96); opacity: 0.8; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes purchaseBurst {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  20% { opacity: 0.9; }
  100% { transform: translate(var(--dx), var(--dy)) scale(var(--scale)); opacity: 0; }
}

@keyframes feedbackRise {
  0% { transform: translate(-50%, 0) scale(0.9); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(-50%, -34px) scale(1.02); opacity: 0; }
}

.hero-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.auth-card {
  min-width: 250px;
  padding: 0.85rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.auth-form input {
  padding: 0.65rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(7, 13, 24, 0.75);
  color: var(--text);
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
}

.auth-link-btn {
  margin-top: 0.1rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
  text-align: left;
}

.auth-link-btn:hover {
  color: var(--accent-2);
  transform: none;
  filter: none;
  box-shadow: none;
  text-decoration: underline;
}

.auth-hidden {
  display: none;
}

.speed-group {
  display: inline-flex;
  gap: 0.4rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.speed-btn.active {
  background: linear-gradient(135deg, var(--accent-2), #3b82f6);
  color: white;
}

.dashboard {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 1rem;
}

body.auth-locked .dashboard,
body.auth-locked .hero-actions,
body.auth-locked .buildings-panel,
body.auth-locked .power-panel,
body.auth-locked .log-panel {
  opacity: 0.5;
}

body.auth-locked .dashboard,
body.auth-locked .hero-actions {
  pointer-events: none;
}

.panel {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(18, 31, 51, 0.96), rgba(12, 21, 39, 0.95));
  padding: 1rem 1.2rem;
  box-shadow: 0 20px 50px var(--shadow);
}

.resources-panel,
.power-panel,
.log-panel {
  min-height: 280px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.95rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.clock {
  color: var(--accent-2);
  font-weight: 700;
}

.game-notice {
  min-height: 1.6rem;
  margin-bottom: 0.6rem;
  padding: 0.3rem 0.6rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
}

.game-notice.success {
  color: var(--accent);
  border-color: rgba(124, 240, 180, 0.35);
}

.game-notice.warning {
  color: var(--warning);
  border-color: rgba(255, 190, 69, 0.35);
}

.resource-list {
  display: grid;
  gap: 0.7rem;
}

.resource-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0.95rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform 140ms ease, border-color 140ms ease;
}

.resource-item:hover {
  transform: translateY(-1px);
  border-color: rgba(109, 168, 255, 0.35);
}

.resource-item.active {
  border-color: rgba(124, 240, 180, 0.4);
  box-shadow: inset 0 0 0 1px rgba(124, 240, 180, 0.16), 0 0 20px rgba(124, 240, 180, 0.12);
  animation: pulseGlow 1.2s ease-in-out infinite;
}

.resource-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 700;
}

.resource-label span:first-child {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: rgba(109, 168, 255, 0.16);
  font-size: 1.1rem;
}

.resource-value {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.resource-meta {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 0.2rem;
}

.resource-subtext {
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-subtitle {
  margin: 1rem 0 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

.milestone-list {
  display: grid;
  gap: 0.55rem;
}

.milestone-item {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.milestone-item.completed {
  border-color: rgba(66, 211, 146, 0.35);
  background: rgba(66, 211, 146, 0.08);
}

.milestone-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.milestone-status {
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
}

.milestone-item.completed .milestone-status {
  color: var(--accent);
}

.contract-card {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: start;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.contract-card.completed {
  border-color: rgba(66, 211, 146, 0.35);
  background: rgba(66, 211, 146, 0.08);
}

.contract-reward {
  font-size: 0.82rem;
  color: var(--accent-2);
  margin-top: 0.28rem;
}

.contract-action {
  white-space: nowrap;
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(90, 164, 255, 0.16);
  color: #b8d8ff;
  font-size: 0.84rem;
}

.goal-card {
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124, 240, 180, 0.12), rgba(109, 168, 255, 0.1));
  border: 1px solid rgba(124, 240, 180, 0.14);
  margin-bottom: 0.7rem;
}

.goal-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.goal-copy {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.goal-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: 0.35rem;
}

.goal-bar > div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.goal-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.ascension-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124, 240, 180, 0.14), rgba(109, 168, 255, 0.12));
  border: 1px solid rgba(124, 240, 180, 0.2);
  margin-bottom: 0.7rem;
  cursor: pointer;
}

.ascension-title {
  font-weight: 700;
}

.ascension-copy {
  color: var(--muted);
  font-size: 0.9rem;
}

.ascension-meta {
  color: var(--accent-2);
  font-size: 0.82rem;
}

.ascension-card button {
  align-self: flex-start;
  padding: 0.48rem 0.8rem;
  font-size: 0.84rem;
}

.upgrade-card {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease;
}

.upgrade-card:hover {
  transform: translateY(-1px);
  border-color: rgba(109, 168, 255, 0.35);
}

.upgrade-card.owned {
  border-color: rgba(124, 240, 180, 0.28);
  background: rgba(124, 240, 180, 0.08);
}

.upgrade-action {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 0.35rem;
}

.upgrade-action button {
  padding: 0.45rem 0.75rem;
  font-size: 0.84rem;
}

.building-grid {
  display: grid;
  gap: 0.75rem;
}

.factory-floor {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.factory-floor-list {
  display: grid;
  gap: 0.55rem;
}

.floor-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.floor-item.active {
  border-color: rgba(124, 240, 180, 0.36);
  box-shadow: inset 0 0 0 1px rgba(124, 240, 180, 0.16);
}

.floor-item.standby {
  border-color: rgba(255, 190, 69, 0.26);
}

.floor-item.offline {
  opacity: 0.78;
}

.floor-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.floor-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.floor-copy {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.floor-detail {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.76rem;
}

.building-card {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 44, 68, 0.9), rgba(16, 28, 47, 0.95));
  padding: 0.95rem;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  animation: riseIn 260ms ease-out;
}

.building-card:focus-visible,
.ascension-card:focus-visible {
  outline: 2px solid rgba(124, 240, 180, 0.7);
  outline-offset: 2px;
}

@keyframes riseIn {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

.building-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(109, 168, 255, 0.12), transparent 45%);
  pointer-events: none;
}

.building-card.active {
  border-color: rgba(124, 240, 180, 0.35);
  box-shadow: 0 0 0 1px rgba(124, 240, 180, 0.15), 0 0 24px rgba(124, 240, 180, 0.12);
  animation: pulseGlow 1.4s ease-in-out infinite;
}

.building-card.affordable {
  border-color: rgba(255, 190, 69, 0.35);
}

.building-card.offline {
  opacity: 0.9;
}

.building-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.building-title strong {
  font-size: 1rem;
}

.building-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.building-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.building-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.building-status.active {
  background: rgba(124, 240, 180, 0.14);
  color: var(--accent);
}

.building-status.standby {
  background: rgba(255, 190, 69, 0.14);
  color: var(--warning);
}

.building-status.locked {
  background: rgba(255,255,255,0.08);
  color: var(--muted);
}

.building-title span {
  color: var(--muted);
  font-size: 0.85rem;
}

.building-description {
  color: var(--muted);
  margin: 0 0 0.7rem;
  line-height: 1.5;
  font-size: 0.92rem;
}

.building-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.cost-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.7rem;
  background: rgba(90, 164, 255, 0.16);
  border-radius: 999px;
  color: #b8d8ff;
  font-size: 0.82rem;
}

.power-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.power-stat {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border-radius: 16px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid rgba(255,255,255,0.06);
}

.power-stat span {
  color: var(--muted);
  font-size: 0.84rem;
}

.power-stat strong {
  font-size: 1rem;
}

.meter {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.meter > div {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
  box-shadow: 0 0 18px rgba(109, 168, 255, 0.34);
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
  max-height: 18rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.log-item {
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
  padding: 0.6rem 0.75rem;
}

.log-item.empty {
  color: var(--muted);
  text-align: center;
}

.log-item small {
  display: block;
  color: var(--accent-2);
  margin-bottom: 0.25rem;
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 660px) {
  .hero {
    flex-direction: column;
  }

  .power-stats {
    grid-template-columns: 1fr;
  }
}
