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

body {
  font-family: 'Arial', 'Helvetica', sans-serif;
  background-color: #1a1410;
  color: #ffffff;
  overflow: hidden;
}

.meme-maker-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #1a1410;
}

/* Header */
.meme-header {
  background-color: #2a2420;
  padding: 12px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3a3430;
  border-radius: 20px 20px 0 0;
  margin: 10px 10px 0 10px;
}

.logo-container {
  flex-shrink: 0;
  position: relative;
}

.logo-link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Logo image - starts hidden, fades in on desktop too */
.logo-image {
  width: 0;
  height: 0;
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  object-fit: contain;
}

/* Logo image - animated state (desktop) */
.logo-container.minimized .logo-image {
  width: 50px;
  height: 50px;
  opacity: 1;
}

.logo-text {
  font-size: 36px;
  font-weight: 900;
  color: #FFB800;
  text-transform: uppercase;
  letter-spacing: -1px;
  margin: 0;
  font-family: 'Impact', 'Arial Black', sans-serif;
  text-shadow: 2px 2px 0px #000000;
  opacity: 1;
  max-width: 300px;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  overflow: hidden;
}

/* Logo text - animated state (desktop) */
.logo-container.minimized .logo-text {
  opacity: 0;
  max-width: 0;
  margin: 0;
}

/* Desktop hover effect - show text again on hover */
@media (min-width: 769px) {
  .logo-container.minimized:hover .logo-image {
    width: 0;
    height: 0;
    opacity: 0;
  }

  .logo-container.minimized:hover .logo-text {
    opacity: 1;
    max-width: 300px;
  }
}

.logo-meme {
  color: #ffffff;
  font-weight: 700;
  font-style: italic;
  text-shadow: 2px 2px 0px #000000;
}

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

.tool-btn {
  background-color: #3a3430;
  border: 2px solid #4a4440;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  text-transform: capitalize;
}

.tool-btn:hover {
  background-color: #4a4440;
  border-color: #FFB800;
  transform: translateY(-1px);
}

.tool-btn:active {
  transform: scale(0.98);
}

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

/* Mobile-only elements - hidden on desktop */
.mobile-only {
  display: none;
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  background-color: #2a2420;
  margin: 0 10px 10px 10px;
  border-radius: 0 0 20px 20px;
}

/* Sidebar */
.sidebar {
  width: 140px;
  background-color: #1a1410;
  border-right: 1px solid #3a3430;
  display: flex;
  flex-direction: column;
  padding: 30px 0;
  gap: 5px;
}

.sidebar-section {
  margin: 0;
}

.sidebar-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: #999;
  padding: 18px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  text-transform: lowercase;
  transition: all 0.2s;
  border-left: 4px solid transparent;
  font-weight: 600;
}

.sidebar-btn:hover {
  background-color: #2a2420;
  color: #FFB800;
}

.sidebar-btn.active {
  background-color: #2a2420;
  color: #FFB800;
  border-left-color: #FFB800;
}

.sidebar-btn svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* Content Panel */
.content-panel {
  width: 420px;
  background-color: #1a1410;
  border-right: 1px solid #3a3430;
  overflow-y: auto;
  padding: 25px 20px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #FFB800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Upload Area */
.upload-area {
  border: 2px dashed #4a4440;
  border-radius: 12px;
  padding: 35px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 20px;
  background-color: #2a2420;
}

.upload-area:hover {
  border-color: #FFB800;
  background-color: #3a3430;
}

.upload-area svg {
  margin-bottom: 12px;
  opacity: 0.7;
  color: #FFB800;
}

.upload-area p {
  margin: 5px 0;
  color: #ddd;
  font-size: 14px;
  font-weight: 500;
}

.upload-hint {
  font-size: 11px;
  color: #999;
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.image-item {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid #2a2420;
  transition: all 0.2s;
  position: relative;
  background-color: #2a2420;
}

.image-item:hover {
  border-color: #FFB800;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(255, 184, 0, 0.3);
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  color: #999;
}

.placeholder-message p {
  margin: 10px 0;
  font-size: 13px;
}

.placeholder-message strong {
  color: #FFB800;
}

.hint {
  font-size: 11px;
  color: #777;
}

/* Effects Grid */
.effects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.effect-btn {
  background-color: #2a2420;
  border: 2px solid #3a3430;
  border-radius: 10px;
  padding: 18px 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 12px;
  transition: all 0.2s;
  font-weight: 600;
}

.effect-btn:hover {
  background-color: #3a3430;
  border-color: #FFB800;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 184, 0, 0.2);
}

.effect-btn span:first-child {
  font-size: 32px;
}

/* Text Controls */
.text-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.text-input {
  width: 100%;
  padding: 13px 15px;
  background-color: #2a2420;
  border: 2px solid #3a3430;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.text-input:focus {
  outline: none;
  border-color: #FFB800;
  background-color: #3a3430;
}

.text-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.text-options label {
  font-size: 12px;
  color: #ddd;
  min-width: 70px;
  font-weight: 600;
}

.slider {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: #3a3430;
  outline: none;
  border: 1px solid #4a4440;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFB800;
  cursor: pointer;
  border: 2px solid #000;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFB800;
  cursor: pointer;
  border: 2px solid #000;
}

.select-input {
  flex: 1;
  padding: 10px 12px;
  background-color: #2a2420;
  border: 2px solid #3a3430;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.select-input:focus {
  outline: none;
  border-color: #FFB800;
}

.color-input {
  width: 55px;
  height: 38px;
  border: 2px solid #3a3430;
  border-radius: 8px;
  background-color: #2a2420;
  cursor: pointer;
}

.color-input:hover {
  border-color: #FFB800;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  background-color: #FFB800;
  border: none;
  border-radius: 10px;
  color: #000000;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.primary-btn:hover {
  background-color: #FFA500;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 184, 0, 0.3);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  width: 100%;
  padding: 12px;
  background-color: #3a3430;
  border: 2px solid #4a4440;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.secondary-btn:hover {
  background-color: #4a4440;
  border-color: #FFB800;
  transform: translateY(-1px);
}

.secondary-btn:active {
  transform: translateY(0);
}

.background-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.background-controls .text-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.background-controls .secondary-btn {
  margin-top: 5px;
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background-color: #2a2420;
  overflow: auto;
}

.canvas-wrapper {
  position: relative;
  border: 4px solid #5a54ff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  background: #2a2420;
  width: 800px;
  height: 800px;
  max-width: 100%;
  max-height: 100%;
}

#memeCanvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  background: transparent;
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.download-btn {
  margin-top: 25px;
  padding: 14px 50px;
  background-color: #FFB800;
  border: none;
  border-radius: 10px;
  color: #000000;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(255, 184, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.download-btn:hover {
  background-color: #FFA500;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 184, 0, 0.5);
}

.download-btn:active {
  transform: translateY(0);
}

.download-btn svg {
  width: 18px;
  height: 18px;
}

/* Scrollbar Styling */
.content-panel::-webkit-scrollbar {
  width: 10px;
}

.content-panel::-webkit-scrollbar-track {
  background: #1a1410;
}

.content-panel::-webkit-scrollbar-thumb {
  background: #3a3430;
  border-radius: 5px;
  border: 2px solid #1a1410;
}

.content-panel::-webkit-scrollbar-thumb:hover {
  background: #4a4440;
}

/* Responsive */
@media (max-width: 1200px) {
  .content-panel {
    width: 300px;
  }

  .canvas-container {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  /* ===== MOBILE LAYOUT OVERHAUL ===== */

  /* Reset body overflow */
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* Container adjustments */
  .meme-maker-container {
    height: auto;
    min-height: 100vh;
  }

  /* ===== HEADER ===== */
  .meme-header {
    padding: 12px 15px;
    margin: 0;
    border-radius: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo-container {
    flex-shrink: 0;
    position: relative;
  }

  .logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Logo image - starts hidden, fades in */
  .logo-image {
    display: block;
    width: 0;
    height: 0;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    object-fit: contain;
  }

  /* Logo image - animated state */
  .logo-container.minimized .logo-image {
    width: 40px;
    height: 40px;
    opacity: 1;
  }

  /* Logo text - starts visible, fades out */
  .logo-text {
    font-size: 22px;
    letter-spacing: -0.5px;
    opacity: 1;
    max-width: 200px;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: hidden;
  }

  /* Logo text - animated state */
  .logo-container.minimized .logo-text {
    opacity: 0;
    max-width: 0;
    margin: 0;
  }

  .logo-meme {
    font-size: 15px;
  }

  /* Toolbar - horizontal scroll with proper containment */
  .toolbar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    flex: 1;
    min-width: 0;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .tool-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    flex-shrink: 0;
    border-radius: 8px;
  }

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

  .tool-btn span {
    display: none;
  }

  /* Show mobile-only button */
  .mobile-only {
    display: flex;
  }

  /* ===== MAIN CONTENT - VERTICAL STACK ===== */
  .main-content {
    flex-direction: column;
    overflow: visible;
    margin: 0;
    border-radius: 0;
    background-color: #1a1410;
  }

  /* ===== SIDEBAR - HORIZONTAL NAVIGATION ===== */
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-bottom: 2px solid #3a3430;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background-color: #2a2420;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar-section {
    flex-shrink: 0;
  }

  .sidebar-btn {
    min-width: 85px;
    width: auto;
    height: 85px;
    padding: 12px 8px;
    border-left: none;
    border-bottom: 4px solid transparent;
    flex-direction: column;
    justify-content: center;
  }

  .sidebar-btn.active {
    border-left: none;
    border-bottom-color: #FFB800;
  }

  .sidebar-btn svg {
    width: 30px;
    height: 30px;
  }

  .sidebar-btn span {
    font-size: 11px;
    margin-top: 6px;
  }

  /* ===== CONTENT PANEL ===== */
  .content-panel {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 2px solid #3a3430;
    overflow-y: visible;
    padding: 0;
    padding-bottom: calc(min(90vw, 90vh) + 80px); /* Add padding equal to canvas height + extra space */
    background-color: #1a1410;
  }

  .panel {
    padding: 25px 20px;
  }

  .panel-title {
    font-size: 20px;
    margin-bottom: 20px;
  }

  /* Upload area */
  .upload-area {
    padding: 30px 15px;
    margin-bottom: 20px;
  }

  .upload-area svg {
    width: 40px;
    height: 40px;
  }

  .upload-area p {
    font-size: 14px;
  }

  /* ===== IMAGE/STICKER GRIDS ===== */
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .image-item {
    height: 150px;
    border-radius: 10px;
    border-width: 2px;
  }

  .placeholder-message {
    grid-column: 1 / -1;
    padding: 30px 20px;
  }

  .placeholder-message p {
    font-size: 14px;
  }

  .placeholder-message .hint {
    font-size: 12px;
  }

  /* ===== TEXT CONTROLS ===== */
  .text-controls {
    gap: 18px;
  }

  .text-input {
    font-size: 16px;
    padding: 15px;
    min-height: 52px;
    border-radius: 10px;
  }

  .text-options {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .text-options label {
    width: 100%;
    min-width: auto;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 5px;
  }

  .slider {
    width: 100%;
    height: 10px;
    min-width: auto;
  }

  .slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  .select-input {
    width: 100%;
    font-size: 16px;
    padding: 14px;
    min-height: 52px;
  }

  .color-input {
    width: 70px;
    height: 52px;
    min-width: 70px;
    min-height: 52px;
  }

  /* ===== BUTTONS ===== */
  .primary-btn,
  .secondary-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    min-height: 56px;
    border-radius: 10px;
  }

  /* ===== EFFECTS GRID ===== */
  .effects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .effect-btn {
    padding: 22px 15px;
    min-height: 110px;
    border-radius: 12px;
  }

  .effect-btn span:first-child {
    font-size: 40px;
  }

  .effect-btn span:last-child {
    font-size: 14px;
    margin-top: 8px;
  }

  /* ===== BACKGROUND CONTROLS ===== */
  .background-controls {
    gap: 15px;
  }

  .background-controls .text-options {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .background-controls .text-options label {
    width: auto;
    margin-bottom: 0;
  }

  .background-controls .secondary-btn {
    margin-top: 0;
  }

  /* ===== CANVAS AREA - LARGE BOTTOM CANVAS ===== */
  .canvas-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    z-index: 90;
    padding: 15px;
    background-color: rgba(26, 20, 16, 0.98);
    pointer-events: none; /* Allow scrolling through the container */
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 2px solid #3a3430;
    touch-action: auto; /* Allow scrolling */
  }

  .canvas-wrapper {
    width: calc(100vw - 20px);
    max-width: min(90vw, 90vh);
    height: calc(100vw - 20px);
    max-height: min(90vw, 90vh);
    margin: 0 auto;
    border-width: 3px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
    position: relative;
    aspect-ratio: 1 / 1;
    background-color: #2a2420;
    overflow: visible;
    touch-action: none;
  }

  /* Fabric.js canvas scaling - Fabric.js handles all scaling */
  .canvas-wrapper .canvas-container {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible;
    pointer-events: auto !important;
    touch-action: none !important;
  }

  #memeCanvas {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    display: block;
    pointer-events: auto !important;
    touch-action: none !important;
  }

  /* Upper canvas (Fabric.js interaction layer) */
  .upper-canvas {
    pointer-events: auto !important;
    touch-action: none !important;
  }

  /* Lower canvas (Fabric.js background layer) */
  .lower-canvas {
    pointer-events: auto !important;
    touch-action: none !important;
  }

  /* Ensure all canvas layers are interactive */
  canvas {
    pointer-events: auto !important;
    touch-action: none !important;
  }

  /* Prevent page scrolling when touching canvas area */
  .canvas-container * {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Mobile-optimized canvas controls */
  @media (max-width: 768px) {
    /* Larger, more visible selection handles */
    .canvas-container .canvas-wrapper canvas {
      cursor: grab;
    }

    .canvas-container .canvas-wrapper canvas:active {
      cursor: grabbing;
    }

    /* Better visual feedback for selected objects */
    .upper-canvas {
      -webkit-tap-highlight-color: transparent;
    }
  }

  .download-btn {
    width: 100%;
    max-width: 400px;
    padding: 16px;
    font-size: 16px;
    min-height: 56px;
    border-radius: 12px;
    margin-top: 15px;
    pointer-events: auto !important;
    touch-action: manipulation;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    justify-content: center;
  }

  .download-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Hide canvas when modal is open */
  .modal.active ~ .meme-maker-container .canvas-container {
    display: none;
  }

  /* Canvas hidden state */
  .canvas-container.hidden {
    display: none;
  }

  /* Canvas toggle button active state */
  #toggleCanvasBtn.active {
    background-color: #FFB800;
    border-color: #FFB800;
    color: #000;
  }

  /* ===== MODAL ===== */
  .modal-content {
    width: 92%;
    max-width: 92%;
    max-height: 85vh;
    margin: 0;
    border-radius: 15px;
  }

  .modal-header {
    padding: 18px 20px;
  }

  .modal-header h3 {
    font-size: 19px;
  }

  .modal-close {
    font-size: 32px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }

  .modal-body {
    padding: 20px;
    max-height: calc(85vh - 80px);
  }

  /* ===== LAYERS ===== */
  .layers-list {
    gap: 12px;
  }

  .layer-item {
    padding: 12px 15px;
    border-radius: 10px;
  }

  .layer-info {
    gap: 12px;
  }

  .layer-preview {
    width: 42px;
    height: 42px;
    font-size: 20px;
    flex-shrink: 0;
  }

  .layer-name {
    font-size: 14px;
    word-break: break-word;
  }

  .layer-actions {
    gap: 8px;
    flex-shrink: 0;
  }

  .layer-action-btn {
    padding: 10px 14px;
    font-size: 16px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 8px;
  }

  /* ===== SCROLLBAR STYLING ===== */
  .content-panel::-webkit-scrollbar {
    width: 8px;
  }

  .content-panel::-webkit-scrollbar-track {
    background: #1a1410;
  }

  .content-panel::-webkit-scrollbar-thumb {
    background: #3a3430;
    border-radius: 4px;
  }
}

@media (max-width: 480px) {
  /* ===== EXTRA SMALL DEVICES ===== */

  /* Header */
  .meme-header {
    padding: 12px 15px;
  }

  .logo-text {
    font-size: 22px;
  }

  .logo-meme {
    font-size: 15px;
  }

  .toolbar {
    gap: 6px;
  }

  .tool-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

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

  /* Sidebar */
  .sidebar-btn {
    min-width: 75px;
    height: 80px;
    padding: 10px 6px;
  }

  .sidebar-btn svg {
    width: 26px;
    height: 26px;
  }

  .sidebar-btn span {
    font-size: 10px;
    margin-top: 4px;
  }

  /* Content Panel */
  .panel {
    padding: 20px 15px;
  }

  .panel-title {
    font-size: 18px;
    margin-bottom: 18px;
  }

  /* Upload area */
  .upload-area {
    padding: 25px 12px;
  }

  .upload-area svg {
    width: 35px;
    height: 35px;
  }

  .upload-area p {
    font-size: 13px;
  }

  /* Image grid */
  .image-grid {
    gap: 12px;
  }

  .image-item {
    height: 140px;
  }

  /* Text controls */
  .text-input {
    padding: 14px;
    min-height: 50px;
    font-size: 16px;
  }

  .text-options label {
    font-size: 12px;
  }

  .select-input {
    padding: 13px;
    min-height: 50px;
  }

  .color-input {
    width: 65px;
    height: 50px;
    min-width: 65px;
    min-height: 50px;
  }

  /* Buttons */
  .primary-btn,
  .secondary-btn {
    padding: 15px;
    font-size: 15px;
    min-height: 54px;
  }

  /* Effects - single column for better usability */
  .effects-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .effect-btn {
    padding: 20px 15px;
    min-height: 100px;
  }

  .effect-btn span:first-child {
    font-size: 36px;
  }

  .effect-btn span:last-child {
    font-size: 13px;
  }

  /* Canvas - optimized for extra small devices */
  .canvas-container {
    padding: 10px;
  }

  .canvas-wrapper {
    width: calc(100vw - 20px);
    max-width: min(92vw, 92vh);
    height: calc(100vw - 20px);
    max-height: min(92vw, 92vh);
    border-width: 2px;
    border-radius: 10px;
  }

  .download-btn {
    max-width: 350px;
    padding: 14px;
    font-size: 15px;
    min-height: 52px;
    margin-top: 12px;
  }

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

  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 95%;
  }

  .modal-header {
    padding: 15px 18px;
  }

  .modal-header h3 {
    font-size: 17px;
  }

  .modal-close {
    font-size: 28px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
  }

  .modal-body {
    padding: 18px;
  }

  /* Layers */
  .layer-item {
    padding: 10px 12px;
  }

  .layer-preview {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .layer-name {
    font-size: 13px;
  }

  .layer-actions {
    gap: 6px;
  }

  .layer-action-btn {
    padding: 8px 12px;
    font-size: 15px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ===== LANDSCAPE MODE OPTIMIZATION ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .canvas-container {
    padding: 8px;
  }

  .canvas-wrapper {
    width: min(85vh, 90vw);
    max-width: 90vw;
    height: min(85vh, 90vw);
    max-height: 85vh;
  }

  .download-btn {
    max-width: 300px;
    padding: 12px;
    font-size: 14px;
    min-height: 48px;
  }

  .download-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.2s;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: #2a2420;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border: 2px solid #3a3430;
  animation: slideIn 0.3s;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 25px;
  background-color: #1a1410;
  border-bottom: 2px solid #3a3430;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #FFB800;
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close:hover {
  color: #FFB800;
  transform: rotate(90deg);
}

.modal-body {
  padding: 20px 25px;
  max-height: calc(80vh - 80px);
  overflow-y: auto;
}

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-item {
  background-color: #1a1410;
  border: 2px solid #3a3430;
  border-radius: 8px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  transition: all 0.2s;
}

.layer-item:hover {
  border-color: #FFB800;
  background-color: #2a2420;
}

.layer-item.dragging {
  opacity: 0.5;
}

.layer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.layer-preview {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background-color: #3a3430;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid #4a4440;
}

.layer-name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.layer-actions {
  display: flex;
  gap: 8px;
}

.layer-action-btn {
  background-color: #3a3430;
  border: 1px solid #4a4440;
  border-radius: 6px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.layer-action-btn:hover {
  background-color: #4a4440;
  border-color: #FFB800;
}

