:root {
  --panel-bg: #111;
  --border: #27272a;
  --text: #e5e7eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #000;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP",
               "Hiragino Sans", "Yu Gothic", "Noto Color Emoji", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  gap: 8px;
}

aside {
  background: var(--panel-bg);
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px) + 12px);
  border-right: 1px solid #000;
  overflow: auto;
}

main {
  display: flex;
  flex-direction: column;
  background: #000;
}

header {
  padding: 10px 16px;
  border-bottom: 1px solid #111;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.github-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.github-link:hover {
  opacity: 1;
}

.field {
  margin-bottom: 10px;
  font-size: 12px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #050505;
  color: var(--text);
  font-size: 13px;
}

#flag1, #flag2 {
  font-family: "Noto Color Emoji", system-ui, -apple-system, "Segoe UI",
               "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

.field textarea {
  resize: vertical;
  min-height: 140px;
}

.inline {
  display: flex;
  gap: 6px;
}

.inline > * {
  flex: 1;
}

/* Color picker group - two color pickers close together */
.color-picker-group {
  display: flex;
  gap: 2px;
  flex: 1;
  align-items: flex-end;
}

.color-picker-group > .field {
  flex: 0 1 auto;
  min-width: 0;
  margin-bottom: 10px;
}

.muted {
  color: #9ca3af;
  font-size: 11px;
}

.btn {
  appearance: none;
  border-radius: 9px;
  border: 1px solid #1f2937;
  background: #111827;
  color: #f9fafb;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
}

.btn.primary {
  background: linear-gradient(180deg, #b91c1c, #7f1d1d);
  border-color: #7f1d1d;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

canvas {
  max-width: 100%;
  max-height: 100vh;
  height: auto;
  width: auto;
  background: #000;
  display: block;
}

footer {
  padding: 8px 12px;
  border-top: 1px solid #111;
  font-size: 11px;
  color: #9ca3af;
}

.settings-toggle-btn,
.settings-close-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.settings-toggle-btn:hover,
.settings-close-btn:hover {
  opacity: 1;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.settings-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.settings-overlay.active {
  display: block;
  opacity: 1;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  
  aside {
    order: 2;
    position: fixed;
    top: 0;
    bottom: 0;
    right: -100%;
    width: 85%;
    max-width: 400px;
    z-index: 999;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    border-right: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  aside.active {
    right: 0;
  }
  
  main {
    order: 1;
  }
  
  .settings-toggle-btn {
    display: flex;
  }
  
  .settings-close-btn {
    display: flex;
  }
}

@media (min-width: 901px) {
  .settings-toggle-btn,
  .settings-close-btn {
    display: none;
  }
  
  .settings-overlay {
    display: none !important;
  }
}

