:root {
  --bg-color: #050811;
  --panel-bg: rgba(5, 8, 17, 0.85);
  --text-color: #e2e8f0;
  --border-color: rgba(0, 240, 255, 0.3);
  --accent-color: #00f0ff;
  --accent-glow: rgba(0, 240, 255, 0.6);
  --danger-color: #ff003c;
  --drop-zone-border: rgba(0, 240, 255, 0.3);
  --drop-zone-bg: rgba(0, 240, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Chakra Petch', 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text-color);
  height: 100vh;
  width: 100%;
  display: flex;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(15,23,42,0.9) 0%, rgba(15,23,42,0) 100%);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
  text-transform: uppercase;
  letter-spacing: 4px;
}

header p {
  color: #94a3b8;
  font-weight: 300;
}

main {
  display: flex;
  flex: 1;
  position: relative;
  min-height: 0; /* Crucial for nested flex scrolling */
}

/* Game Area */
.game-area {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  overflow: hidden;
  perspective: 2000px;
  touch-action: none;
  background-color: #050811;
}

/* Motherboard Isometric View */
.motherboard-container {
  width: 800px;
  height: 800px;
  position: absolute;
  top: 50%;
  left: 50%;
  background: transparent;
  transform-origin: center center;
}

  .motherboard-bg {
    position: absolute;
    inset: 0;
    opacity: 1;
    transition: opacity 0.5s ease, filter 0.3s ease;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 1;
    background-image: url('/mainboard.webp'), url('/mainboard.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
  }
  
  .motherboard-bg.initial-hide {
    opacity: 0;
    pointer-events: none !important;
  }

  .motherboard-bg:not(.initial-hide):hover {
    filter: brightness(1.05) drop-shadow(0 0 16px rgba(0, 240, 255, 0.4));
  }

  .motherboard-bg.zoomed-in {
    filter: brightness(1.1) drop-shadow(0 0 25px rgba(0, 240, 255, 0.75));
  }

  .mb-real-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
  }

/* Drop Zones (Flat on motherboard) */
.drop-zone {
  position: absolute;
  background-color: transparent;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  z-index: 5;
}

.drop-zone .zone-label {
  display: none;
}

/* Motherboard Initial Drop Zone */
.drop-zone.mb-zone {
  position: absolute;
  top: 10%; left: 10%;
  width: 80%; height: 80%;
  border: 3px dashed var(--accent-color);
  background: rgba(0, 240, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.2) inset, 0 0 25px rgba(0, 240, 255, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  cursor: pointer;
  animation: pulse-mb-glow 2.5s infinite ease-in-out;
}

.drop-zone.mb-zone.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

@keyframes pulse-mb-glow {
  0%, 100% {
    border-color: var(--accent-color);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.2) inset, 0 0 20px rgba(0, 240, 255, 0.2);
  }
  50% {
    border-color: #38bdf8;
    box-shadow: 0 0 50px rgba(0, 240, 255, 0.4) inset, 0 0 35px rgba(0, 240, 255, 0.45);
  }
}

.drop-zone.mb-zone .zone-label {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-color);
  text-shadow: 0 0 15px var(--accent-glow);
  text-align: center;
  pointer-events: none;
  background: rgba(5, 8, 17, 0.9);
  padding: 16px 28px;
  border-radius: 10px;
  border: 1px solid var(--accent-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

/* Matching drop target highlight while dragging */
body.is-dragging-active .drop-zone.target-match {
  border: 2px dashed rgba(0, 240, 255, 0.7) !important;
  background-color: rgba(0, 240, 255, 0.12) !important;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3) inset;
  animation: pulse-drop-target 1.5s infinite ease-in-out;
}

body.is-dragging-active .drop-zone.target-match .zone-label {
  display: block !important;
  font-size: 0.85rem;
  color: #fff;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  background: rgba(5, 8, 17, 0.85);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--accent-color);
  white-space: nowrap;
}

@keyframes pulse-drop-target {
  0%, 100% {
    border-color: rgba(0, 240, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2) inset;
  }
  50% {
    border-color: #38bdf8;
    box-shadow: 0 0 28px rgba(0, 240, 255, 0.45) inset;
  }
}

.drop-zone.drag-over {
  border: 2px solid #00f0ff !important;
  background-color: rgba(0, 240, 255, 0.3) !important;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.6) inset !important;
  transform: scale(1.02);
}

.drop-zone.drag-over .zone-label {
  display: block !important;
  color: #00f0ff !important;
  font-weight: 700 !important;
  text-shadow: 0 0 10px #00f0ff !important;
}

/* Mapping Active State */
.motherboard-container.mapping-active .drop-zone {
  border: 1px dashed var(--accent-color);
  background-color: rgba(0, 240, 255, 0.05);
}

.motherboard-container.mapping-active .drop-zone::before,
.motherboard-container.mapping-active .drop-zone::after {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid var(--accent-color);
  pointer-events: none;
}
.motherboard-container.mapping-active .drop-zone::before {
  top: -2px; left: -2px;
  border-right: none; border-bottom: none;
}
.motherboard-container.mapping-active .drop-zone::after {
  bottom: -2px; right: -2px;
  border-left: none; border-top: none;
}

.motherboard-container.mapping-active .drop-zone.drag-over {
  background-color: rgba(0, 240, 255, 0.2);
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 30px var(--accent-glow) inset;
}

.motherboard-container.mapping-active .drop-zone .zone-label {
  display: block;
  font-size: 0.9rem;
  color: var(--accent-color);
  font-weight: 600;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 5px var(--accent-color);
}

/* Sockets positioning */
.cpu-zone { top: 25%; left: 40%; width: 120px; height: 100px; }
.ram-slot-1, .ram-zone, .ram-1 { top: 19%; left: 44.5%; width: 230px; height: 160px; }
.gpu-zone { top: 54%; left: 47.5%; width: 228px; height: 142px; }
.storage-zone { top: 44.5%; left: 49%; width: 134px; height: 76px; }
.psu-zone { top: 78%; left: 38%; width: 260px; height: 260px; }
.case-zone { top: 5%; left: 3%; width: 220px; height: 260px; z-index: 6; }
.keyboard-zone { top: 70%; left: 6%; width: 260px; height: 140px; z-index: 6; }
.mouse-zone { top: 68%; left: 74%; width: 140px; height: 160px; z-index: 6; }

/* Draggable Components */
.component-item {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  font-weight: 700;
  font-size: 0.9rem;
  color: transparent;
  user-select: none;
  touch-action: none;
  position: relative;
  transition: transform 0.2s, filter 0.2s;
}

.component-item:active {
  cursor: grabbing;
}

/* 2D Fallback Styles for colored blocks (when images are not available) */

/* CPU */
.component-item[data-id='cpu'] { background: #3b82f6; border: 2px solid #2563eb; border-radius: 4px; }

/* GPU */
.component-item[data-id='gpu'] { background: #ef4444; border: 2px solid #dc2626; border-radius: 4px; }

/* RAM */
.component-item[data-id='ram'] { background: #eab308; border: 2px solid #ca8a04; border-radius: 4px; }

/* Storage (NVMe) */
.component-item[data-id='storage'] { background: #10b981; border: 2px solid #059669; border-radius: 4px; }

/* PSU */
.component-item[data-id='psu'] { background: #f97316; border: 2px solid #ea580c; border-radius: 4px; }

/* Hide fallback backgrounds/borders when using custom images */
.component-item.is-image-mode[data-id] {
  background: transparent !important;
  border: none !important;
}

/* Prevent native browser drag interfering with custom pointer drag */
img, .inventory-card, .inventory-component-thumb, .cable-inventory-card, .component-item {
  -webkit-user-drag: none !important;
  user-drag: none !important;
  -webkit-touch-callout: none !important;
}

/* Dragging State - High visibility Glowing Ghost Element */
.component-item.is-dragging {
  position: fixed !important;
  z-index: 99999 !important;
  pointer-events: none !important;
  background: rgba(10, 20, 36, 0.95) !important;
  border: 2px solid #00f0ff !important;
  border-radius: 14px !important;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.8), 0 10px 30px rgba(0, 0, 0, 0.85) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 0.98 !important;
  transition: none !important;
  will-change: transform !important;
}

.component-item.is-dragging img {
  max-width: 88% !important;
  max-height: 88% !important;
  object-fit: contain !important;
  pointer-events: none !important;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8)) !important;
}

.inventory-card.is-being-dragged {
  opacity: 0.3 !important;
  transform: scale(0.96) !important;
}

/* While dragging, disable pointer events on placed items and non-target zones so dragging never accidentally triggers info or conflicts */
body.is-dragging-active .placed-component,
body.is-dragging-active .drop-zone:not(.target-match) {
  pointer-events: none !important;
}

/* Placed component rotation and positioning */
.drop-zone .placed-component {
  transform: translate(var(--img-x, 0px), var(--img-y, 0px)) rotate(var(--img-r, 0deg)) skew(var(--img-skew-x, 0deg), var(--img-skew-y, 0deg));
  /* Use physical layout dimensions instead of transform: scale() to prevent image blurriness */
  width: calc(100% * var(--img-s, 1)) !important;
  height: calc(100% * var(--img-s, 1)) !important;
  /* Removed aggressive image-rendering flags as they cause aliasing on mobile HDPI screens */
}

/* Sidebar Inventory */
.inventory {
  width: 320px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  height: 100%;
}

.inventory h2 {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e2e8f0;
}

.inventory-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-height: 0; /* Allows it to shrink and trigger scroll */
}

/* Custom Scrollbar for Inventory */
.inventory-list::-webkit-scrollbar {
  width: 6px;
}
.inventory-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}
.inventory-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.inventory-card {
  background: rgba(8, 16, 28, 0.7);
  border: 1px solid var(--border-color);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.inventory-card:hover {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent-color);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2) inset;
}

.inventory-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.inventory-card:hover::before {
  left: 200%;
}

.inventory-card.selected {
  border-color: var(--accent-color) !important;
  background: rgba(0, 240, 255, 0.15) !important;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.4) inset, 0 0 10px rgba(0, 240, 255, 0.3) !important;
  transform: translateY(-2px);
}

.inventory-card.is-placed {
  opacity: 0.45;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.4);
}

.inventory-card.is-placed::after {
  content: '✓ ติดตั้งแล้ว';
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.65rem;
  color: #34d399;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid #10b981;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
}

.quick-install-btn {
  display: none !important;
}

.inventory-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
  text-align: left;
  line-height: 1.3;
}

.drag-wrapper {
  height: 96px;
  width: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  border: 1px solid rgba(0, 240, 255, 0.12);
  padding: 6px;
  box-sizing: border-box;
}

.drag-wrapper .component-item {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.inventory-component-thumb {
  max-width: 85%;
  max-height: 85%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
  transition: transform 0.2s ease;
}

.inventory-card:hover .inventory-component-thumb {
  transform: scale(1.08);
}

/* Floating Labels */
.floating-label-container {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  animation: float-in 0.4s ease-out forwards;
}

@keyframes float-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.floating-label-container .label-box {
  background-color: rgba(5, 8, 17, 0.9);
  color: var(--accent-color);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: auto;
  cursor: grab;
  border: 1px solid var(--accent-color);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3) inset;
  transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.floating-label-container .label-box:hover {
  background-color: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6) inset;
}

/* Hide ALL floating labels (boxes and lines) when zoomed in */
.motherboard-container.cinematic-mode .floating-label-container {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 0.3s;
}

/* HUD Info Bar (Bottom) */
.hud-info {
  position: fixed;
  bottom: 0; left: 0; width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 50%, rgba(0,0,0,0));
  z-index: 300;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 4rem 10% 2rem;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: auto;
}

.hud-info.hidden {
  opacity: 0;
  transform: translateY(50px);
  pointer-events: none;
}

.hud-close {
  position: absolute;
  top: 1rem;
  right: 2.5rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 30px;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.hud-close:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.hud-text h2 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.5rem;
  text-shadow: 0 4px 10px rgba(0,0,0,0.8);
}

.hud-text p {
  color: #cbd5e1;
  line-height: 1.6;
  font-size: 1.1rem;
  font-weight: 300;
  max-width: 800px;
  text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* Placed Component Image Transition */
.placed-component {
  position: relative;
  overflow: visible; /* Allow images to exceed bounds if needed */
}

.placed-component.is-image-mode {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.placed-component.is-image-mode::after {
  display: none !important;
}

.placed-component .icon-text {
  position: relative;
  z-index: 2;
  transition: opacity 0.5s;
}

/* Placed component image rules handle their own sizing via .comp-image-ext */

.comp-image-ext, .comp-image-int {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  object-fit: contain;
  z-index: 3;
  transform: scale(1);
  transition: all 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

.comp-image-ext {
  opacity: 1;
}

.comp-image-int {
  opacity: 0;
}

/* When zoomed in, switch from ext to int */
.placed-component.zoomed-in .comp-image-ext {
  opacity: 0;
  transform: scale(1.1);
}

.placed-component.zoomed-in .comp-image-int {
  opacity: 1;
  transform: scale(1.1);
}

/* --- Mapping Tools --- */
.mapping-toggle-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #3b82f6;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: background 0.2s;
}

.mapping-toggle-btn:hover {
  background: #2563eb;
}

.mapping-toggle-btn.active {
  background: #ef4444;
}

.mapping-panel {
  position: absolute;
  top: 4rem;
  right: 1rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #334155;
  padding: 1.5rem;
  border-radius: 12px;
  width: 300px;
  z-index: 100;
  color: white;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition: opacity 0.3s, transform 0.3s;
}

.modal-content {
  background: rgba(5, 8, 17, 0.95);
  border: 1px solid var(--accent-color);
  clip-path: polygon(30px 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%, 0 30px);
  padding: 3rem;
  max-width: 700px;
  width: 90%;
  color: var(--text-color);
  position: relative;
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.1) inset;
}

.modal-content::before {
  content: 'SYSTEM.INFO';
  position: absolute;
  top: 10px;
  left: 30px;
  font-size: 0.7rem;
  color: var(--accent-color);
  letter-spacing: 3px;
  opacity: 0.5;
}

.modal.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

.mapping-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

.mapping-panel h3 {
  margin-top: 0;
  font-size: 1.1rem;
  color: #60a5fa;
  margin-bottom: 0.5rem;
}

.mapping-panel p {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 1.5rem;
}

.mapping-controls label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: #cbd5e1;
}

.mapping-controls select {
  width: 100%;
  padding: 0.5rem;
  background: #1e293b;
  color: white;
  border: 1px solid #475569;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-family: 'Prompt', sans-serif;
}

.slider-group {
  margin-bottom: 1.5rem;
}

.slider-group input[type="range"] {
  width: 100%;
  cursor: pointer;
}

/* When mapping mode is active, make drop zones highly visible and interactive */
.motherboard-container.mapping-active .drop-zone {
  border: 2px solid #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.2) !important;
  z-index: 100;
  cursor: move;
}

/* Locked State */
.motherboard-container.mapping-active .drop-zone.is-locked {
  border: 2px solid #10b981 !important;
  background-color: rgba(16, 185, 129, 0.2) !important;
  cursor: default;
}

/* Resize handle */
.resize-handle {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 12px;
  height: 12px;
  background-color: #ef4444;
  border-radius: 50%;
  cursor: nwse-resize;
  display: none;
  z-index: 101;
}

.motherboard-container.mapping-active .drop-zone .resize-handle {
  display: block;
}

.motherboard-container.mapping-active .drop-zone.is-locked .resize-handle {
  display: none !important;
}

/* Smooth Camera Transitions */
.motherboard-container {
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}
.motherboard-container.no-transition {
  transition: none !important;
}

/* ----------------------------------
   Responsive Mobile Layout (Apple Style)
   ---------------------------------- */
@media (max-width: 768px) {
  /* Shop Mobile Optimizations */
  #shop-view {
    padding: 0.4rem 0.5rem;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .shop-header {
    padding: 0.4rem 0.4rem 0.6rem 0.4rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  }

  .shop-header .header-content {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    text-align: left !important;
    gap: 0.5rem !important;
  }

  .shop-header .header-titles {
    text-align: left !important;
    flex: 1;
    min-width: 0;
  }

  .shop-header h1 {
    font-size: 0.9rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .shop-mission-desc {
    font-size: 0.68rem !important;
    margin-top: 2px !important;
    color: #94a3b8 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 250px !important;
  }

  .mobile-cart-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 3px 8px !important;
    font-size: 0.74rem !important;
    flex-shrink: 0 !important;
    background: rgba(0, 240, 255, 0.12) !important;
    border: 1px solid rgba(0, 240, 255, 0.4) !important;
    color: #00f0ff !important;
    border-radius: 16px !important;
  }

  .shop-layout {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
    gap: 0 !important;
    position: relative !important;
  }

  .shop-products {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    padding: 0.3rem 0.3rem calc(5.5rem + env(safe-area-inset-bottom, 14px)) 0.3rem !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
  }

  .shop-scroll-spacer {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: calc(4.5rem + env(safe-area-inset-bottom, 14px)) !important;
    min-height: 4.5rem !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  .product-card {
    padding: 0.6rem 0.5rem !important;
    border-radius: 8px !important;
    touch-action: pan-y !important;
  }

  .product-card * {
    touch-action: pan-y !important;
  }

  .product-image {
    height: 75px !important;
    width: 100% !important;
    object-fit: contain !important;
    margin-bottom: 0.3rem !important;
  }

  .product-name {
    font-size: 0.8rem !important;
    height: 2.3em !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    margin-bottom: 0.2rem !important;
  }

  .product-desc {
    display: none !important;
  }

  .product-price {
    font-size: 0.9rem !important;
    margin-bottom: 0.35rem !important;
  }

  .add-cart-btn {
    padding: 0.45rem 0.3rem !important;
    font-size: 0.76rem !important;
  }

  /* Mobile Sticky Bottom Cart Bar */
  .mobile-sticky-cart-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    background: rgba(10, 15, 30, 0.98) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    border-top: 1px solid rgba(0, 240, 255, 0.4) !important;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.85) !important;
    z-index: 950 !important;
    padding: 0.45rem 0.8rem calc(0.45rem + env(safe-area-inset-bottom, 14px)) 0.8rem !important;
    align-items: center !important;
    justify-content: space-between !important;
    pointer-events: auto !important;
  }

  #shop-view.hidden .mobile-sticky-cart-bar {
    display: none !important;
  }

  .mobile-cart-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .m-cart-count {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .m-cart-price {
    font-size: 1.15rem;
    color: var(--accent-color);
    font-weight: 800;
    font-family: monospace;
  }

  .mobile-cart-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .m-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
  }

  .m-btn-primary {
    background: linear-gradient(135deg, #00f0ff, #3b82f6) !important;
    color: #000 !important;
    font-weight: 800 !important;
    padding: 8px 14px !important;
    border-radius: 6px !important;
    font-size: 0.85rem !important;
    border: none !important;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4) !important;
  }

  /* Slide-up Cart Drawer on Mobile */
  .shop-cart {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 75vh !important;
    border-radius: 16px 16px 0 0 !important;
    border: 1px solid var(--accent-color) !important;
    border-bottom: none !important;
    z-index: 1001 !important;
    transform: translateY(110%) !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    background: rgba(10, 15, 30, 0.98) !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
    box-shadow: 0 -15px 40px rgba(0, 0, 0, 0.9) !important;
    clip-path: none !important;
    display: flex !important;
  }

  .shop-cart.cart-drawer-open {
    transform: translateY(0) !important;
  }

  .close-cart-btn {
    display: flex !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    color: #fff !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    font-size: 1.3rem !important;
    cursor: pointer !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .cart-drawer-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    z-index: 1000;
  }

  .cart-drawer-backdrop.hidden {
    display: none !important;
  }

  /* Workbench View Mobile Optimization */
  #build-view:not(.hidden) {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: radial-gradient(circle at 50% 30%, #0c162c 0%, #050811 100%) !important;
    touch-action: none !important;
    z-index: 50 !important;
  }

  #build-view.hidden,
  #shop-view.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }

  #build-view header {
    padding: 0.32rem 0.6rem !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    flex-shrink: 0 !important;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2) !important;
    background: rgba(10, 15, 29, 0.92) !important;
    z-index: 20 !important;
  }

  #build-view .header-content {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    text-align: left !important;
    gap: 0.4rem !important;
    width: 100% !important;
  }

  #build-view .header-titles {
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  #build-view header h1 {
    font-size: 0.92rem !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    color: var(--accent-color) !important;
  }

  #build-view header p {
    display: none !important; /* Hide long subtitle on mobile to give maximum height to board */
  }

  #build-view main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: relative !important;
  }

  #build-view .game-area {
    display: flex !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    position: relative !important;
    overflow: hidden !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: none !important;
  }

  /* Transform Sidebar into Compact Bottom Dock (Apple-grade tactile ribbon) */
  .inventory {
    width: 100% !important;
    height: auto !important;
    flex-shrink: 0 !important;
    min-height: 80px !important;
    max-height: 102px !important;
    border-left: none !important;
    border-top: 1px solid rgba(0, 240, 255, 0.3) !important;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.85) !important;
    background: rgba(8, 14, 26, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 16px)) !important;
    padding-top: 0.25rem !important;
    z-index: 100 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  .inventory h2 {
    display: none !important; /* Hide title to maximize space */
  }

  .inventory-list {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0.2rem 0.6rem !important;
    gap: 0.5rem !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    display: flex !important;
    align-items: center !important;
  }

  .inventory-list.drag-active {
    overflow-x: hidden !important;
    touch-action: none !important;
    scroll-snap-type: none !important;
  }

  .inventory-list::-webkit-scrollbar {
    display: none !important;
  }

  .inventory-card {
    min-width: 80px !important;
    max-width: 90px !important;
    height: 72px !important;
    padding: 0.3rem 0.35rem !important;
    flex-shrink: 0 !important;
    scroll-snap-align: start !important;
    margin-bottom: 0 !important;
    gap: 0.2rem !important;
    touch-action: pan-x !important;
    border-radius: 8px !important;
    clip-path: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(14, 23, 42, 0.75) !important;
    border: 1px solid rgba(0, 240, 255, 0.25) !important;
    position: relative !important;
    cursor: grab !important;
  }

  .inventory-card:active {
    cursor: grabbing !important;
  }

  .inventory-card-title {
    font-size: 0.68rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    text-align: center !important;
    line-height: 1.1 !important;
    color: #e2e8f0 !important;
  }

  .drag-wrapper {
    height: 44px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
  }

  .inventory-component-thumb {
    max-width: 88% !important;
    max-height: 42px !important;
    object-fit: contain !important;
    pointer-events: none !important;
  }

  .inventory-card.is-placed {
    opacity: 0.35 !important;
    background: rgba(15, 23, 42, 0.35) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
  }

  .inventory-card.is-placed::after {
    content: '✓ วางแล้ว' !important;
    position: absolute !important;
    top: 2px !important;
    right: 2px !important;
    font-size: 0.56rem !important;
    color: #34d399 !important;
    background: rgba(16, 185, 129, 0.25) !important;
    border: 1px solid #10b981 !important;
    border-radius: 3px !important;
    padding: 0px 3px !important;
    font-weight: 700 !important;
  }

  .quick-install-btn {
    display: none !important;
  }

  .os-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
}

@keyframes dataFlow {
  from { stroke-dashoffset: 15; }
  to { stroke-dashoffset: 0; }
}

/* --------------------------------------
   SHOP PHASE (Step 1)
--------------------------------------- */
#shop-view, #build-view {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  color: var(--text-color);
  box-sizing: border-box;
  overflow: hidden;
}

#shop-view {
  padding: 1rem 2rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.shop-header {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(0, 240, 255, 0.25);
  margin-bottom: 1rem;
}

.shop-header .header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.shop-header h1 {
  font-size: 1.8rem;
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.shop-mission-desc {
  color: #94a3b8;
  font-size: 0.88rem;
  margin: 4px 0 0 0;
}

.mobile-cart-btn {
  display: none;
}

.mobile-cart-btn .badge {
  background: var(--accent-color);
  color: #000;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.shop-layout {
  display: flex;
  flex: 1;
  gap: 1.5rem;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.shop-products {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: max-content;
  align-items: start;
  gap: 1.2rem;
  overflow-y: auto;
  padding-right: 0.6rem;
  padding-bottom: 3.5rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.product-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.2);
}

.product-card.in-cart {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.product-card.in-cart::before {
  content: '✓ ในตะกร้าแล้ว';
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid #10b981;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  z-index: 2;
}

.product-image {
  height: 110px;
  width: 100%;
  object-fit: contain;
  margin-bottom: 0.8rem;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

.product-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.4rem 0;
  color: #fff;
  line-height: 1.3;
}

.product-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 0.8rem;
  flex: 1;
  line-height: 1.4;
}

.product-price {
  font-size: 1.15rem;
  color: var(--accent-color);
  font-weight: 800;
  margin-bottom: 0.8rem;
  font-family: monospace;
}

.add-cart-btn {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  padding: 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.add-cart-btn:hover {
  background: var(--accent-color);
  color: #000;
}

.add-cart-btn.added {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #f87171;
}

.add-cart-btn.added:hover {
  background: #ef4444;
  color: #fff;
}

.shop-cart {
  width: 320px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cart-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
}

.close-cart-btn {
  display: none;
}

.cart-drawer-backdrop {
  display: none;
}

.mobile-sticky-cart-bar {
  display: none;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 2.5rem 1rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--accent-color);
  border-radius: 4px;
}

.cart-item.warning-item {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.cart-item-name {
  font-size: 0.88rem;
  color: white;
  font-weight: 600;
}

.cart-item-price {
  font-size: 0.8rem;
  color: #94a3b8;
  font-family: monospace;
}

.remove-item-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0 4px;
  transition: transform 0.2s;
}

.remove-item-btn:hover {
  transform: scale(1.2);
}

.cart-summary {
  padding: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}

.cart-total {
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  margin-bottom: 1rem;
  text-align: right;
  font-family: monospace;
}

.checkout-main-btn {
  width: 100%;
}

.cyber-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  padding: 0.8rem 1.4rem;
  background: var(--accent-color);
  color: black;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  border-radius: 4px;
}

.cyber-btn.btn-block,
.cart-summary .cyber-btn {
  width: 100%;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.header-titles {
  text-align: left;
  flex: 1;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.header-btn {
  background: rgba(0, 240, 255, 0.12) !important;
  border: 1px solid var(--accent-color) !important;
  color: var(--accent-color) !important;
  padding: 0.55rem 1.2rem !important;
  font-size: 0.95rem !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  transition: all 0.2s ease !important;
}

.header-btn:hover {
  background: var(--accent-color) !important;
  color: #000 !important;
  box-shadow: 0 0 15px var(--accent-glow) !important;
  transform: translateY(-2px);
}

.cyber-btn:hover {
  background: white;
  box-shadow: 0 0 15px var(--accent-glow);
}

.warning-modal {
  border-color: #ef4444;
  box-shadow: 0 10px 40px rgba(239, 68, 68, 0.2);
}

.warning-title {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  margin-top: 0;
}

#validation-errors {
  color: #fca5a5;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.danger-modal {
  border-color: #ef4444;
  box-shadow: 0 10px 40px rgba(239, 68, 68, 0.4);
  text-align: center;
}

.danger-title {
  font-size: 2.5rem;
  color: #ef4444;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
  margin-top: 0;
  margin-bottom: 1rem;
}

.danger-btn {
  background: #ef4444;
  color: white;
  margin-top: 1.5rem;
}

.danger-btn:hover {
  background: white;
  color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
}

.intro-modal {
  border-color: #3b82f6;
  box-shadow: 0 10px 40px rgba(59, 130, 246, 0.4);
  text-align: center;
}

.intro-modal h2 {
  color: #3b82f6;
  margin-top: 0;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.processing-spinner {
  font-size: 4rem;
  color: var(--accent-color);
  margin-bottom: 1.5rem;
  text-shadow: 0 0 20px var(--accent-glow);
}

.processing-title {
  font-size: 1.8rem;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.processing-subtitle {
  color: #94a3b8;
  font-size: 1rem;
}

/* Toast Notifications */
.notification-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.9);
  border-left: 4px solid var(--accent-color);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
}

.toast.show {
  transform: translateX(0);
}

@media (max-width: 600px) {
  .notification-container {
    top: calc(42px + env(safe-area-inset-top, 8px));
    bottom: auto;
    left: 12px;
    right: 12px;
  }
  .toast {
    transform: translateY(-120%);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }
  .toast.show {
    transform: translateY(0);
  }
}

.toast.warning {
  border-left-color: #f59e0b;
}
.toast.warning i {
  color: #f59e0b;
}

.toast.error {
  border-left-color: #ef4444;
}
.toast.error i {
  color: #ef4444;
}

.toast.success {
  border-left-color: #10b981;
}
.toast.success i {
  color: #10b981;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
}

@media (max-height: 850px) {
  .modal-overlay {
    align-items: flex-start;
  }
}

.modal-content {
  background: var(--bg-color);
  padding: 2.5rem;
  width: 90%;
  max-width: 500px;
  border: 1px solid var(--accent-color);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%);
  opacity: 1;
  transform: none;
}

@keyframes modalPop {
  0% { opacity: 0; transform: scale(0.8) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ----------------------------------
   OS Selection Modal (Part 2)
   ---------------------------------- */
.os-modal-content {
  background: rgba(10, 15, 30, 0.98);
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.25);
  border-radius: 12px;
  clip-path: none;
  padding: 2rem;
  text-align: center;
  max-width: 650px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}

.os-modal-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid var(--accent-color);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 0.8rem;
  letter-spacing: 1px;
}

.os-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.os-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.2rem 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.os-card:hover {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent-color);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.2);
}

.os-card.selected {
  background: rgba(0, 240, 255, 0.15);
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.4);
  transform: translateY(-2px);
}

.os-card.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 8px;
  color: var(--accent-color);
  font-weight: bold;
  font-size: 1rem;
}

.os-card-icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
  transition: transform 0.2s ease;
}

.os-card:hover .os-card-icon {
  transform: scale(1.1);
}

.os-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.2rem;
}

.os-card-tag {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.os-card-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .os-modal-content {
    padding: 1.2rem 0.8rem;
    max-height: 94vh;
  }
  .os-modal-content h2 {
    font-size: 1.3rem !important;
  }
  .os-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin: 0.8rem 0;
  }
  .os-card {
    padding: 0.8rem 0.4rem;
  }
  .os-card-icon {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
  }
  .os-card-title {
    font-size: 0.9rem;
  }
  .os-card-tag {
    font-size: 0.65rem;
    margin-bottom: 0.3rem;
  }
  .os-card-desc {
    font-size: 0.7rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  #install-os-btn {
    font-size: 0.92rem !important;
    padding: 0.65rem !important;
  }
}

/* Install Progress Bar */
.install-progress-bar-container {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.install-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f0ff, #3b82f6);
  border-radius: 6px;
  transition: width 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.8);
}

/* ----------------------------------
   ACTIVE LEARNING: POWER ON SCREEN
   ---------------------------------- */
.power-station-card {
  background: rgba(10, 16, 32, 0.96);
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.35);
  border-radius: 16px;
  max-width: 840px;
  width: 95%;
  padding: 2.2rem;
  display: flex;
  gap: 2rem;
  align-items: center;
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  .power-station-card {
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.2rem;
    text-align: center;
  }
}

.power-case-visual {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.pc-case-frame {
  position: relative;
  width: 240px;
  height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.pc-case-power-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 25px rgba(0,0,0,0.8));
  z-index: 2;
  position: relative;
  transition: all 0.5s ease;
}

.pc-rgb-fan-glow {
  position: absolute;
  top: 25%;
  left: 20%;
  width: 60%;
  height: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.4), rgba(255, 0, 128, 0.3), transparent 70%);
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0;
  z-index: 1;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.pc-case-frame.powered-on .pc-rgb-fan-glow {
  opacity: 1;
  animation: rgbCycle 4s infinite linear;
}

@keyframes rgbCycle {
  0% { filter: blur(25px) hue-rotate(0deg); }
  100% { filter: blur(25px) hue-rotate(360deg); }
}

.power-action-panel {
  flex: 1.4;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.power-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #10b981;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.power-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.power-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
}

.power-btn-container {
  position: relative;
  margin: 1rem 0;
}

.pc-big-power-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e293b, #0f172a);
  border: 3px solid var(--accent-color);
  color: var(--accent-color);
  font-size: 2.5rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.4), 0 0 15px rgba(0, 240, 255, 0.3) inset;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  z-index: 5;
}

.pc-big-power-btn:hover {
  transform: scale(1.08);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 45px rgba(0, 240, 255, 0.7), 0 0 25px rgba(0, 240, 255, 0.5) inset;
}

.pc-big-power-btn:active,
.pc-big-power-btn.booting {
  transform: scale(0.95);
  border-color: #10b981;
  color: #10b981;
  box-shadow: 0 0 50px #10b981, 0 0 30px #10b981 inset;
}

.power-btn-pulse {
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent-color);
  opacity: 0.6;
  animation: powerPulse 2s infinite ease-out;
  pointer-events: none;
}

@keyframes powerPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.power-btn-caption {
  font-size: 0.85rem;
  color: var(--accent-color);
  letter-spacing: 2px;
  font-weight: 700;
}

.power-boot-log {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 8px 16px;
  width: 100%;
  font-size: 0.85rem;
  color: #94a3b8;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.power-boot-log .log-line.active {
  color: #10b981;
  font-weight: 600;
}

/* ----------------------------------
   CABLE & MONITOR SETUP VIEW (PHASE 2.5)
   ---------------------------------- */
.cable-setup-view {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #0d1527 0%, #050811 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cable-setup-view.hidden {
  display: none !important;
}

.cable-setup-header {
  text-align: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.cable-setup-header h1 {
  font-size: 1.5rem;
  color: var(--accent-color);
  margin-bottom: 4px;
}

.cable-setup-header p {
  font-size: 0.95rem;
  color: #94a3b8;
}

.cable-stage-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.04) 1px, transparent 1px);
  background-size: 30px 30px;
}

.cable-svg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.cable-path-idle {
  fill: none;
  stroke: #475569;
  stroke-width: 6px;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.cable-path-active {
  fill: none;
  stroke: #00f0ff;
  stroke-width: 6px;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.8));
  stroke-dasharray: 8 4;
  animation: cablePowerFlow 1s linear infinite;
}

@keyframes cablePowerFlow {
  to { stroke-dashoffset: -24; }
}

.cable-desk-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  width: 100%;
  max-width: 900px;
  padding: 1rem;
  position: relative;
  z-index: 5;
}

.desk-station {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.station-label {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* PC Station */
.pc-case-device {
  position: relative;
  width: 220px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desk-case-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 15px 30px rgba(0,0,0,0.8));
}

.pc-case-glow {
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
  pointer-events: none;
}

.gpu-port-anchor {
  position: absolute;
  right: -5px;
  top: 55%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 12;
}

.gpu-port-badge {
  font-size: 0.68rem;
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.gpu-port-jack {
  width: 16px;
  height: 20px;
  background: #0284c7;
  border: 2px solid #38bdf8;
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.8);
}

/* Monitor Station */
.monitor-station {
  position: relative;
  width: 260px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.monitor-drop-zone {
  width: 240px;
  height: 220px;
  border: 2px dashed rgba(0, 240, 255, 0.4);
  border-radius: 16px;
  background: rgba(0, 240, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 1rem;
  text-align: center;
  transition: all 0.25s ease;
  position: relative;
}

.monitor-drop-zone:hover,
.monitor-drop-zone.target-match {
  border-color: #00f0ff;
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.3);
  transform: scale(1.02);
}

.zone-icon {
  font-size: 3rem;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
  animation: pulseIcon 1.5s infinite;
}

.zone-title {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.zone-sub {
  color: #94a3b8;
  font-size: 0.78rem;
}

.placed-monitor-device {
  position: relative;
  width: 260px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: winPopup 0.3s ease;
}

.desk-monitor-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 15px 30px rgba(0,0,0,0.8));
}

.monitor-port-target {
  position: absolute;
  left: -10px;
  bottom: 50px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 15;
  transition: transform 0.2s;
}

.monitor-port-target:hover,
.monitor-port-target.active {
  transform: scale(1.1);
}

.port-target-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #00f0ff;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid #00f0ff;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  white-space: nowrap;
}

.port-pulse-beacon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00f0ff;
  box-shadow: 0 0 10px #00f0ff;
  animation: pulseBeacon 1s infinite;
}

@keyframes pulseBeacon {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.monitor-screen-overlay {
  position: absolute;
  top: 25px;
  left: 20px;
  right: 20px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.screen-no-signal {
  color: #ef4444;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  animation: blinkWarn 1.5s infinite;
}

.screen-signal-ok {
  color: #10b981;
  font-weight: 800;
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.85);
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #10b981;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

/* Draggable Cable Plug */
.draggable-cable-plug {
  position: absolute;
  z-index: 25;
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: box-shadow 0.2s;
}

.draggable-cable-plug:active {
  cursor: grabbing;
}

.draggable-cable-plug.connected {
  pointer-events: none;
}

.plug-body {
  background: linear-gradient(135deg, #0284c7, #00f0ff);
  color: #030712;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid #fff;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.8), 0 6px 15px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  gap: 6px;
}

.plug-drag-hint {
  font-size: 0.7rem;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.9);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}

/* Bottom Dock */
.cable-bottom-dock {
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-color);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 10;
}

.cable-dock-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.cable-dock-guide {
  font-size: 0.9rem;
  color: #94a3b8;
}

.cable-inventory-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid var(--accent-color);
  border-radius: 10px;
  padding: 8px 16px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: all 0.2s;
}

.cable-inventory-card:hover {
  background: rgba(0, 240, 255, 0.18);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.3);
}

.cable-inventory-card img {
  width: 50px;
  height: 45px;
  object-fit: contain;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.card-hint {
  font-size: 0.75rem;
  color: var(--accent-color);
}

.cable-success-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
  gap: 1.2rem;
  animation: fadeInSuccess 0.4s ease-out;
}

@keyframes fadeInSuccess {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cable-success-text {
  font-size: 0.95rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-glow {
  animation: proceedPulse 2s infinite ease-in-out;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
}

@keyframes proceedPulse {
  0%, 100% {
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4), 0 0 30px rgba(0, 240, 255, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.8), 0 0 45px rgba(0, 240, 255, 0.4);
    transform: scale(1.02);
  }
}

/* Mobile Responsiveness for Cable View */
@media (max-width: 768px) {
  .cable-desk-area {
    gap: 0.8rem;
    padding: 0.5rem;
  }
  .pc-case-device {
    width: 135px;
    height: 175px;
  }
  .desk-station .station-label {
    font-size: 0.72rem;
    padding: 2px 8px;
  }
  .monitor-station {
    width: 170px;
    min-height: 175px;
  }
  .monitor-drop-zone {
    width: 160px;
    height: 165px;
    padding: 0.4rem;
  }
  .zone-icon {
    font-size: 2rem;
  }
  .zone-title {
    font-size: 0.82rem;
  }
  .zone-sub {
    font-size: 0.65rem;
  }
  .placed-monitor-device {
    width: 170px;
    height: 175px;
  }
  .monitor-port-target {
    left: -5px;
    bottom: 35px;
  }
  .port-target-label {
    font-size: 0.65rem;
    padding: 3px 6px;
  }
  .monitor-screen-overlay {
    top: 15px;
    left: 12px;
    right: 12px;
    height: 80px;
  }
  .screen-no-signal {
    font-size: 0.7rem;
    padding: 4px 6px;
  }
  .screen-signal-ok {
    font-size: 0.72rem;
    padding: 4px 6px;
  }
  .plug-body {
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .plug-drag-hint {
    font-size: 0.65rem;
  }
  .cable-bottom-dock {
    padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom, 0px)) 0.8rem;
  }
  .cable-dock-content {
    gap: 0.6rem;
  }
  .cable-dock-guide {
    display: none;
  }
  .cable-success-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  .cable-success-bar button {
    width: 100%;
    padding: 0.75rem;
  }
}

/* ----------------------------------
   SIMULATED MONITOR & OS DESKTOP
   ---------------------------------- */
.desktop-screen {
  position: fixed;
  inset: 0;
  background: #030712;
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.desktop-screen.hidden {
  display: none !important;
}

.monitor-bezel {
  width: 100%;
  max-width: 1200px;
  height: 92vh;
  background: #111827;
  border: 10px solid #1f2937;
  border-bottom: 24px solid #1f2937;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.9), 0 0 40px rgba(0, 240, 255, 0.1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  .desktop-screen {
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    height: 100% !important;
    height: 100dvh !important;
    width: 100% !important;
    inset: 0 !important;
    overflow: hidden !important;
  }
  .desktop-screen.hidden {
    display: none !important;
  }
  .monitor-bezel {
    height: 100% !important;
    height: 100dvh !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
  }
}

.monitor-screen {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

/* Boot Screen Overlay */
.boot-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

.boot-overlay.hidden-boot {
  opacity: 0;
  pointer-events: none;
}

.boot-logo-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.boot-logo-box i {
  font-size: 4.5rem;
  color: #fff;
  filter: drop-shadow(0 0 20px rgba(255,255,255,0.4));
}

.boot-spinner {
  display: flex;
  gap: 8px;
}

.boot-spinner .spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: bootDotPulse 1.2s infinite ease-in-out both;
}

.boot-spinner .spinner-dot:nth-child(1) { animation-delay: -0.32s; }
.boot-spinner .spinner-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bootDotPulse {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.3; }
  40% { transform: scale(1.1); opacity: 1; }
}

.boot-text {
  color: #94a3b8;
  font-size: 0.95rem;
  letter-spacing: 1px;
}

/* Desktop Environment */
.desktop-env {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* Wallpapers */
.desktop-env.wp-windows {
  background: radial-gradient(circle at 50% 60%, #1e40af 0%, #172554 45%, #030712 100%);
}

.desktop-env.wp-macos {
  background: linear-gradient(135deg, #f97316 0%, #db2777 40%, #4c1d95 80%, #1e1b4b 100%);
}

.desktop-env.wp-ubuntu {
  background: radial-gradient(circle at top left, #e95420 0%, #77216f 50%, #2c001e 100%);
}

.desktop-env.wp-chromeos {
  background: linear-gradient(135deg, #10b981 0%, #0284c7 50%, #1e1b4b 100%);
}

/* macOS Top Bar */
.macos-topbar {
  display: none;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  color: #fff;
  font-size: 0.85rem;
  padding: 0 14px;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}

.desktop-env.ui-macos .macos-topbar {
  display: flex;
}

.macos-left, .macos-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.macos-left .apple-logo {
  font-size: 0.95rem;
}

.macos-left .app-name {
  font-weight: 700;
}

/* Desktop Icons Grid */
.desktop-icons-area {
  flex: 1;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  grid-auto-rows: 90px;
  gap: 1.2rem;
  align-content: start;
  z-index: 10;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
}

.icon-img-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}

.desktop-icon:hover .icon-img-box {
  transform: scale(1.1);
}

#icon-specs .icon-img-box { background: rgba(59, 130, 246, 0.25); border-color: #3b82f6; color: #60a5fa; }
#icon-benchmark .icon-img-box { background: rgba(234, 179, 8, 0.25); border-color: #eab308; color: #fde047; }
#icon-mission .icon-img-box { background: rgba(16, 185, 129, 0.25); border-color: #10b981; color: #34d399; }
#icon-restart .icon-img-box { background: rgba(239, 68, 68, 0.25); border-color: #ef4444; color: #f87171; }

.icon-label {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  line-height: 1.2;
}

/* Windows in Desktop */
.os-window {
  position: absolute;
  top: 10%;
  left: 15%;
  width: 70%;
  max-width: 650px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow: hidden;
  animation: winPopup 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.os-window.hidden {
  display: none !important;
}

@keyframes winPopup {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 768px) {
  .monitor-screen {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
  }
  .desktop-env {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .desktop-env.ui-macos .macos-topbar {
    display: flex !important;
    height: calc(30px + env(safe-area-inset-top, 0px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    font-size: 0.8rem !important;
    flex-shrink: 0 !important;
  }
  .os-window {
    position: fixed !important;
    top: calc(8px + env(safe-area-inset-top, 0px)) !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(56px + env(safe-area-inset-bottom, 8px)) !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 12px !important;
    z-index: 35 !important;
    overflow: hidden !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85) !important;
    background: rgba(15, 23, 42, 0.98) !important;
  }
  .os-window.hidden {
    display: none !important;
  }
  .desktop-env.ui-macos .os-window,
  .desktop-env.macos .os-window {
    top: calc(36px + env(safe-area-inset-top, 0px)) !important;
    bottom: calc(66px + env(safe-area-inset-bottom, 8px)) !important;
  }
  .window-titlebar {
    position: sticky !important;
    top: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    flex-shrink: 0 !important;
    background: rgba(30, 41, 59, 0.98) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 10px !important;
    z-index: 50 !important;
  }
  .window-title {
    font-size: 0.82rem !important;
    margin-right: 0 !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding: 0 6px !important;
  }
  .window-body {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    padding: 0.8rem 0.6rem 3.5rem 0.6rem !important;
  }
  .monitor-chin {
    height: 36px !important;
    padding: 0 12px calc(2px + env(safe-area-inset-bottom, 0px)) 12px !important;
    flex-shrink: 0 !important;
  }
  .monitor-logo-badge {
    font-size: 0.72rem !important;
  }
  .monitor-exit-btn {
    padding: 3px 8px !important;
    font-size: 0.75rem !important;
  }
  .desktop-taskbar {
    height: 44px !important;
  }
  .desktop-env.ui-macos .desktop-taskbar {
    bottom: 8px !important;
    height: 48px !important;
    padding: 4px 10px !important;
  }
  .certificate-body {
    padding: 0.8rem 0.5rem !important;
  }
  .cert-medal {
    font-size: 2.5rem !important;
    margin-bottom: 0.4rem !important;
  }
  .cert-title {
    font-size: 1.15rem !important;
    margin-bottom: 2px !important;
  }
  .cert-name {
    font-size: 1.05rem !important;
    margin-bottom: 0.5rem !important;
  }
  .certificate-body p {
    font-size: 0.8rem !important;
    margin-bottom: 0.8rem !important;
  }
  .cert-meta-grid {
    gap: 0.4rem !important;
    margin: 0.6rem 0 !important;
  }
  .cert-meta-box {
    padding: 4px 8px !important;
  }
  .cert-meta-box div:first-child {
    font-size: 0.65rem !important;
  }
  .cert-meta-box div:last-child {
    font-size: 0.85rem !important;
  }
  .benchmark-body {
    padding: 0.8rem !important;
  }
  .bench-meter-circle {
    width: 75px !important;
    height: 75px !important;
  }
  .bench-meter-circle .fps-counter {
    font-size: 1.5rem !important;
  }
  .bench-info h3 {
    font-size: 1rem !important;
  }
  .bench-info p {
    font-size: 0.78rem !important;
  }
}

.window-titlebar {
  height: 38px;
  background: rgba(30, 41, 59, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 12px;
  justify-content: space-between;
  user-select: none;
}

.window-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.win-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.win-btn::after {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: -10px;
  right: -10px;
}

.win-btn.close { background: #ef4444; }
.win-btn.min { background: #eab308; }
.win-btn.max { background: #22c55e; }

.win-mobile-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.win-mobile-close:hover,
.win-mobile-close:active {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.window-title {
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
  margin-right: 0;
  padding: 0 8px;
}

.window-body {
  padding: 1.5rem;
  color: #f1f5f9;
  overflow-y: auto;
  max-height: 60vh;
}

.os-specs-header-card {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 480px) {
  .os-specs-header-card {
    padding: 10px 12px;
    gap: 8px;
  }
  .os-specs-header-card .os-specs-title {
    font-size: 1rem !important;
  }
}

/* Specs Window Styling */
.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.spec-item-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.spec-icon {
  font-size: 1.6rem;
  color: var(--accent-color);
  width: 32px;
  text-align: center;
}

.spec-details {
  flex: 1;
}

.spec-label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
}

.spec-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

/* Benchmark Window Styling */
.benchmark-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.bench-meter-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid var(--accent-color);
  background: rgba(0, 240, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.bench-meter-circle .fps-counter {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-color);
  line-height: 1;
}

.bench-meter-circle .fps-unit {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 2px;
}

.bench-info h3 {
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 4px;
}

.bench-info p {
  color: #94a3b8;
  font-size: 0.9rem;
}

.bench-progress-track {
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.2rem;
}

.bench-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #00f0ff, #10b981);
  border-radius: 6px;
  transition: width 0.1s linear;
}

.bench-results-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid #10b981;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  text-align: left;
}

/* Certificate Body */
.certificate-body {
  text-align: center;
  padding: 2rem 1.5rem;
}

.cert-medal {
  font-size: 4rem;
  color: #eab308;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px rgba(234, 179, 8, 0.6));
}

.cert-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.cert-name {
  font-size: 1.3rem;
  color: var(--accent-color);
  font-weight: 700;
  margin-bottom: 1rem;
}

.cert-meta-grid {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.2rem 0;
  flex-wrap: wrap;
}

.cert-meta-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 16px;
}

/* Bottom Desktop Taskbar / Dock */
.desktop-taskbar {
  height: 48px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 25;
}

.taskbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Windows Taskbar Style (Centered) */
.desktop-env.ui-windows .taskbar-inner {
  justify-content: space-between;
}

.tb-centered-icons {
  display: flex;
  gap: 8px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.tb-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.tb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.tb-system-tray {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #e2e8f0;
  font-size: 0.85rem;
}

/* macOS Floating Dock Style */
.desktop-env.ui-macos .desktop-taskbar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  padding: 6px 14px;
  height: 54px;
}

/* Monitor Chin & Controls */
.monitor-chin {
  height: 40px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  color: #64748b;
  font-size: 0.85rem;
}

.monitor-logo-badge {
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 0.85rem;
}

.monitor-exit-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.monitor-exit-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

