* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6c63ff;
  --secondary: #f5f7fa;
  --text-dark: #222;
  --text-light: #fff;
  --bg-card: #ffffffcc;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  --radius: 16px;
}

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #6c63ff 0%, #48c6ef 100%);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  color: var(--text-light);
}

header h1 {
  font-size: 2.3rem;
  font-weight: 700;
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

main {
  width: 95%;
  max-width: 1100px;
  margin: 2rem auto;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
}

section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

section:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

section h2 {
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.4rem;
}

.upload-section {
  grid-column: 1;
}

.upload-section input[type="file"] {
  display: block;
  margin: 1rem auto;
  padding: 0.8rem 1.2rem;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.upload-section input[type="file"]:hover {
  background: var(--primary);
  color: var(--text-light);
}

#imageCanvas {
  display: block;
  margin: 1.5rem auto 0;
  max-width: 100%;
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  cursor: crosshair;
}

.color-section {
  position: sticky;
  top: 2rem;
  height: fit-content;
  text-align: center;
}

#colorPreview {
  width: 150px;
  height: 150px;
  margin: 1rem auto;
  border-radius: 50%;
  border: 3px solid var(--primary);
  box-shadow: var(--shadow);
}

.color-info p {
  margin: 0.4rem 0;
  font-size: 1rem;
}

button {
  background: var(--primary);
  color: var(--text-light);
  padding: 0.8rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

button:hover {
  background: #5848e0;
}

.palette-section {
  grid-column: 1 / -1;
  text-align: center;
}

#palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 1rem;
}

.palette-color {
  width: 55px;
  height: 55px;
  border-radius: 10px;
  border: 2px solid var(--primary);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.palette-color:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow);
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-light);
  font-size: 0.9rem;
  opacity: 0.9;
}

@media (max-width: 900px) {
  main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .color-section {
    position: relative;
    top: 0;
    order: -1;
  }

  #colorPreview {
    width: 120px;
    height: 120px;
  }

  button {
    width: 100%;
  }
}
