/* ========================================================
   CHIP MANUFACTURING WAR // MINIMALIST CUSTOM STYLING
   ======================================================== */

/* Custom Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(3, 7, 18, 0.5); /* slate-950 equivalent */
  border-radius: 999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(30, 41, 59, 0.8); /* slate-800 equivalent */
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.5);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, 0.8); /* slate-600 equivalent */
}

/* Custom Fade In animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Connection Wire Dash offset animations */
@keyframes dash {
  to {
    stroke-dashoffset: -40;
  }
}

.wire-animated {
  stroke-dasharray: 8, 4;
  animation: dash 1.5s linear infinite;
}

/* Tech Node cards hover glow profiles */
.node-glow-litho:hover {
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.15);
}

.node-glow-transistor:hover {
  box-shadow: 0 0 15px rgba(251, 113, 133, 0.15);
}

.node-glow-material:hover {
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.15);
}

.node-glow-packaging:hover {
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.15);
}

.node-glow-grand:hover {
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.25);
}

.node-glow-eda:hover {
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

/* Tech Tree SVG connection path hover glow */
#tech-tree-svg path {
  transition: stroke-width 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  cursor: pointer;
}

#tech-tree-svg path:hover {
  stroke-width: 3 !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 6px currentColor);
}

/* Mini tooltip for path dependency description */
#tech-tree-svg path {
  vector-effect: non-scaling-stroke;
}

/* Tech tree container: ensure sizing before JS renders cards */
#tech-tree-container {
  width: 2420px;
  height: 1100px;
  min-width: 2420px;
  min-height: 1100px;
}

/* Tooltip container structure if any */
.tech-tooltip {
  transition: opacity 0.15s ease-out;
}

/* ========================================================
   MOBILE RESPONSIVE ADAPTATIONS
   ======================================================== */

/* Orientation overlay */
#orientation-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#orientation-overlay.active {
  display: flex;
}

#orientation-overlay .content {
  text-align: center;
  padding: 2rem;
  max-width: 320px;
}

#orientation-overlay .icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: phone-rotate 2s ease-in-out infinite;
}

@keyframes phone-rotate {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  75% { transform: rotate(90deg); }
}

#orientation-overlay h2 {
  font-size: 1.125rem;
  font-weight: 800;
  color: #f1f5f9;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

#orientation-overlay p {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.5;
  font-family: 'JetBrains Mono', monospace;
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  /* Tutorial overlay mobile fixes */
  #tutorial-tooltip .skip-btn {
    min-height: 48px;
    font-size: 13px;
  }
  #tutorial-complete .complete-btn {
    min-height: 48px;
  }
  #tutorial-tooltip {
    max-width: 90vw !important;
    padding: 14px 16px !important;
  }
  #tutorial-highlight-box {
    border-width: 2px !important;
  }
  /* Compact header */
  header h1 {
    font-size: 0.625rem !important;
  }
  .header-subtitle {
    display: none;
  }
  .header-btn-text {
    display: none;
  }
  .header-btn {
    padding: 0.5rem !important;
  }

  /* Main container */
  main {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    margin-top: 0.75rem !important;
  }

  /* HUD panels: more compact */
  .hud-panel {
    padding: 0.75rem !important;
  }

  /* Big RP display */
  #hud-remaining-rp {
    font-size: 1.75rem !important;
  }

  /* Research point section */
  .rp-section {
    padding: 0.75rem !important;
  }

  /* Node detail: 2 columns for specs */
  #node-detail-panel .node-spec-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  @media (min-width: 640px) {
    #node-detail-panel .node-spec-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
  }

  /* Investment buttons: bigger touch targets */
  .inv-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.75rem !important;
  }
  #btn-add-max {
    min-height: 44px;
  }

  /* Tech tree: smaller height */
  .tree-wrapper {
    height: 650px !important;
    overflow: auto !important;
  }

  /* Legend row: compact dots only */
  .legend-item {
    font-size: 0 !important;
  }
  .legend-item .legend-label {
    display: none;
  }
  .legend-dot {
    width: 10px !important;
    height: 10px !important;
  }

  /* Next turn button */
  #btn-next-turn {
    font-size: 0.75rem !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }

  /* Log panel */
  #terminal-logs {
    height: 10rem !important;
    font-size: 0.625rem !important;
  }

  /* Filter buttons */
  .log-filter-btn {
    padding: 0.375rem 0.5rem !important;
    font-size: 0.625rem !important;
  }

  /* AI progress section */
  #ai-progress-list > div {
    gap: 0.5rem !important;
  }

  /* Game over modal */
  #gameover-modal .modal-content {
    margin: 0 0.75rem;
    padding: 1.5rem !important;
  }

  /* Rules modal */
  #rules-modal .modal-content {
    margin: 0 0.75rem;
    padding: 1rem !important;
  }

  /* Prereq badges: smaller on mobile */
  #prereq-list button {
    font-size: 0.625rem !important;
    padding: 0.25rem 0.375rem !important;
  }

  /* Manual save/load text */
  .hud-action-btn span {
    display: none;
  }

  /* Force / clear buttons touch-friendly */
  #btn-force-next {
    min-height: 44px;
    font-size: 0.7rem !important;
  }
  #btn-clear-invest {
    font-size: 0.65rem !important;
    min-height: 36px;
  }
}

/* Tablet: 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
  .tree-wrapper {
    height: 820px !important;
    overflow: auto !important;
  }
}

/* ========================================================
   TEXT OVERFLOW & LONG NODE NAMES FIXES
   ======================================================== */

/* Prevent card title overflow */
#tech-tree-container .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Ensure card content doesn't break layout */
#tech-tree-container .text-xs.font-black {
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Mobile-specific text overflow fixes */
@media (max-width: 767px) {
  #tech-tree-container .truncate {
    max-width: 140px;
  }

  #detail-title {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Log entries on mobile */
  #terminal-logs .leading-relaxed {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* ========================================================
   TUTORIAL OVERLAY SYSTEM
   ======================================================== */

/* Main overlay container - lets clicks pass through overlay itself */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9997;
  pointer-events: none;
  background: rgba(3, 7, 18, 0.72);
}

/* Highlight box with pulse animation */
#tutorial-highlight-box {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border: 2.5px solid #22d3ee;
  border-radius: 12px;
  box-shadow:
    0 0 20px rgba(34, 211, 238, 0.5),
    0 0 60px rgba(34, 211, 238, 0.15),
    inset 0 0 20px rgba(34, 211, 238, 0.05);
  animation: tutorial-pulse 1.5s ease-in-out infinite;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tutorial-pulse {
  0%, 100% {
    border-color: #22d3ee;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.5), 0 0 60px rgba(34, 211, 238, 0.15);
  }
  50% {
    border-color: #67e8f9;
    box-shadow: 0 0 35px rgba(34, 211, 238, 0.7), 0 0 80px rgba(34, 211, 238, 0.25);
  }
}

/* Tooltip card positioned near highlight */
#tutorial-tooltip {
  position: fixed;
  z-index: 10000;
  pointer-events: auto;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 16px 20px;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transition: opacity 0.3s ease;
}

#tutorial-tooltip p {
  font-size: 13px;
  line-height: 1.7;
  color: #e2e8f0;
  margin-bottom: 8px;
}

#tutorial-tooltip .tutorial-step-indicators {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

#tutorial-tooltip .tutorial-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #334155;
  transition: all 0.3s ease;
}

#tutorial-tooltip .tutorial-step-dot.active {
  background: #22d3ee;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

#tutorial-tooltip .tutorial-step-dot.done {
  background: #10b981;
}

#tutorial-tooltip .skip-btn {
  font-size: 11px;
  color: #475569;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 0;
  transition: color 0.2s;
}
#tutorial-tooltip .skip-btn:hover {
  color: #94a3b8;
}

/* Scroll hint at bottom of overlay */
#tutorial-scroll-hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  color: #94a3b8;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  text-align: center;
  animation: tutorial-scroll-bounce 1.5s ease-in-out infinite;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

@keyframes tutorial-scroll-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
  50% { transform: translateX(-50%) translateY(6px); opacity: 1; }
}

/* Tutorial complete overlay */
#tutorial-complete {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.88);
  pointer-events: auto;
}
#tutorial-complete .content {
  text-align: center;
  max-width: 340px;
  padding: 2rem;
}
#tutorial-complete .emoji {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
}
#tutorial-complete h3 {
  font-size: 20px;
  font-weight: 900;
  color: #f1f5f9;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
#tutorial-complete p {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.6;
}
#tutorial-complete .complete-btn {
  margin-top: 20px;
  padding: 12px 32px;
  border-radius: 12px;
  background: linear-gradient(to right, #10b981, #0d9488);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}
#tutorial-complete .complete-btn:hover {
  opacity: 0.9;
}

/* ========================================================
   INTERACTION FEEDBACK ENHANCEMENTS
   ======================================================== */

/* Button press animation */
.inv-btn:active:not(:disabled) {
  transform: scale(0.95) !important;
}

.soft-disabled {
  opacity: 0.42 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.15);
}

.soft-disabled:hover {
  opacity: 0.42 !important;
}

.soft-disabled:active {
  transform: none !important;
}

/* Progress bar flash at 100% */
@keyframes progress-flash {
  0% { opacity: 1; }
  50% { opacity: 0.2; }
  100% { opacity: 1; }
}
.progress-flash {
  animation: progress-flash 0.5s ease-out 2 !important;
}

/* ========================================================
   FLOATING TIPS (first 3 turns)
   ======================================================== */
.floating-tip {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: #e2e8f0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  animation: tip-fade-in 0.3s ease-out;
  white-space: nowrap;
}

@keyframes tip-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Floating tip 2 and 3 need positioned parents */
#node-detail-panel {
  position: relative;
}
.hud-panel {
  position: relative;
}

/* ========================================================
   GAME OVER BUTTON SAFETY
   ======================================================== */

/* Extra safety: ensure disabled buttons remain visually non-interactive */
#btn-next-turn[disabled],
#btn-next-turn:disabled {
  pointer-events: none;
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========================================================
   DIFFICULTY SELECTOR STYLES
   ======================================================== */
.diff-option {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.diff-option:active {
  transform: scale(0.97);
}

/* ========================================================
   LOG SCROLL SMOOTHING
   ======================================================== */
#terminal-logs {
  scroll-behavior: smooth;
}

/* ========================================================
   全局通知条
   ======================================================== */
#toast-notification {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10020;
  background: #0f172a;
  border: 1px solid #22d3ee;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: #e2e8f0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 90vw;
  text-align: center;
  pointer-events: auto;
  animation: toast-slidein 0.3s ease-out;
  white-space: nowrap;
}
#toast-notification.hidden {
  display: none;
}
@keyframes toast-slidein {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-fadeout {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ========================================================
   竖屏自适应模式 (PORTRAIT / MOBILE LAYOUT)
   ======================================================== */

/* ---- 基础容器 ---- */
.mobile-layout #mobile-view {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: #030712;
  overflow: hidden;
}

/* 隐藏桌面内容 */
.mobile-layout header,
.mobile-layout main,
.mobile-layout #orientation-overlay {
  display: none !important;
}

/* ---- 顶部状态栏 ---- */
#mobile-status-header {
  display: flex;
  gap: 1px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: 6px 0;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#mobile-status-header::-webkit-scrollbar { display: none; }
.mobile-stat-item {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  padding: 3px 5px;
  border-right: 1px solid #1e293b;
}
.mobile-stat-item:last-child { border-right: none; }
.mobile-stat-label {
  display: block;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.mobile-stat-value {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-stat-emerald { color: #34d399; }
.mobile-stat-cyan { color: #22d3ee; }

#mobile-status-header .mobile-reset-btn {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#mobile-status-header .mobile-reset-btn:active {
  background: #334155;
  color: #ef4444;
}

/* ---- 可滚动内容区 ---- */
#mobile-scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  padding-bottom: 140px;
}

/* ---- 竖向科技卡片列表 ---- */
.mobile-tech-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.mobile-tech-card:active {
  border-color: #3b82f6;
}
.mobile-tech-card.locked {
  opacity: 0.75;
}
.mobile-tech-card.unlocked {
  border-color: #065f46;
}
.mobile-tech-card.selected {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 12px rgba(59,130,246,0.3);
  background: rgba(59,130,246,0.08) !important;
}
.mobile-card-branch-label {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(71, 85, 105, 0.2);
}
.mobile-tech-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}
.mobile-tech-card-title {
  font-size: 14px;
  font-weight: 800;
  color: #e2e8f0;
  line-height: 1.3;
}
.mobile-tech-card-subtitle {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #64748b;
  display: block;
  margin-top: 1px;
}
.mobile-tech-card-badge {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.mobile-tech-card-badge.researchable {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.mobile-tech-card-badge.blocked {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.25);
}
.mobile-tech-card-badge.unlocked {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.mobile-tech-card-badge.locked {
  background: rgba(71, 85, 105, 0.2);
  color: #64748b;
  border: 1px solid #1e293b;
  white-space: normal;
  word-break: break-all;
  max-width: 55%;
  text-align: right;
  font-size: 9px;
  line-height: 1.3;
}

/* 进度条 */
.mobile-progress-wrap {
  margin-bottom: 10px;
}
.mobile-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: #94a3b8;
  margin-bottom: 4px;
}
.mobile-progress-bar {
  width: 100%;
  height: 6px;
  background: #020617;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #1e293b;
}
.mobile-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(to right, #3b82f6, #22d3ee);
  transition: width 0.3s;
}
.mobile-progress-fill.complete {
  background: linear-gradient(to right, #10b981, #34d399);
}

/* 卡片内嵌后续节点预览 */
.mobile-upcoming {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
}
.mobile-upcoming-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: #475569;
  cursor: pointer;
}
.mobile-upcoming-item:active {
  color: #94a3b8;
}
.mobile-upcoming-arrow {
  color: #334155;
  flex-shrink: 0;
  font-size: 11px;
}
.mobile-upcoming-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #64748b;
}
.mobile-upcoming-cost {
  flex-shrink: 0;
  color: #475569;
  font-size: 10px;
}

/* 卡片按钮区 */
.mobile-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mobile-card-meta {
  margin-bottom: 8px;
  font-size: 10px;
  line-height: 1.45;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}
.mobile-card-blocked {
  margin-bottom: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(244, 63, 94, 0.2);
  background: rgba(127, 29, 29, 0.15);
  color: #fecdd3;
  font-size: 10px;
  line-height: 1.4;
  font-family: 'JetBrains Mono', monospace;
}
.mobile-inv-btn {
  flex: 1;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid #1e293b;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mobile-inv-btn:active {
  background: #334155;
  transform: scale(0.97);
}
.mobile-inv-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}
.mobile-inv-btn.soft-disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.mobile-inv-btn.soft-disabled:active {
  transform: none !important;
}
.mobile-inv-btn.primary {
  background: #1e40af;
  border-color: #2563eb;
  color: #fff;
}
.mobile-inv-btn.primary:active {
  background: #2563eb;
}
.mobile-inv-btn.success {
  background: #065f46;
  border-color: #059669;
  color: #fff;
}
.mobile-inv-btn.success:active {
  background: #059669;
}

/* ---- 已解锁科技折叠面板 ---- */
#mobile-unlocked-section {
  margin-top: 8px;
  margin-bottom: 12px;
}
.mobile-collapse-btn {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mobile-collapse-btn:active {
  background: #1e293b;
}
.mobile-collapse-btn.open {
  color: #e2e8f0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
#mobile-unlocked-list {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 4px 12px 12px;
}

/* ---- RP信息 ---- */
.mobile-rp-bar {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  color: #e2e8f0;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

/* ---- AI对手进度 ---- */
#mobile-ai-section {
  margin-top: 8px;
}
.mobile-section-title {
  font-size: 14px;
  font-weight: 800;
  color: #94a3b8;
  margin-bottom: 10px;
  padding: 0 2px;
}
#mobile-ai-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-ai-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 10px 12px;
}
.mobile-ai-card-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mobile-ai-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}
.mobile-ai-card-avatar {
  font-size: 18px;
  flex-shrink: 0;
}
.mobile-ai-card-name {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  display: block;
}
.mobile-ai-card-process {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #22d3ee;
  font-weight: 700;
  display: block;
}
.mobile-ai-card-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.mobile-ai-bar {
  flex: 1;
  height: 4px;
  background: #020617;
  border-radius: 999px;
  overflow: hidden;
  min-width: 40px;
}
.mobile-ai-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s;
}
.mobile-ai-pct {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #64748b;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- 底部固定操作栏 ---- */
#mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9995;
  background: #0f172a;
  border-top: 1px solid #1e293b;
  padding: 6px 10px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
  flex-shrink: 0;
}
#mobile-bottom-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.mob-action-btn {
  flex: 1;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid #1e293b;
  background: #1e293b;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mob-action-btn:active {
  background: #334155;
}
.mob-action-btn span {
  font-size: 10px;
}
.mob-next-btn {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mob-next-btn:disabled {
  background: #1e293b;
  color: #475569;
  cursor: not-allowed;
  border: 1px solid #334155;
}
.mob-next-btn:not(:disabled) {
  background: linear-gradient(to right, #10b981, #0d9488);
  color: #fff;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25);
}
.mob-next-btn:not(:disabled):active {
  opacity: 0.85;
  transform: scale(0.98);
}
.mob-force-btn {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid #854d0e;
  background: rgba(146, 84, 13, 0.15);
  color: #fbbf24;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.mob-force-btn:active {
  background: rgba(146, 84, 13, 0.3);
}

/* ---- 全屏模态框（竖屏版） ---- */
.mobile-layout #market-modal,
.mobile-layout #prod-modal,
.mobile-layout #contract-modal {
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  background: rgba(3, 7, 18, 0.95) !important;
  z-index: 10001 !important;
}
.mobile-layout #market-modal .modal-content,
.mobile-layout #prod-modal .modal-content,
.mobile-layout #contract-modal .modal-content {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  border-radius: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 16px !important;
  border: none !important;
  overflow-y: auto !important;
}
.mobile-layout .mobile-modal-back {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 20px;
  cursor: pointer;
  margin-right: 4px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mobile-layout .mobile-modal-back:active {
  background: #334155;
}
.mobile-layout #btn-close-market,
.mobile-layout #btn-close-prod,
.mobile-layout #btn-close-contract {
  display: none !important;
}

/* ---- 竖屏版教程/提示适配 ---- */
.mobile-layout .floating-tip {
  display: none !important;
}
.mobile-layout #tutorial-overlay {
  z-index: 10002 !important;
}
.mobile-layout #tutorial-highlight-box {
  z-index: 10003 !important;
  border-width: 2.5px !important;
}
.mobile-layout #tutorial-tooltip {
  z-index: 10004 !important;
  max-width: 88vw !important;
  padding: 14px 16px !important;
}
.mobile-layout #tutorial-tooltip .skip-btn {
  min-height: 48px;
  font-size: 13px;
}
.mobile-layout #tutorial-complete {
  z-index: 10005 !important;
}
.mobile-layout #tutorial-complete .complete-btn {
  min-height: 48px;
  font-size: 15px;
}

/* 竖屏版 ready-overlay / load-prompt / gameover 优先级（确保盖住 mobile-view） */
.mobile-layout #ready-overlay,
.mobile-layout #load-prompt,
.mobile-layout #gameover-modal {
  z-index: 10020 !important;
}

/* ---- 教程完成弹窗屏幕适配 ---- */
.mobile-layout #tutorial-complete .content {
  padding: 1.5rem;
}

/* ---- 竖屏版 ready-overlay / load-prompt 排版优化 ---- */
.mobile-layout #ready-overlay > div,
.mobile-layout #load-prompt > div {
  max-width: 92vw !important;
  margin: 0 auto !important;
  padding: 1.25rem !important;
}
.mobile-layout #ready-overlay h1 {
  font-size: 1rem !important;
}
.mobile-layout #ready-overlay p {
  font-size: 0.65rem !important;
}
.mobile-layout #ready-overlay .diff-option {
  padding: 0.75rem 0.75rem !important;
  font-size: 0.7rem !important;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.mobile-layout #ready-overlay #btn-ready-start {
  min-height: 52px;
  font-size: 0.85rem !important;
}
.mobile-layout #load-prompt h3 {
  font-size: 0.95rem !important;
}
.mobile-layout #load-prompt p {
  font-size: 0.7rem !important;
}

/* ---- 极窄屏适配 (< 200px) ---- */
@media (max-width: 200px) {
  .mobile-layout #mobile-status-header {
    padding: 4px 0;
  }
  .mobile-layout #mobile-scroll-area {
    padding: 8px;
    padding-bottom: 150px;
  }
  .mobile-layout .mobile-tech-card {
    padding: 10px;
    margin-bottom: 8px;
  }
  .mobile-layout .mobile-tech-card-title {
    font-size: 13px;
  }
  .mobile-layout .mobile-tech-card-subtitle {
    font-size: 9px;
  }
  .mobile-layout .mobile-tech-card-badge {
    font-size: 9px;
    padding: 1px 5px;
  }
  .mobile-layout .mobile-progress-label {
    font-size: 10px;
  }
  .mobile-layout .mobile-progress-bar {
    height: 4px;
  }
  .mobile-layout .mobile-inv-btn {
    font-size: 11px !important;
    min-height: 38px;
    padding: 0 4px;
  }
  .mobile-layout .mobile-rp-bar {
    font-size: 12px;
    padding: 8px 10px;
  }
  .mobile-layout .mobile-section-title {
    font-size: 12px;
  }
  .mobile-layout .mobile-ai-card {
    padding: 8px 10px;
  }
  .mobile-layout .mobile-ai-card-name {
    font-size: 11px;
  }
  .mobile-layout .mobile-ai-card-process {
    font-size: 9px;
  }
  .mobile-layout .mobile-upcoming-item {
    font-size: 10px;
    padding: 3px 0;
  }
  .mobile-layout .mobile-upcoming-cost {
    font-size: 9px;
  }
  .mobile-layout .mobile-card-branch-label {
    font-size: 8px;
  }
  .mobile-layout .mob-action-btn {
    font-size: 11px !important;
    min-height: 40px;
  }
  .mobile-layout .mob-action-btn span {
    font-size: 8px;
  }
  .mobile-layout .mob-next-btn {
    font-size: 13px;
    min-height: 48px;
  }
  .mobile-layout #mobile-bottom-bar {
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
  }
  .mobile-layout #mobile-bottom-actions {
    gap: 4px;
    margin-bottom: 4px;
  }
  .mobile-layout .mobile-stat-label {
    font-size: 7px;
    letter-spacing: 0;
  }
  .mobile-layout .mobile-stat-value {
    font-size: 10px;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-layout .mobile-stat-item {
    padding: 2px 3px;
    flex: 0 0 auto;
  }
  .mobile-layout #mobile-status-header .mobile-reset-btn {
    min-width: 28px;
    min-height: 28px;
    font-size: 14px;
    margin: 0 2px;
  }
  .mobile-layout .mobile-tech-card-title {
    font-size: 11px;
  }
  .mobile-layout .mobile-tech-card-subtitle {
    font-size: 8px;
  }
  .mobile-layout .mobile-tech-card-badge {
    font-size: 7px;
    padding: 1px 3px;
    max-width: 40%;
  }
  .mobile-layout .mobile-inv-btn {
    font-size: 10px !important;
    min-height: 34px;
    padding: 0 2px;
  }
  .mobile-layout .mobile-card-branch-label {
    font-size: 7px;
  }
  .mobile-layout .mobile-card-actions {
    gap: 4px;
  }
  .mobile-layout .mobile-upcoming-item {
    font-size: 9px;
    padding: 2px 0;
  }
  .mobile-layout .mobile-upcoming-cost {
    font-size: 8px;
  }
  .mobile-layout .mobile-ai-card-name { font-size: 10px; }
  .mobile-layout .mob-action-btn {
    font-size: 10px !important;
    min-height: 36px;
  }
  .mobile-layout .mob-action-btn span { font-size: 7px; }
  .mobile-layout .mob-next-btn {
    font-size: 12px;
    min-height: 44px;
  }
  .mobile-layout #mobile-bottom-bar {
    padding: 4px 6px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
  }
  .mobile-layout .mobile-rp-bar { font-size: 10px; padding: 6px 8px; }
}
