/* ==========================================================================
   ESTILS PER AL JOC ARCADE WEBGL PIXEL ART: TALLER TYCOON · PUNT D'EQUILIBRI
   INS Pere Borrell · Ciències Aplicades II · 2n FP Bàsica
   ========================================================================== */

.tycoon-wrapper {
  background: #090d16;
  border: 4px solid #1e293b;
  border-radius: 14px;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  color: #f8fafc;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(15, 23, 42, 0.8);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  margin: 1.5rem 0;
  position: relative;
  overflow: hidden;
}

/* BARRA SUPERIOR */
.tycoon-hud-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: #0f172a;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #1e293b;
  margin-bottom: 0.85rem;
}

.hud-scenario {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-grow: 1;
}

.hud-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.05em;
  font-family: 'Fira Code', monospace;
}

.tycoon-select {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.tycoon-select:focus {
  border-color: #10b981;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tycoon-btn-sm {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Fira Code', monospace;
}

.tycoon-btn-sm:hover {
  background: #334155;
  border-color: #64748b;
}

/* PANELL PERSONALITZAT MODE LLIURE */
.tycoon-custom-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  background: #111827;
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px dashed #374151;
  margin-bottom: 0.85rem;
  align-items: center;
}

.custom-input-group label {
  display: block;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.custom-input-group input[type="range"] {
  width: 100%;
  accent-color: #10b981;
}

.custom-summary {
  grid-column: 1 / -1;
  background: #1f2937;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #e5e7eb;
}

/* TARGETES FINANCERES (LIVE HUD) */
.tycoon-financial-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.finance-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.finance-card.highlight-card {
  background: #0c1427;
  border-color: #3b82f6;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.f-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.05em;
  font-family: 'Fira Code', monospace;
  margin-bottom: 0.15rem;
}

.f-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  line-height: 1.1;
}

.f-sub {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.text-red { color: #f87171; }
.text-amber { color: #fbbf24; }
.text-blue { color: #60a5fa; }
.text-danger-strong { color: #ef4444; }
.text-amber-strong { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.text-success-strong { color: #10b981; text-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }

/* CONTENIDOR DEL CANVAS WEBGL PIXEL ART */
.tycoon-canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: #030712;
  border-radius: 10px;
  border: 2px solid #1e293b;
  padding: 0.5rem;
  overflow: hidden;
}

#tycoon-webgl-canvas {
  width: 100%;
  max-width: 640px;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 6px;
  background: #000;
  /* Nitidesa retro pixel art estricta */
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  outline: none;
}

#tycoon-webgl-canvas:focus-visible {
  box-shadow: 0 0 0 3px #10b981;
}

/* BAFARADA DE PROMPT I INSTRUCCIONS */
.tycoon-action-prompt {
  width: 100%;
  max-width: 640px;
  background: #111827;
  border-left: 4px solid #10b981;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  color: #e5e7eb;
  margin-top: 0.5rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.4;
  box-sizing: border-box;
}

/* CONTROLS TÀCTILS PER A PANTALLES TÀCTILS */
.tycoon-touch-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 640px;
  margin-top: 0.65rem;
  gap: 0.75rem;
}

.touch-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.touch-row {
  display: flex;
  gap: 4px;
}

.touch-btn {
  background: #1e293b;
  color: #f1f5f9;
  border: 2px solid #334155;
  border-radius: 8px;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.touch-btn:active {
  background: #059669;
  border-color: #10b981;
}

.touch-action {
  background: #059669;
  border-color: #10b981;
  font-size: 0.75rem;
  font-family: 'Fira Code', monospace;
}

.touch-quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.touch-target-btn {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.touch-target-btn:hover, .touch-target-btn:active {
  background: #334155;
  border-color: #10b981;
}

/* SECCIÓ DE GRÀFICA INTERACTIVA */
.tycoon-graph-section {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.85rem;
  margin-top: 1rem;
}

.graph-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.graph-header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 700;
}

.badge-pe {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
}

.graph-canvas-wrap {
  width: 100%;
  overflow-x: auto;
}

#tycoon-graph-canvas {
  width: 100%;
  max-width: 620px;
  height: 150px;
  display: block;
  border-radius: 6px;
  background: #0f172a;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.65rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.leg-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

@media (max-width: 600px) {
  .tycoon-hud-top {
    flex-direction: column;
    align-items: stretch;
  }
  .hud-actions {
    justify-content: space-between;
  }
  .touch-quick-nav {
    width: 100%;
    justify-content: center;
  }
}
