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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  overflow: hidden;
  color: #e8f4fc;
}

#gameContainer {
  display: flex;
  width: 100vw;
  height: 100vh;
  gap: 10px;
  padding: 10px;
}

/* Canvas Area */
#canvasArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(180deg, #1e3a5f 0%, #2d5a87 50%, #1e3a5f 100%);
  border-radius: 20px;
  box-shadow:
    0 0 30px rgba(100, 200, 255, 0.1),
    inset 0 0 60px rgba(100, 200, 255, 0.05);
  overflow: hidden;
}

#canvasArea::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

#characterCanvas {
  max-width: 100%;
  max-height: calc(100% - 80px);
  object-fit: contain;
}

/* Action Buttons */
#actionButtons {
  display: flex;
  gap: 15px;
  padding: 15px;
  position: absolute;
  bottom: 10px;
}

.action-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e8f4fc;
}

.action-btn svg {
  width: 24px;
  height: 24px;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.action-btn.primary {
  background: linear-gradient(135deg, #64b5f6, #42a5f5);
  border-color: #90caf9;
}

.action-btn.primary:hover {
  background: linear-gradient(135deg, #90caf9, #64b5f6);
  box-shadow: 0 0 20px rgba(100, 181, 246, 0.5);
}

/* Right Panel */
#rightPanel {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* Category Tabs */
#categoryTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-tab {
  flex: 1;
  min-width: calc(33% - 4px);
  padding: 10px 8px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #a8d4f0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cat-tab:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cat-tab.active {
  background: linear-gradient(135deg, #4fc3f7, #29b6f6);
  color: #0d1b2a;
  box-shadow: 0 4px 15px rgba(79, 195, 247, 0.3);
}

/* Subcategory Selector */
#subcategorySelector {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sub-tab {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  background: transparent;
  color: #81d4fa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sub-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.sub-tab.active {
  background: rgba(79, 195, 247, 0.3);
  border-color: #4fc3f7;
  color: #e8f4fc;
}

/* Color Picker */
#colorPicker {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#colorPicker label {
  display: block;
  font-size: 12px;
  color: #81d4fa;
  margin-bottom: 8px;
}

#hueSlider {
  width: 100%;
  height: 20px;
  -webkit-appearance: none;
  border-radius: 10px;
  background: linear-gradient(to right,
    hsl(0, 80%, 60%),
    hsl(60, 80%, 60%),
    hsl(120, 80%, 60%),
    hsl(180, 80%, 60%),
    hsl(240, 80%, 60%),
    hsl(300, 80%, 60%),
    hsl(360, 80%, 60%)
  );
  outline: none;
  cursor: pointer;
}

#hueSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid #0d1b2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

#hueSlider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid #0d1b2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

#huePreview {
  height: 4px;
  margin-top: 8px;
  border-radius: 2px;
  background: #4fc3f7;
  transition: background 0.3s ease;
}

/* Item Grid */
#itemGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding: 5px;
  flex: 1;
  min-height: 0;
}

#itemGrid::-webkit-scrollbar {
  width: 6px;
}

#itemGrid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

#itemGrid::-webkit-scrollbar-thumb {
  background: rgba(79, 195, 247, 0.5);
  border-radius: 3px;
}

.item-card {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.item-card:hover {
  border-color: rgba(79, 195, 247, 0.5);
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.item-card.selected {
  border-color: #4fc3f7;
  box-shadow: 0 0 15px rgba(79, 195, 247, 0.4);
  background: rgba(79, 195, 247, 0.2);
}

.item-card canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.item-card.none-item::after {
  content: '\2715';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: #81d4fa;
}


/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

#loadingOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.snowflake {
  font-size: 60px;
  color: #81d4fa;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loader p {
  margin-top: 20px;
  font-size: 16px;
  color: #81d4fa;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #gameContainer {
    flex-direction: column;
    padding: 5px;
    gap: 5px;
  }

  #canvasArea {
    flex: none;
    height: 50vh;
    border-radius: 15px;
  }

  #rightPanel {
    width: 100%;
    flex: 1;
    border-radius: 15px;
    padding: 10px;
  }

  #categoryTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 5px;
    padding-bottom: 5px;
  }

  .cat-tab {
    min-width: auto;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 11px;
  }

  #itemGrid {
    gap: 6px;
  }

  .action-btn {
    width: 44px;
    height: 44px;
  }

  .action-btn svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  #itemGrid {
    grid-template-columns: repeat(3, 1fr);
  }
}
