/* css/game.css - Estilização Principal Mobile Portrait do Koa 3D Tycoon */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --primary-coral: #ff5e57;
  --primary-coral-dark: #d63031;
  --accent-teal: #00cec9;
  --accent-teal-dark: #009688;
  --accent-blue: #0984e3;
  --accent-purple: #6c5ce7;
  --gold: #f5b041;
  --gold-dark: #d35400;
  --bg-dark: #0e1117;
  --card-bg: rgba(23, 28, 38, 0.88);
  --card-border: rgba(255, 255, 255, 0.12);
  --glass-bg: rgba(26, 32, 44, 0.75);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text-main: #f8f9fa;
  --text-muted: #a0aec0;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #08090c;
  font-family: var(--font-main);
  color: var(--text-main);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* Container de Enquadramento Mobile Retrato */
#app-viewport {
  width: 100%;
  height: 100%;
  max-width: 440px;
  max-height: 920px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 1px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

@media (min-width: 500px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1b202c 0%, #08090c 100%);
  }

  #app-viewport {
    height: 92vh;
    border-radius: 36px;
    border: 4px solid rgba(255, 255, 255, 0.15);
  }
}

/* Cenas do Jogo */
.game-scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.game-scene.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
  transform: scale(1);
}

.game-scene.entering {
  transform: scale(1.05);
}

/* Imagens de fundo das cenas oficiais */
#scene-street {
  background-image: url('../assets/images/bg-game/bairro-casa.webp');
}

#scene-street.company-tier-1 {
  background-image: url('../assets/images/bg-game/bairro-casa-empresa-n1.png');
}

#scene-street.company-tier-2 {
  background-image: url('../assets/images/bg-game/bairro-casa-empresa-n2.png');
}

#scene-street.company-tier-3 {
  background-image: url('../assets/images/bg-game/bairro-casa-empresa-n3.png');
}

#scene-city {
  background-image: url('../assets/images/bg-game/cidade.jpg');
}

/* Plano 2: Destaque da Oficina */
#scene-workshop {
  background-color: #000;
  background-image: radial-gradient(circle at 50% 35%, rgba(30, 41, 59, 0.85) 0%, rgba(0, 0, 0, 0.98) 75%);
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.workshop-bg-art {
  position: absolute;
  top: calc(55px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  height: 48%;
  background-image: url('../assets/images/bg-game/casa-dentro-n1.jpg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center top;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  transition: background-image 0.3s ease;
}

.workshop-bg-art.is-company {
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.75));
}

/* Header da Oficina */
.workshop-header {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(64px + env(safe-area-inset-top, 0px)) 20px 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
  text-align: center;
}

.workshop-title-box {
  text-align: center;
  flex: 1;
}

.workshop-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.workshop-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.btn-close-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-close-circle:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.3);
}

/* Área Interativa das Impressoras na Oficina */
.workshop-printers-rack {
  position: relative;
  z-index: 12;
  margin-top: 220px;
  padding: 0 12px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  transition: all 0.3s ease;
}

.workshop-printers-rack::-webkit-scrollbar {
  display: none;
}

/* Layout Padrão: 1 ou 2 impressoras (tamanho padrão) */
.workshop-printers-rack.layout-printers-2 {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 225px;
}

.workshop-printers-rack.layout-printers-2 .printer-card {
  flex: 1;
  min-width: 155px;
  max-width: 185px;
}

/* Passou de 2 impressoras (3 máquinas): diminui tamanho e exibe linha com 3 */
.workshop-printers-rack.layout-printers-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 8px;
  margin-top: 215px;
  overflow-x: hidden;
}

.workshop-printers-rack.layout-printers-3 .printer-card {
  min-width: 0;
  width: 100%;
  padding: 8px 4px 6px;
}

.workshop-printers-rack.layout-printers-3 .printer-thumb {
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
}

.workshop-printers-rack.layout-printers-3 .printer-thumb-icon {
  font-size: 22px;
}

.workshop-printers-rack.layout-printers-3 .printer-info-name {
  font-size: 10.5px;
}

.workshop-printers-rack.layout-printers-3 .printer-helper-badge {
  font-size: 9.5px;
  padding: 1.5px 5px;
}

.workshop-printers-rack.layout-printers-3 .printer-status-text {
  font-size: 9.5px;
  line-height: 1.15;
}

.workshop-printers-rack.layout-printers-3 .printer-progress-bar {
  margin-top: 5px;
  height: 5px;
}

.workshop-printers-rack.layout-printers-3 .printer-actions-wrapper {
  gap: 4px;
  margin-top: 5px;
}

.workshop-printers-rack.layout-printers-3 .btn-deliver-printer {
  padding: 6px 2px;
  font-size: 9.5px;
  letter-spacing: 0;
  border-radius: 6px;
}

.workshop-printers-rack.layout-printers-3 .btn-discard-printer {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: 6px;
}

.workshop-printers-rack.layout-printers-3 .btn-store-printer {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: 6px;
}

/* Passou de 3 impressoras (4, 5, 6 ou mais): duas linhas com 3 cada */
.workshop-printers-rack.layout-printers-grid-3x2 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 6px;
  padding: 0 8px;
  margin-top: 160px;
  max-height: 335px;
  overflow-y: auto;
  overflow-x: hidden;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-card {
  min-width: 0;
  width: 100%;
  padding: 7px 4px 5px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-thumb {
  width: 42px;
  height: 42px;
  margin-bottom: 3px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-thumb-icon {
  font-size: 20px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-info-name {
  font-size: 10px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-helper-badge {
  font-size: 9px;
  padding: 1px 4px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-status-text {
  font-size: 9px;
  line-height: 1.15;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-progress-bar {
  margin-top: 4px;
  height: 5px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .printer-actions-wrapper {
  gap: 4px;
  margin-top: 5px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .btn-deliver-printer {
  padding: 5px 2px;
  font-size: 9px;
  letter-spacing: 0;
  border-radius: 6px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .btn-discard-printer {
  width: 26px;
  height: 26px;
  font-size: 12px;
  border-radius: 6px;
}

.workshop-printers-rack.layout-printers-grid-3x2 .btn-store-printer {
  width: 26px;
  height: 26px;
  font-size: 12px;
  border-radius: 6px;
}

.printer-card {
  flex: 1;
  min-width: 170px;
  background: rgba(20, 26, 38, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s, border-color 0.2s;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.printer-card:active {
  transform: scale(0.98);
}

.printer-card.is-printing {
  border-color: var(--accent-teal);
  box-shadow: 0 0 15px rgba(0, 206, 201, 0.25);
}

.printer-card.is-ready {
  border-color: var(--gold);
  animation: pulse-ready 1.5s infinite;
}

@keyframes pulse-ready {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 176, 65, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(245, 176, 65, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(245, 176, 65, 0);
  }
}

.printer-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 8px;
  position: relative;
  overflow: visible;
}

.printer-thumb-img {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  padding: 2px;
}

.printer-thumb-icon {
  font-size: 28px;
  line-height: 1;
}

.printer-status-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a0aec0;
  border: 2px solid #141a26;
}

.printer-card.is-printing .printer-status-dot {
  background: var(--accent-teal);
  box-shadow: 0 0 6px var(--accent-teal);
}

.printer-card.is-ready .printer-status-dot {
  background: var(--gold);
}

.printer-info-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 100%;
}

.printer-status-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.printer-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.printer-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-teal), #55efc4);
  transition: width 0.2s linear;
}

.printer-actions-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}

.printer-actions-wrapper .btn-deliver-printer {
  flex: 1;
  margin-top: 0;
}

.btn-deliver-printer {
  margin-top: 8px;
  width: 100%;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(211, 84, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, filter 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.btn-deliver-printer img.coin-icon-inline {
  width: 14px;
  height: 14px;
  object-fit: contain;
  vertical-align: middle;
}

.btn-deliver-printer:active {
  transform: scale(0.96);
  filter: brightness(1.15);
}

.btn-discard-printer {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  background: rgba(235, 87, 87, 0.15);
  border: 1px solid rgba(235, 87, 87, 0.4);
  color: #ff7675;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-discard-printer:active {
  transform: scale(0.92);
  background: rgba(235, 87, 87, 0.35);
}

.btn-store-printer {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  background: rgba(108, 92, 231, 0.2);
  border: 1px solid rgba(108, 92, 231, 0.6);
  color: #a29bfe;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-store-printer:active {
  transform: scale(0.94);
  background: rgba(108, 92, 231, 0.45);
}

.btn-cancel-action {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-cancel-action:active {
  transform: scale(0.96);
}

/* Bandeja Inferior de Pedidos / Demandas */
.workshop-bottom-tray {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 12;
  background: linear-gradient(180deg, transparent 0%, rgba(10, 14, 20, 0.95) 15%, #07090d 100%);
  padding: 6px 12px calc(14px + env(safe-area-inset-bottom, 0px));
}

.orders-tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 4px;
}

.orders-tray-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
}

.orders-tray-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-teal);
  background: rgba(0, 206, 201, 0.12);
  border: 1px solid rgba(0, 206, 201, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Bandeja de Pedidos da Casa: Sempre formato padronizado de 4 colunas (25% cada) */
.orders-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 5px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 180px;
  scrollbar-width: none;
  padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch;
  transition: all 0.25s ease;
}

.orders-list.layout-factory-expedition {
  display: block;
  max-height: none;
  overflow: visible;
  padding: 2px 0 4px;
}

.orders-list::-webkit-scrollbar {
  display: none;
}

.order-card {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  background: rgba(18, 24, 34, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 5px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.order-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.order-card:active {
  transform: scale(0.95);
}

.order-circle-wrapper {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.order-svg-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.order-circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 4;
}

.order-circle-progress {
  fill: none;
  stroke: var(--accent-teal);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear, stroke 0.3s;
}

.order-item-icon {
  font-size: 17px;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  line-height: 1;
}

.order-color-dots {
  position: absolute;
  bottom: -2px;
  right: -2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  z-index: 3;
  pointer-events: none;
}

.order-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #121822;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

/* 1 cor: bolinha padrão */
.order-color-dots.dots-1 .order-color-dot {
  width: 10px;
  height: 10px;
}

/* 2 cores: duas bolinhas lado a lado */
.order-color-dots.dots-2 {
  gap: 2.5px;
}

.order-color-dots.dots-2 .order-color-dot {
  width: 9px;
  height: 9px;
}

/* 3 cores: três bolinhas compactas */
.order-color-dots.dots-3 {
  gap: 1.5px;
}

.order-color-dots.dots-3 .order-color-dot {
  width: 8px;
  height: 8px;
}

/* 4 ou mais cores: arranjo em grade 2x2 */
.order-color-dots.dots-4 {
  display: grid;
  grid-template-columns: repeat(2, 7.5px);
  gap: 1.5px;
  bottom: -3px;
  right: -3px;
}

.order-color-dots.dots-4 .order-color-dot {
  width: 7.5px;
  height: 7.5px;
}

/* Compatibilidade caso exista .order-color-dot avulso */
.order-circle-wrapper>.order-color-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
}

.order-product-name {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1px;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1px;
  line-height: 1.1;
}

.order-reward {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.order-reward img.coin-icon-inline {
  width: 11px;
  height: 11px;
  object-fit: contain;
}

/* Animações e Toasts */
.toast-msg {
  position: absolute;
  top: calc(75px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(14, 18, 25, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  max-width: 88%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Floating Cash/Rep Animation */
.floating-text {
  position: absolute;
  color: var(--gold, #ffd700);
  font-weight: 800;
  font-size: 16px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  animation: floatUp 1.2s forwards cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 4px;
}

.floating-text img.coin-icon-inline {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-45px) scale(1.2);
  }
}