:root {
  --theme-color: #1c1a99;
}

body {
  font-family: 'Arial', sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#emoji-container {
  max-width: 700px;
  margin: 50px auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  flex: 1;
}

#emoji-header {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 24px;
  color: var(--theme-color);
}

/* Sections */
.tool-section {
  margin-bottom: 24px;
}

.section-label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: #666;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#emoji-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 32px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', Arial, sans-serif;
  line-height: 1.4;
  margin-bottom: 12px;
}

#emoji-input:focus {
  outline: none;
  border-color: var(--theme-color);
}

.emoji-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-btn {
  background: #f4f4f4;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  line-height: 1.3;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', Arial, sans-serif;
}

.preset-btn:hover {
  background: #e0e0e0;
  transform: scale(1.2);
}

/* Controls */
.controls-row {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Size buttons */
.size-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.size-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: bold;
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.size-btn.active {
  background: var(--theme-color);
  color: #fff;
  border-color: var(--theme-color);
}

.size-btn:hover:not(.active) {
  background: #e0e0e0;
}

/* Background buttons */
.bg-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.bg-btn {
  padding: 7px 14px;
  font-size: 13px;
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bg-btn.active {
  background: var(--theme-color);
  color: #fff;
  border-color: var(--theme-color);
}

.bg-btn:hover:not(.active) {
  background: #e0e0e0;
}

/* Hidden native color input triggered by Custom button */
#custom-bg-color {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.color-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff6600;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Padding slider */
#padding-range {
  width: 100%;
  max-width: 300px;
  accent-color: var(--theme-color);
}

/* Preview */
.preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.canvas-wrapper {
  display: inline-block;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  /* Checkerboard to visualize transparency */
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #fff;
}

#preview-canvas {
  display: block;
  max-width: 256px;
  max-height: 256px;
  width: 100%;
  height: auto;
}

.preview-label {
  font-size: 12px;
  color: #999;
  margin: 8px 0 0;
}

/* Download */
.download-bar {
  text-align: center;
}

#download-btn {
  padding: 12px 36px;
  font-size: 16px;
  background-color: var(--theme-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#download-btn:hover {
  background-color: #0d0c5f;
}

/* Toast */
#toast {
  position: fixed;
  top: 40px;
  right: 40px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

#theme-color-picker {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 10px 0;
  background-color: var(--theme-color);
  color: #fff;
  font-size: 14px;
  margin-top: auto;
}

.footer a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
}

.footer a:hover {
  text-decoration: underline;
}

a.external::after {
  content: "↗";
  margin-left: 4px;
}

@media screen and (max-width: 768px) {
  #emoji-container {
    margin: 30px 10px;
    padding: 15px;
  }

  #emoji-header {
    font-size: 20px;
  }
}

@media screen and (max-width: 480px) {
  #emoji-container {
    margin: 10px 5px;
    padding: 10px;
  }

  #emoji-header {
    font-size: 18px;
    margin-bottom: 16px;
  }

  #emoji-input {
    font-size: 26px;
    padding: 8px 10px;
  }

  .preset-btn {
    font-size: 18px;
    padding: 3px 5px;
  }

  .size-btn,
  .bg-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  #padding-range {
    max-width: 100%;
  }

  #download-btn {
    padding: 10px 28px;
    font-size: 15px;
  }

  #toast {
    right: 10px;
    top: 10px;
    font-size: 13px;
  }

  .footer {
    font-size: 12px;
    padding: 8px 10px;
  }
}
