/*
 * TSTP World Map CSS
 * All --world-* CSS vars bridged from --tstp-*
 */
:root {
  --world-accent: var(--tstp-accent, #7c3aed);
  --world-surface: var(--tstp-surface, #1e1e2e);
  --world-text: var(--tstp-text, #e2e8f0);
  --world-gold: var(--tstp-gold, #f59e0b);
  --world-border: var(--tstp-border, #334155);
  --world-muted: var(--tstp-muted, #64748b);
  --world-danger: var(--tstp-danger, #ef4444);
  --world-map-entertainment: #7c3aed;
  --world-map-downtown: #3b82f6;
  --world-map-financial: #f59e0b;
  --world-map-industrial: #6b7280;
  --world-map-residential: #10b981;
  --world-map-countryside: #84cc16;
  --world-map-offshore: #06b6d4;
}

body {
  margin: 0;
  background: var(--world-surface);
  color: var(--world-text);
  font-family: 'Inter', Arial, sans-serif;
  min-height: 100vh;
}

.world-hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--world-surface);
  border-bottom: 1px solid var(--world-border);
  display: flex;
  align-items: center;
  z-index: 100;
  padding: 0 24px;
  gap: 24px;
}

.world-hud-nav {
  display: flex;
  gap: 8px;
}
.world-hud-nav button {
  background: none;
  border: none;
  color: var(--world-text);
  font-size: 18px;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.world-hud-nav button.is-active {
  background: var(--world-accent);
  color: #fff;
}

.world-main {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 60px);
  margin-top: 60px;
}

.world-map-container {
  flex: 1;
  position: relative;
  background: var(--world-surface);
  min-width: 0;
}
canvas#worldMapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.world-sidebar {
  width: 320px;
  background: var(--world-surface);
  border-left: 1px solid var(--world-border);
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: 400px;
  z-index: 10;
}

.world-panel {
  background: var(--world-surface);
  border: 1px solid var(--world-border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px;
}

.world-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid var(--world-border);
  background: var(--world-muted);
  color: var(--world-text);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.world-btn:hover, .world-btn:focus-visible {
  background: var(--world-accent);
  color: #fff;
  border-color: var(--world-accent);
}
.world-btn-primary {
  background: var(--world-accent);
  color: #fff;
  border-color: var(--world-accent);
}
.world-btn-primary:hover, .world-btn-primary:focus-visible {
  background: #fff;
  color: var(--world-accent);
}
.world-btn-danger {
  background: var(--world-danger);
  color: #fff;
  border-color: var(--world-danger);
}
.world-btn-danger:hover, .world-btn-danger:focus-visible {
  background: #fff;
  color: var(--world-danger);
}

.world-tab {
  display: none;
}
.world-tab.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.world-district-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-right: 8px;
  background: var(--world-accent);
}

.world-business-card, .world-job-card {
  background: var(--world-surface);
  border: 1px solid var(--world-border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(30,30,46,0.04);
}

.world-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes coin-pop {
    0% { transform: scale(0.7); opacity: 0.5; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }
  @keyframes level-up-flash {
    0% { background: var(--world-gold); }
    100% { background: var(--world-surface); }
  }
  @keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 var(--world-accent, #7c3aed); }
    70% { box-shadow: 0 0 0 12px rgba(124,58,237,0); }
    100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); }
  }
}

@media (max-width: 1024px) {
  .world-sidebar {
    width: 220px;
    min-width: 120px;
  }
}
/* Venue modal */
.venue-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.venue-modal[hidden] { display: none; }
.venue-modal-card {
  background: var(--world-surface, #1e1e2e);
  border: 1px solid var(--world-border, #334155);
  border-radius: 16px; padding: 2rem; text-align: center;
  min-width: 280px; max-width: 380px;
  position: relative;
  color: var(--world-text, #e2e8f0);
}
.venue-modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; color: var(--world-text, #f1f5f9);
  font-size: 1.2rem; cursor: pointer;
}
.venue-modal-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.btn-enter-venue {
  display: inline-block; margin-top: 1rem; padding: 0.75rem 2rem;
  background: var(--world-accent, #7c3aed); color: #fff;
  border-radius: 8px; text-decoration: none; font-weight: bold;
}
.btn-enter-venue:hover, .btn-enter-venue:focus-visible {
  background: var(--world-text, #e2e8f0);
  color: var(--world-accent, #7c3aed);
  outline: none;
}
@media (prefers-reduced-motion: no-preference) {
  .venue-modal-card { animation: modal-in 200ms ease-out; }
  @keyframes modal-in {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
  }
}

@media (max-width: 768px) {
  .world-main {
    flex-direction: column;
  }
  .world-sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: unset;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    height: 320px;
    border-left: none;
    border-top: 1px solid var(--world-border);
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(30,30,46,0.08);
  }
  /* Mobile HUD: stack player info + wallet on top, nav scrolls below */
  .world-hud {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px 4px;
    gap: 8px;
  }
  .world-hud-player {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .world-hud-nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 4px;
    /* Fade right edge to hint scrollable content */
    mask-image: linear-gradient(to right, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
  }
  .world-hud-nav::-webkit-scrollbar { display: none; }
  /* Smaller touch targets on mobile so more tabs show in initial view */
  .world-hud-nav button,
  .world-btn {
    font-size: 13px;
    padding: 5px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .world-main {
    margin-top: 80px;
    height: calc(100vh - 80px);
  }
}

/* ===== Tab Content Shared ===== */
.world-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--world-muted);
  font-style: italic;
}
.world-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--world-danger);
}
.world-tab.is-active {
  overflow-y: auto;
}
/* Headings within tabs */
.world-tab h2 {
  margin: 0 0 1.25rem;
  font-size: 1.4rem;
  font-weight: 700;
}

/* ===== Bank Tab ===== */
.world-bank-panel {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}
.bank-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: var(--world-gold);
}
.bank-balances {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}
.bank-balance-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--world-border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bank-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--world-muted);
}
.bank-amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--world-gold);
}
.bank-rate {
  font-size: 0.75rem;
  color: var(--world-muted);
}
.bank-credit {
  margin-bottom: 1.5rem;
  color: var(--world-muted);
  font-size: 0.9rem;
}
.credit-score {
  color: var(--world-text);
  font-size: 1rem;
}
.bank-actions {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--world-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bank-action-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.bank-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--world-border);
  border-radius: 6px;
  color: var(--world-text);
  font-size: 0.95rem;
  padding: 9px 12px;
  min-width: 0;
}
.bank-input:focus { outline: 2px solid var(--world-accent); border-color: var(--world-accent); }
.bank-select {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--world-border);
  border-radius: 6px;
  color: var(--world-text);
  font-size: 0.95rem;
  padding: 9px 12px;
  cursor: pointer;
}
.btn-bank-action {
  flex: 1;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  background: var(--world-accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s;
}
.btn-bank-action:hover, .btn-bank-action:focus-visible { background: #9b5cf6; }
.btn-bank-withdraw { background: var(--world-danger); }
.btn-bank-withdraw:hover, .btn-bank-withdraw:focus-visible { background: #f87171; }
.bank-msg {
  color: var(--world-danger);
  font-size: 0.9rem;
  min-height: 1.4em;
  padding-top: 4px;
}

/* ===== Businesses Tab ===== */
.world-business-panel, .world-businesses-panel {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}
.world-business-panel > p, .world-businesses-panel > p {
  color: var(--world-muted);
  padding: 2rem 0;
  text-align: center;
}
.biz-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--world-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s;
}
.biz-card:hover { border-color: var(--world-accent); }
.biz-card strong { flex: 1; color: var(--world-text); font-size: 1rem; }
.biz-type {
  font-size: 0.78rem;
  color: var(--world-muted);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 3px 10px;
}
.biz-level {
  font-size: 0.82rem;
  color: var(--world-gold);
  font-weight: 700;
  background: rgba(245,158,11,0.12);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ===== Market Tab ===== */
.world-market-panel {
  max-width: 820px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}
.market-listings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.market-listings th {
  text-align: left;
  padding: 10px 12px;
  color: var(--world-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--world-border);
}
.market-listings td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(51,65,85,0.4);
  color: var(--world-text);
}
.market-listings tr:last-child td { border-bottom: none; }
.market-listings tr:hover td { background: rgba(255,255,255,0.03); }
.btn-buy-listing {
  background: var(--world-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
  min-height: 36px;
}
.btn-buy-listing:hover, .btn-buy-listing:focus-visible { background: #9b5cf6; }

/* ===== Jobs Tab ===== */
.world-jobs-panel {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}
.job-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--world-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s;
}
.job-card:hover { border-color: var(--world-accent); }
.job-icon { font-size: 2rem; flex-shrink: 0; width: 2.5rem; text-align: center; }
.job-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.job-info strong { font-size: 1rem; color: var(--world-text); }
.job-biz { font-size: 0.8rem; color: var(--world-muted); }
.job-reward { font-size: 0.9rem; color: var(--world-gold); font-weight: 700; }
.btn-take-job {
  background: var(--world-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
  flex-shrink: 0;
  min-height: 44px;
}
.btn-take-job:hover, .btn-take-job:focus-visible { background: #9b5cf6; }
