:root {
  color-scheme: dark;
  --bg: #071019;
  --panel: #111c29;
  --panel-2: #162434;
  --line: #284056;
  --text: #edf6ff;
  --muted: #9cb2c3;
  --gold: #f7c948;
  --green: #59d68b;
  --red: #ff6b6b;
  --cyan: #48c6ef;
  --violet: #8b7cf6;
  --shadow: 0 22px 70px rgba(0, 0, 0, .38);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(72, 198, 239, .12), transparent 34%),
    linear-gradient(135deg, #071019 0%, #0f1723 48%, #151624 100%);
  color: var(--text);
  overflow-x: hidden;
  touch-action: manipulation;
}

button {
  font: inherit;
}

.app {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  padding: 18px;
}

.stage,
.panel {
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(12, 21, 31, .82);
  box-shadow: var(--shadow);
}

.stage {
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  align-items: center;
  background: rgba(255, 255, 255, .03);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 56px);
  line-height: 1;
}

h2 {
  font-size: 17px;
  margin-bottom: 0;
}

h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  width: min(560px, 52%);
}

.metric {
  min-width: 0;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  padding: 12px;
}

.metric span,
.prestige-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong,
.prestige-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.market-ticker {
  border-block: 1px solid rgba(255, 255, 255, .08);
  background: #09131e;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  gap: 34px;
  padding: 11px 0;
  animation: ticker 32s linear infinite;
}

.ticker-item {
  color: var(--muted);
  font-weight: 700;
}

.ticker-item.up {
  color: var(--green);
}

.ticker-item.down {
  color: var(--red);
}

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

.office-wrap {
  position: relative;
  min-height: 420px;
  background: linear-gradient(#0b1d2d, #09111b);
}

#officeCanvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
  image-rendering: pixelated;
}

.office-overlay {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.primary-action,
.wide-action {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7c948, #f59e0b);
  color: #172033;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(245, 158, 11, .22);
}

.primary-action {
  min-width: 176px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .12s ease, filter .12s ease;
}

.primary-action:hover,
.wide-action:hover,
.buy-card button:not(:disabled):hover {
  filter: brightness(1.08);
}

.primary-action:active {
  transform: translateY(2px) scale(.98);
}

.button-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #182231;
  color: var(--gold);
  font-size: 11px;
}

.floating-text {
  color: var(--green);
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  min-width: 150px;
  height: 32px;
  pointer-events: none;
}

.floating-text.pop {
  animation: floatUp .7s ease-out;
}

@keyframes floatUp {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  to {
    transform: translateY(-18px);
    opacity: 0;
  }
}

.panel {
  border-radius: 8px;
  min-width: 0;
  padding: 14px;
  overflow: hidden;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tab.active {
  background: var(--cyan);
  color: #06111a;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

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

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}

.icon-button,
.danger-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #0c1723;
  cursor: pointer;
  font-weight: 900;
}

.danger-button {
  width: auto;
  padding: 0 14px;
  color: #ffd7d7;
  border-color: rgba(255, 107, 107, .35);
}

.upgrade-list,
.portfolio-list {
  display: grid;
  gap: 10px;
}

.buy-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 88px;
  gap: 12px;
  align-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .08);
  padding: 10px;
}

.sprite-badge {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #0b1420;
  border: 1px solid var(--line);
  font-weight: 900;
}

.buy-copy {
  min-width: 0;
}

.buy-copy p {
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.buy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.buy-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
}

.buy-card button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #06130d;
  cursor: pointer;
  font-weight: 900;
}

.buy-card button:disabled {
  cursor: not-allowed;
  background: #34495d;
  color: #8ea3b6;
}

.portfolio-row {
  border-radius: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .045);
}

.portfolio-row header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 900;
}

.portfolio-row .bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #0a141f;
}

.portfolio-row .fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.portfolio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.portfolio-actions button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0c1723;
  color: var(--text);
  cursor: pointer;
}

.prestige-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.prestige-card > div {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .055);
  padding: 12px;
}

.wide-action {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.events {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 14px;
}

.event-log {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
  max-height: 214px;
  overflow: auto;
}

.event-log li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  border-left: 3px solid var(--cyan);
  padding: 6px 8px;
  background: rgba(255, 255, 255, .035);
  border-radius: 0 8px 8px 0;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
  }

  .status-grid {
    width: min(100%, 560px);
  }
}

@media (max-width: 720px) {
  .app {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
    gap: 12px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.02;
  }

  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .metric {
    padding: 8px;
  }

  .metric span {
    font-size: 10px;
  }

  .metric strong {
    font-size: 13px;
  }

  .office-wrap,
  #officeCanvas {
    min-height: 340px;
    height: 58vh;
    max-height: 460px;
  }

  .office-overlay {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .primary-action {
    min-width: 150px;
    height: 54px;
  }

  .panel {
    padding: 10px;
  }

  .panel-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(12, 21, 31, .96);
    padding-bottom: 8px;
  }

  .tab {
    min-height: 40px;
    font-size: 13px;
  }

  .buy-card {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
  }

  .buy-card button {
    grid-column: 1 / -1;
    height: 42px;
  }

  .portfolio-actions button {
    min-height: 42px;
  }
}

@media (max-width: 390px) {
  h1 {
    font-size: 26px;
  }

  .metric strong {
    font-size: 12px;
  }

  .primary-action {
    width: 100%;
  }

  .office-overlay {
    flex-direction: column;
    align-items: stretch;
  }
}
}
