/* ==========================================================================
   Toy & Teddy Workshop - Cozy Atelier Retro Styling
   - Warm vintage toy workshop, parquet wood textures, brass accents & pixel art
   ========================================================================== */

:root {
  --bg-color: #1a100a;
  --panel-bg: rgba(45, 27, 20, 0.95);
  --wood-dark: #321c13;
  --wood-mid: #4a2818;
  --wood-light: #6a3e26;
  --wood-border: #7c482b;
  --gold-accent: #f59e0b;
  --gold-bright: #fbbf24;
  --pink-accent: #ec4899;
  --cyan-accent: #38bdf8;
  --text-main: #fef3c7;
  --text-sub: #d7ccc8;
  --text-muted: #a89f91;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 50% 15%, rgba(245, 158, 11, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 85% 75%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 15% 85%, rgba(56, 189, 248, 0.06) 0%, transparent 50%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12px;
  overflow-x: hidden;
}

/* ==========================================================================
   상단 네비게이션 & 배너 헤더
   ========================================================================== */
.game-header {
  width: 100%;
  max-width: 860px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(50, 28, 19, 0.96) 0%, rgba(35, 18, 12, 0.98) 100%);
  border: 2px solid var(--wood-border);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 
    0 4px 18px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.header-banner-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.banner-thumb {
  width: 110px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #8d5b36;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-titles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.back-link {
  color: var(--gold-accent);
  text-decoration: none;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.3px;
  width: fit-content;
  transition: all 0.2s;
}

.back-link:hover {
  color: #fef08a;
  transform: translateX(-2px);
}

.game-title {
  font-size: 18px;
  font-weight: 800;
  color: #fef08a;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

.game-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-pill {
  background: linear-gradient(180deg, #543120 0%, #3e2215 100%);
  color: #fef3c7;
  border: 1px solid #7c482b;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-pill:hover {
  background: linear-gradient(180deg, #6c402b 0%, #522d1c 100%);
  border-color: var(--gold-accent);
  color: #fff;
  transform: translateY(-1px);
}

.btn-pill:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   특별 긴급 주문서 배너 (Special Order Widget)
   ========================================================================== */
.order-bar {
  width: 100%;
  max-width: 860px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(74, 40, 24, 0.95) 0%, rgba(45, 20, 10, 0.98) 100%);
  border: 2px solid #b45309;
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: orderPulse 2.5s infinite ease-in-out;
}

@keyframes orderPulse {
  0%, 100% { border-color: #b45309; box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25); }
  50% { border-color: #facc15; box-shadow: 0 4px 20px rgba(250, 204, 21, 0.45); }
}

.order-icon-badge {
  font-size: 26px;
  flex-shrink: 0;
}

.order-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-tag {
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.order-title {
  font-size: 13px;
  color: #fef08a;
}

.order-time {
  font-size: 11px;
  color: #fca5a5;
  font-weight: 700;
  margin-left: auto;
}

.order-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.order-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b 0%, #22c55e 100%);
  border-radius: 4px;
  transition: width 0.3s;
}

.order-count {
  font-size: 11px;
  font-weight: 800;
  color: #fef3c7;
  min-width: 38px;
  text-align: right;
}

.order-reward {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border-left: 1px solid rgba(141, 91, 54, 0.4);
  padding-left: 12px;
}

.reward-label {
  font-size: 10px;
  color: var(--text-muted);
}

.reward-val {
  font-size: 12px;
  font-weight: 800;
  color: #facc15;
}

/* ==========================================================================
   통계 대시보드 HUD
   ========================================================================== */
.stats-bar {
  width: 100%;
  max-width: 860px;
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.stat-box {
  background: linear-gradient(180deg, #381f14 0%, #29150d 100%);
  border: 1px solid #633922;
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stat-icon {
  font-size: 22px;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.stat-val {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
}

#goldText { color: #facc15; text-shadow: 0 0 10px rgba(250, 204, 21, 0.3); }
#joyText { color: #f472b6; text-shadow: 0 0 10px rgba(244, 114, 182, 0.3); }
#soldText { color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.3); }

.dir-indicator-badge {
  background: linear-gradient(180deg, #432416 0%, #2d160d 100%);
  border: 2px dashed #f59e0b;
  border-radius: 10px;
  padding: 7px 12px;
  color: #fde68a;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.dir-indicator-badge:hover {
  background: linear-gradient(180deg, #55301e 0%, #3c1e12 100%);
  border-color: #fbbf24;
  transform: translateY(-1px);
}

.dir-title {
  color: #d7ccc8;
}

kbd {
  background: #1a0c06;
  border: 1px solid #8d5b36;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 800;
  color: #fde68a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   캔버스 공방 작업장 (앤틱 원목 액자 프레임)
   ========================================================================== */
.canvas-wrapper {
  position: relative;
  border: 6px solid #4a2818;
  outline: 2px solid #b45309;
  border-radius: 12px;
  box-shadow: 
    0 0 0 4px #241209,
    inset 0 0 24px rgba(0, 0, 0, 0.85),
    0 16px 40px rgba(0, 0, 0, 0.7);
  background: #2b1810;
  touch-action: none;
  overflow: hidden;
}

#factoryCanvas {
  display: block;
  cursor: crosshair;
}

/* ==========================================================================
   하단 설비 배치 툴바 & 카테고리 탭
   ========================================================================== */
.toolbar-container {
  width: 100%;
  max-width: 860px;
  margin-top: 14px;
  background: linear-gradient(135deg, rgba(50, 28, 19, 0.98) 0%, rgba(35, 18, 12, 0.99) 100%);
  border: 2px solid var(--wood-border);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 
    0 4px 20px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.toolbar-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(141, 91, 54, 0.4);
  padding-bottom: 8px;
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cat-tab {
  background: rgba(30, 16, 10, 0.8);
  border: 1px solid #633922;
  border-radius: 6px;
  padding: 4px 10px;
  color: #d7ccc8;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.cat-tab:hover {
  background: #4a2818;
  color: #fff;
  border-color: #8d5b36;
}

.cat-tab.active {
  background: linear-gradient(180deg, #7c482b 0%, #522d1c 100%);
  color: #fef08a;
  border-color: var(--gold-accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.toolbar-help {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.tools-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: #7c482b #2d160d;
}

.tools-scroll::-webkit-scrollbar {
  height: 6px;
}
.tools-scroll::-webkit-scrollbar-thumb {
  background: #7c482b;
  border-radius: 4px;
}

.tool-btn {
  position: relative;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #3f2215 0%, #2a150c 100%);
  border: 2px solid #5a331e;
  border-radius: 10px;
  padding: 7px 10px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  transition: all 0.16s ease-out;
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tool-btn:hover {
  background: linear-gradient(180deg, #532f1e 0%, #391e12 100%);
  border-color: #925835;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.tool-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.tool-btn.active {
  background: linear-gradient(180deg, #5f3621 0%, #432415 100%);
  border-color: var(--gold-accent);
  box-shadow: 
    0 0 12px rgba(245, 158, 11, 0.45),
    inset 0 0 6px rgba(245, 158, 11, 0.2);
}

.tool-kbd {
  position: absolute;
  top: 3px;
  right: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 800;
  color: #fde68a;
  line-height: 12px;
}

.tool-icon {
  font-size: 20px;
  margin-top: 2px;
}

.tool-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.tool-cost {
  font-size: 10px;
  font-weight: 800;
  color: #facc15;
}

.tool-btn.demolish-btn {
  border-color: #991b1b;
  color: #fca5a5;
  background: linear-gradient(180deg, #451a1a 0%, #2e0f0f 100%);
}
.tool-btn.demolish-btn:hover {
  border-color: #dc2626;
}
.tool-btn.demolish-btn.active {
  background: linear-gradient(180deg, #7f1d1d 0%, #4c1010 100%);
  border-color: #f87171;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

/* ==========================================================================
   모달 레이아웃 (도감 & 연구실)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: linear-gradient(145deg, #2c170f 0%, #21110a 100%);
  border: 3px solid #8d5b36;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  color: #fef3c7;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  background: linear-gradient(180deg, #3e2215 0%, #2e170d 100%);
  border-bottom: 2px solid #5a331e;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 17px;
  color: #fde68a;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #d7ccc8;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close-btn:hover {
  color: #fff;
}

.modal-content {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 레시피 도감 카드 */
.recipe-card {
  background: linear-gradient(180deg, #3a2014 0%, #2a160d 100%);
  border: 1px solid #633922;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.recipe-doll {
  display: flex;
  align-items: center;
  gap: 10px;
}
.doll-icon {
  font-size: 30px;
}
.doll-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}
.doll-price {
  font-size: 12px;
  color: #facc15;
}

.recipe-flow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 10px;
  border-radius: 8px;
  color: #fef08a;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 업그레이드 카드 */
.upgrade-card {
  background: linear-gradient(180deg, #3a2014 0%, #2a160d 100%);
  border: 1px solid #633922;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.upg-icon {
  font-size: 26px;
}

.upg-info {
  flex: 1;
}

.upg-title {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  color: #fff;
}

.upg-lvl {
  color: #38bdf8;
  font-size: 12px;
}

.upg-desc {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 3px;
}

.upg-buy-btn {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border: 1px solid #fbbf24;
  color: #1a0c06;
  font-weight: 900;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.upg-buy-btn:hover {
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  transform: translateY(-1px);
}

.upg-buy-btn.cant-afford {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.upg-buy-btn.disabled {
  background: #475569;
  border-color: #64748b;
  color: #94a3b8;
  cursor: default;
}

/* 업적 카드 */
.achieve-card {
  background: linear-gradient(180deg, #3a2014 0%, #2a160d 100%);
  border: 1px solid #633922;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: all 0.2s;
}

.achieve-card.unlocked {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #4d2a1a 0%, #341a10 100%);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.achieve-icon {
  font-size: 28px;
}

.achieve-info {
  flex: 1;
}

.achieve-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  display: flex;
  justify-content: space-between;
}

.achieve-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

.achieve-badge.locked {
  background: #334155;
  color: #94a3b8;
}

.achieve-badge.unlocked {
  background: #f59e0b;
  color: #1a0c06;
}

.achieve-desc {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 3px;
}

.achieve-reward {
  font-size: 11px;
  color: #facc15;
  font-weight: 700;
  margin-top: 2px;
}

/* ==========================================================================
   반응형 모바일 조율
   ========================================================================== */
@media (max-width: 768px) {
  .header-banner-bar {
    flex-wrap: wrap;
  }
  .banner-thumb {
    width: 80px;
    height: 48px;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }
  .dir-indicator-badge {
    grid-column: span 3;
    justify-content: center;
  }
  .canvas-wrapper {
    width: 100%;
    overflow-x: auto;
  }
  .toolbar-help {
    display: none;
  }
}
