/* Business Tycoon - layout and theme */
:root {
  --bg: #1a1d29;
  --surface: #252936;
  --surface-hover: #2e3344;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #7caf5e;
  --accent-hover: #8fc76a;
  --danger: #d9655c;
  --gold: #e8c547;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body[data-theme="rainbow"] {
  background: linear-gradient(
    135deg,
    #2a0a18 0%,
    #2a1810 15%,
    #2a2a0a 30%,
    #0a2a18 45%,
    #0a182a 60%,
    #18102a 75%,
    #2a0a2a 100%
  );
  background-attachment: fixed;
}

.game-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header & stats */
.header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.header h1 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gold);
}

.stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat .value {
  font-size: 1.25rem;
  font-weight: 600;
}

.stat.balance .value {
  color: var(--accent);
}

.stat.income .value {
  color: var(--accent);
}

.stat.costs .value {
  color: var(--danger);
}

.tick-feedback {
  min-height: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.tick-feedback .gain {
  color: var(--accent);
}

.tick-feedback .loss {
  color: var(--danger);
}

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

.header-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.event-banner {
  display: none;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  text-align: center;
  background: var(--gold);
  color: #111;
}

.event-banner.visible {
  display: block;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.9; }
}

/* Main grid */
.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-hint {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.9rem;
}

.list-item .name {
  font-weight: 500;
}

.list-item .count {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.list-item-employee {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-item-employee .name {
  flex: 1;
}

.list-item-employee .count {
  flex-shrink: 0;
}

.btn-fire {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--danger);
  color: #fff;
}

.btn-fire:hover {
  filter: brightness(1.1);
}

.purchases {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-buy {
  background: var(--accent);
  color: #111;
}

.btn-buy:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-buy:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-hire {
  background: var(--gold);
  color: #111;
}

.btn-hire:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-hire:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-upgrade {
  background: #6b8cce;
  color: #111;
}

.btn-upgrade:hover:not(:disabled) {
  filter: brightness(1.15);
}

.btn-upgrade:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loan {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--text-muted);
}

.btn-repay {
  background: var(--danger);
  color: #fff;
}

.btn-repay:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-repay:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-mute {
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-prestige {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  color: #fff;
}

.btn-prestige:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-prestige:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Mini map */
.map-panel {
  grid-column: 1 / -1;
}

.minimap-wrap {
  background: var(--bg);
  border-radius: 6px;
  padding: 4px;
  display: inline-block;
}

#minimap {
  display: block;
  border-radius: 4px;
  max-width: 100%;
  height: auto;
}

/* Log */
.log-panel {
  grid-column: 1 / -1;
}

.log {
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--bg);
}

.log-entry:last-child {
  border-bottom: none;
}

/* Popup feedback */
.popup-gain {
  color: var(--accent);
  font-weight: 600;
  animation: popup 1s ease-out forwards;
}

@keyframes popup {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px);
  }
}

/* Tutorial overlay */
.tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.tutorial-overlay.visible {
  display: flex;
}

.tutorial-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.tutorial-text {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  line-height: 1.5;
}

.tutorial-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.list-item-building {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.list-item-building .name { flex: 1; min-width: 0; }
.list-item-building .count { flex-shrink: 0; }

.speed-control, .slot-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.speed-control .label, .slot-control .label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slot-control button.active {
  background: var(--accent);
  color: #111;
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.options-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--text-muted);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
}

.contract-text {
  margin: 0;
  font-size: 0.9rem;
}

.stats-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.stats-overlay.visible {
  display: flex;
}

.stats-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 320px;
  box-shadow: var(--shadow);
}

.stats-card h2 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.stats-card #stats-body p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.stats-card button {
  margin-top: 1rem;
}
