:root {
  /* Complete palette as CSS variables */
  --web-black: #111111;
  --deep-purple: #1f1723;
  --royal-purple: #3c2f52;
  --royal-blue: #4656a5;
  --sky-blue: #4995f3;
  --light-cyan: #72deeb;
  --forest-green: #2d8f39;
  --bright-green: #3ec54b;
  --lime-green: #b4e656;
  --burnt-orange: #d86830;
  --light-orange: #f09548;
  --pale-yellow: #efd081;
  --deep-red: #b22741;
  --bright-red: #f5464c;
  --coral-pink: #f79c88;
  --muted-purple: #8c7f90;
  --light-grey: #bcb0b3;
  --off-white: #e2e2e2;
  --web-white: #fafafa;

  /* Spacing */
  --space-xxs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Typography */
  --font-size-md: 0.5rem;
  --font-size-xs: 0.75em;
  --font-size-sm: 0.875em;
  --font-size-lg: 1.125em;
  --font-size-xl: 1.25em;

  /* Border Radius */
  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--light-grey);
  color: var(--web-black);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.header {
  background: var(--pale-yellow);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 3px solid var(--royal-purple);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-map-marker {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  cursor: pointer;
  font-size: 1.2rem;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.2s, background 0.2s;
}

.header-map-marker:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.5);
}

.header-divider {
  color: var(--muted-purple);
  font-weight: bold;
  font-size: 1.1rem;
  margin: 0 4px;
  display: flex;
  align-items: center;
}

.header-location-visual {
  font-size: 1.8rem;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

.location-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.location-name {
  font-size: var(--font-size-lg);
  font-weight: bold;
  color: var(--web-black);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.location-subtitle {
  font-size: var(--font-size-xs);
  color: var(--royal-purple);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-stats {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
}

.stat-item {
  padding: var(--space-xxs) var(--space-xs);
  background: var(--web-white);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--light-grey);
}

.stat-label {
  color: var(--royal-purple);
}

.stat-value {
  color: var(--web-black);
  font-weight: bold;
}

/* Trade Scene */
/* === Trade Scene === */
#tradeScene {
  background: var(--color-wood);
  border: 2px solid var(--color-gold);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
}


.scene {
  display: none; /* 👈 HIDE ALL SCENES BY DEFAULT */
  background: var(--web-white);
  border: 2px solid var(--pale-yellow);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
  margin: var(--space-lg);
  flex: 1;
  min-height: 0; /* 👈 This is crucial for flex children to work properly */
}

.scene.active {
  display: block; /* 👈 SHOW ONLY THE ACTIVE SCENE */
}

#mapScene.active {
  display: flex; /* 👈 Override for map scene to use flexbox */
  flex-direction: column;
  min-height: 80dvh; /* 👈 Take full viewport height when active */
}

#tradeHeader {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--muted-purple);
}

#locationName {
  font-size: var(--font-size-lg);
  font-weight: bold;
  color: var(--web-black);
}

#travelTime {
  font-size: var(--font-size-sm);
  color: var(--royal-purple);
  font-style: italic;
}

#tradeContent {
  padding: var(--space-md);
  min-height: 300px;
}

.panel-banner {
  background: var(--royal-purple);
  color: var(--web-white);
  padding: var(--space-sm);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-md);
  font-weight: bold;
  text-align: center;
}

.panel-insight {
  background: var(--muted-purple);
  color: var(--web-white);
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-md);
  font-style: italic;
  text-align: center;
}

/* Item Grid & Rows */
#itemGrid {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.item-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: var(--space-xs);
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  margin: var(--space-xs) 0;
  background: var(--pale-yellow);
  border-radius: var(--border-radius-md);
  border: 2px solid var(--light-orange);
  transition: all 0.2s ease;
}

.item-row:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

.item-row.good-deal {
  background: var(--pale-yellow);
  border-color: var(--light-orange);
}

.item-row.bad-deal {
  background: var(--pale-yellow);
  border-color: var(--light-orange);
}

.item-row.no-stock {
  opacity: 0.6;
  background: var(--off-white);
  border-color: var(--light-grey);
}

/* Item Visuals */
.item-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.item-icon {
  font-size: 1.8rem;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

.deal-indicator {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 45px;
  text-align: center;
}

.deal-great {
  background: var(--forest-green);
  color: var(--web-white);
}
.deal-good {
  background: var(--light-orange);
  color: var(--web-black);
}
.deal-fair {
  background: var(--muted-purple);
  color: var(--web-white);
}
.deal-poor {
  background: var(--deep-red);
  color: var(--web-white);
}

/* Item Info */
.item-info {
  flex: 1;
}

.item-header {
  color: var(--web-black);
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.item-price {
  color: var(--web-black);
  font-weight: bold;
  font-size: 1rem;
  margin-left: var(--space-xs);
}

.avg-cost {
  font-size: 0.8rem;
  margin-left: var(--space-xs);
  font-weight: normal;
}

.avg-cost.profit {
  color: var(--bright-green);
}

.avg-cost.loss {
  color: var(--deep-red);
}

.item-meta {
  color: var(--royal-purple);
  font-size: var(--font-size-xs);
  line-height: 1.3;
}

.owned-count {
  color: var(--web-black);
  font-weight: bold;
}

/* Controls & Buttons */
.quantity-action-row {
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
  margin-bottom: 6px;
}

.action-button {
  font-size: var(--font-size-sm);
  font-weight: bold;
  padding: var(--space-xs) var(--space-sm);
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.btn {
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
  transition: all 0.2s ease;
  padding: var(--space-xxs) var(--space-xs);
  font-size: var(--font-size-xs);
  flex: 1;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-buy {
  background: var(--forest-green);
  color: var(--web-white);
}
.btn-sell {
  background: var(--deep-red);
  color: var(--web-white);
}

.quantity-btn {
  background: var(--off-white);
  color: var(--web-black);
  border: 1px solid var(--light-grey);
  padding: 0.3rem 0.5rem;
  font-size: var(--font-size-xs);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
}

.quantity-btn-sell {
  background: var(--deep-red);
  color: var(--web-white);
}

.buy-controls,
.sell-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  width: 120px;
}

.quick-buy-all {
  background: var(--forest-green);
  color: var(--web-white);
}

.quick-sell-all {
  background: var(--deep-red);
  color: var(--web-white);
}

/* Map Scene */
/* .scene {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  flex: 1;
  min-height: 0;
} */

.map-controls {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

button {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-md);
  background: var(--color-emerald);
  color: white;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  margin: var(--space-xs) 0;
}

button:hover {
  background: #2e7a63;
}

#newMapBtn {
  background: #a3a3a3;
  margin-left: var(--space-xs);
}

#newMapBtn:hover {
  background: #8a8a8a;
}

/* Map Grid */
#mapGrid {
  width: 100%;
  background: #f0e6d2;
  border: 1px solid #d4c5a8;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  min-height: 400px;
}

/* Sample terrain canvas styling */
.terrain-canvas {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 0;
}

/* Location markers */
.location-marker {
  position: absolute;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  z-index: 10;
}

.location-marker:hover {
  transform: scale(1.2);
  background: rgba(255, 255, 255, 0.5);
}

.location-marker.current {
  background: rgba(255, 255, 200, 0.6);
  border: 2px solid gold;
  transform: scale(1.3);
}

/* Panels */
.map-panels {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
  min-height: 30vh;
}

.news-panel,
.inventory-panel {
  flex: 1;
  background: var(--color-panel-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.news-panel {
  flex: 2;
}

.news-panel h3,
.inventory-panel h3 {
  background: var(--color-panel-border);
  margin: 0;
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: bold;
}

.panel-content {
  flex: 1;
  padding: var(--space-xs);
  overflow-y: auto;
  font-size: var(--font-size-sm);
}

.news-item,
.inventory-item {
  padding: var(--space-xxs) 0;
  border-bottom: 1px dotted var(--color-panel-border);
}

.quest-item {
  background: var(--color-quest-bg);
  border-left: 3px solid var(--color-quest-border);
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  margin: var(--space-xxs) 0;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.quest-item:hover {
  background: rgba(74, 222, 128, 0.2);
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.inventory-item-icon {
  font-size: 1.2rem;
  animation: sway 3s ease-in-out infinite alternate;
}

@keyframes sway {
  0% {
    transform: rotate(-3deg) scale(1.05);
  }
  100% {
    transform: rotate(3deg) scale(1);
  }
}

.empty-message {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}























/* ============ PHASE 1: MOBILE UI REDESIGN - NEW STYLES ============ */

/* If not already defined, add these new vars to :root */
:root {
    --bright-green: #3ec54b;
    --bright-red: #f5464c;
    --muted-purple: #8c7f90;
    --light-grey: #bcb0b3;
    --off-white: #e2e2e2;
    --web-white: #fafafa;
}

/* Trading Cards - Neutral yellow backgrounds, no confusing colors */
.trade-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.trade-card {
    background: var(--pale-yellow);
    border-radius: 12px;
    border: 2px solid var(--light-orange);
    padding: 20px;
    transition: transform 0.2s ease;
}

.trade-card:active {
    transform: scale(0.98);
}

.trade-card.no-stock {
    opacity: 0.6;
    background: var(--off-white);
    border-color: var(--light-grey);
}

/* Quest item highlight */
.trade-card.quest-item {
    border-color: var(--royal-purple);
    background: linear-gradient(135deg, var(--pale-yellow), #f3f0ff);
}

/* Card Header */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.item-emoji {
    font-size: 36px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

.item-details h3 {
    font-size: 20px;
    font-weight: bold;
    color: var(--web-black);
    margin-bottom: 4px;
}

.item-subtitle {
    font-size: 13px;
    color: var(--royal-purple);
    line-height: 1.3;
}

.price-section {
    text-align: right;
}

.item-price {
    font-size: 22px;
    font-weight: bold;
    color: var(--web-black);
    margin-bottom: 4px;
}

/* Clean coin indicators - only extremes get backgrounds */
.deal-indicator {
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 4px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 24px;
    line-height: 1;
}

/* 1 coin = cheap = good deal (bright green background) */
.deal-great {
    background: var(--bright-green);
    color: var(--web-white);
}

/* 2 coins = average = fair deal (no background, blends in) */
.deal-fair {
    background: transparent;
    color: var(--royal-purple);
}

/* 3 coins = expensive = poor deal (bright red background) */
.deal-poor {
    background: var(--bright-red);
    color: var(--web-white);
}

/* Button System - Matches the coin system for consistency */
.action-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.action-btn {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 52px;
}

/* Buy Button States */
.btn-buy {
    background: var(--forest-green);
    color: var(--web-white);
}

/* Hot buy - matches deal-great coin color */
.btn-buy.hot-buy {
    background: var(--bright-green);
    color: var(--web-white);
    box-shadow: 0 4px 8px rgba(62, 197, 75, 0.3);
}

/* Cold buy - muted green */
.btn-buy.cold-buy {
    background: #4a6741;
    color: var(--web-white);
    opacity: 0.85;
}

/* Sell Button States */
.btn-sell {
    background: var(--deep-red);
    color: var(--web-white);
}

/* Hot sell - matches deal-poor coin color */
.btn-sell.hot-sell {
    background: var(--bright-red);
    color: var(--web-white);
    box-shadow: 0 4px 8px rgba(245, 70, 76, 0.3);
}

/* Cold sell - muted red */
.btn-sell.cold-sell {
    background: #7a1e2f;
    color: var(--web-white);
    opacity: 0.85;
}

.action-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* True disabled state - only for can't afford or no stock */
.action-btn:disabled {
    background: var(--light-grey);
    color: var(--muted-purple);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.owned-display {
    background: var(--web-white);
    border: 1px solid var(--light-grey);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    color: var(--web-black);
    min-width: 80px;
    text-align: center;
}

/* Scroll indicator for LCD users */
.scroll-indicator {
    display: none;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-6px);
    }
    60% {
        transform: translateY(-3px);
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .scroll-indicator {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 16px;
        background: var(--pale-yellow);
        border: 2px solid var(--light-orange);
        border-radius: 8px;
        margin-top: 16px;
        color: var(--royal-purple);
        font-size: 14px;
        font-weight: bold;
    }
    
    .scroll-arrow {
        font-size: 18px;
        animation: bounce 2s infinite;
    }

    .header {
        padding: 12px 16px;
    }
    
    .header-stats {
        gap: 12px;
        font-size: 13px;
    }
    
    .stat-item {
        padding: 6px 10px;
    }
    
    .location-name {
        font-size: 16px;
    }
    
    .item-emoji {
        font-size: 32px;
    }
    
    .item-details h3 {
        font-size: 18px;
    }
    
    .item-price {
        font-size: 20px;
    }
    
    .action-btn {
        padding: 14px 20px;
        font-size: 15px;
        min-height: 48px;
    }
}



.quest-banner {
    background: var(--royal-purple);
    color: var(--web-white);
    padding: 12px 16px;
    font-weight: bold;
    text-align: center;
    font-size: 14px;
}

.market-insight {
    background: var(--muted-purple);
    color: var(--web-white);
    padding: 12px 16px;
    font-style: italic;
    text-align: center;
    font-size: 14px;
}