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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: #111827;
  color: #f3f4f6;
  line-height: 1.6;
  padding: 24px;
}

h2 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #f3f4f6;
}

/* ツールバースタイルを改善 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
  background: #1f2937;
  color: #f3f4f6;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #374151;
}

.toolbar-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

select {
  padding: 8px 12px;
  background: #111827;
  color: #f3f4f6;
  border: 1px solid #4b5563;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

select:hover {
  border-color: #6b7280;
  background: #1f2937;
}

select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ボタンスタイルを洗練させた */
button {
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid #4b5563;
  background: #111827;
  color: #f3f4f6;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

button:hover {
  background: #1f2937;
  border-color: #6b7280;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

label {
  font-size: 14px;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

/* チェックボックスのスタイルを改善 */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #3b82f6;
}

#editor-container {
  display: inline-block;
  overflow: auto;
  max-width: 100%;
  border: 1px solid #374151;
  padding: 16px;
  background: #1f2937;
  border-radius: 12px;
  margin-bottom: 24px;
  position: relative;
  min-width: 200px;
  min-height: 200px;
  touch-action: pinch-zoom;
}

.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: #3b82f6;
  cursor: nwse-resize;
  border-radius: 4px 0 12px 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.resize-handle:hover {
  opacity: 1;
}

.resize-handle::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 8px 8px;
  border-color: transparent transparent #ffffff transparent;
}

#editor {
  display: block;
  margin-bottom: 10px;
  background-color: #111827;
  background-image: repeating-conic-gradient(#374151 0% 25%, #1f2937 0% 50%);
  background-size: 10px 10px;
  transform-origin: top left;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: pinch-zoom;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.selection-border {
  position: absolute;
  border: 2px solid #3b82f6;
  pointer-events: none;
  z-index: 100;
  box-sizing: border-box;
}

.layer-item, .frame-item {
  padding: 8px;
  margin-bottom: 4px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-item.active, .frame-item.active {
  background: #1e40af;
  border-color: #3b82f6;
}

.layer-item:hover, .frame-item:hover {
  background: #1f2937;
}

.frame-thumbnail {
  width: 40px;
  height: 40px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
}

.frame-item-content {
  display: flex;
  align-items: center;
  flex: 1;
}

.pixel.no-border {
  outline: none;
}

/* パレットスタイルを改善 */
#palette {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 6px;
  background: #1f2937;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #374151;
}

.color-btn {
  width: 28px;
  height: 28px;
  border: 2px solid #4b5563;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.color-btn:hover {
  border-color: #6b7280;
  transform: scale(1.1);
}

.color-btn.selected {
  border: 2px solid #3b82f6;
  box-shadow: 0 0 0 2px #111827, 0 0 12px rgba(59, 130, 246, 0.5);
  transform: scale(1.15);
}

/* 色表示エリアのダークテーマ対応 */
#currentColorDisplay {
  width: 32px;
  height: 32px;
  border: 2px solid #6b7280;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  position: relative;
}

#currentColorDisplay::before {
  content: '🎨';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
  color: #f3f4f6;
}

#currentColorDisplay:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

#customColorPicker {
  display: none;
  position: absolute;
  background: #111827;
  border: 1px solid #4b5563;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

input[type="color"] {
  width: 50px;
  height: 40px;
  border: 1px solid #4b5563;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

input[type="range"] {
  width: 100px;
  height: 6px;
  border-radius: 3px;
  background: #374151;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: 2px solid #111827;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: 2px solid #111827;
}

/* モーダルスタイルを改善 */
#shortcutsModal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #111827;
  border: 1px solid #374151;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

#shortcutsModal h3 {
  margin-bottom: 16px;
  color: #f3f4f6;
  font-size: 18px;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #374151;
  font-size: 14px;
  color: #d1d5db;
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-key {
  background: #1f2937;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 12px;
  color: #60a5fa;
  border: 1px solid #4b5563;
}

/* ズームコントロールを改善 */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#zoomLevel {
  font-weight: 500;
  color: #e5e7eb;
  min-width: 60px;
  text-align: center;
}

/* ツールモードボタンを改善 */
.tool-mode {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tool-btn {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.tool-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #1e40af;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

p {
  font-size: 14px;
  margin-bottom: 16px;
  color: #d1d5db;
  display: flex;
  align-items: center;
}

input[type="file"] {
  display: none;
}

/* スクロールバーのスタイル */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1f2937;
}

::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

canvas {
  display: none;
}
