:root {
  --pink: #ff8fc7;
  --pink-dark: #ec4f9d;
  --purple: #8b5cf6;
  --purple-dark: #6d28d9;
  --blue: #7dd3fc;
  --blue-dark: #0ea5e9;
  --yellow: #ffd76a;
  --green: #6ee7b7;
  --white: #ffffff;
  --text: #4a3b63;
  --text-soft: #7a6b95;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Comic Sans MS', 'Segoe UI Rounded', 'Trebuchet MS', sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: linear-gradient(180deg, #bfe3ff 0%, #dcefff 25%, #f3e3ff 55%, #ffe0f0 100%);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0) 70%);
  z-index: 0;
}

body::before {
  width: 500px;
  height: 300px;
  top: -80px;
  left: -100px;
}

body::after {
  width: 600px;
  height: 350px;
  bottom: -120px;
  right: -150px;
}

.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0.8;
  animation: floatUp linear infinite;
  user-select: none;
}

@keyframes floatUp {
  0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.9; }
  90% { opacity: 0.9; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

.hidden {
  display: none !important;
}

.view {
  position: relative;
  z-index: 5;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Home view ---------- */
.home-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.home-title {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  margin: 0;
  color: var(--purple-dark);
  text-shadow: 3px 3px 0 rgba(255,255,255,0.7);
}

.home-subtitle {
  font-size: 1.15rem;
  color: var(--text-soft);
  margin-top: 0.6rem;
}

.world-grid {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.6rem;
}

.world-card {
  background: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  padding: 2rem 1.2rem;
  box-shadow: 0 10px 25px rgba(140, 90, 200, 0.18);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  text-align: center;
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.world-card:not(.coming-soon):hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 16px 32px rgba(140, 90, 200, 0.3);
}

.world-emoji {
  font-size: 3rem;
  line-height: 1;
}

.world-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--purple-dark);
}

.world-card.coming-soon {
  cursor: default;
  opacity: 0.65;
  box-shadow: 0 6px 16px rgba(140, 90, 200, 0.1);
}

.world-card.coming-soon .world-name {
  color: var(--text-soft);
}

.soon-badge {
  background: #f3f0ff;
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.world-card.more {
  border: 3px dashed #d9c9ff;
  background: rgba(255,255,255,0.5);
}

/* ---------- World view header ---------- */
.world-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.back-btn {
  border: none;
  background: rgba(255,255,255,0.85);
  color: var(--purple-dark);
  font-family: inherit;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(140, 90, 200, 0.15);
  transition: transform 0.15s ease;
}

.back-btn:hover {
  transform: translateY(-2px);
}

#worldTitle {
  font-size: 1.8rem;
  color: var(--purple-dark);
  margin: 0;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.6);
}

.theme-toggle {
  display: flex;
  gap: 0.4rem;
  background: rgba(255,255,255,0.7);
  padding: 0.3rem;
  border-radius: 999px;
}

.theme-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-soft);
}

.theme-btn.active {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: white;
}

/* ---------- Item grid & cards ---------- */
.item-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 2rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.6rem;
  border-radius: var(--radius-lg);
  transition: background 0.3s ease;
}

.item-grid.theme-sky {
  background: linear-gradient(180deg, rgba(191,227,255,0.35), rgba(243,227,255,0.25));
  padding-top: 1.5rem;
}

.item-grid.theme-studio {
  background: #ffffff;
  padding-top: 1.5rem;
  box-shadow: inset 0 0 0 1px #f0eaff;
}

.item-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: 0 10px 25px rgba(140, 90, 200, 0.18);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 32px rgba(140, 90, 200, 0.28);
}

.item-image {
  border-radius: var(--radius-md);
  height: 170px;
  background: linear-gradient(135deg, #cdeeff, #e6d6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  overflow: hidden;
}

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

.item-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--purple-dark);
  margin: 0;
}

.item-stars {
  color: var(--pink-dark);
  letter-spacing: 2px;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.item-tag {
  background: #e9f7ff;
  color: #1a8fc9;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.item-desc {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.4;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-soft);
  padding: 2.5rem 1rem;
  font-size: 1.05rem;
}

.add-btn {
  display: block;
  margin: 0.5rem auto 3rem;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(236, 79, 157, 0.35);
  transition: transform 0.15s ease;
}

.add-btn:hover {
  transform: translateY(-2px) scale(1.02);
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 59, 99, 0.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 50px rgba(80, 50, 130, 0.35);
}

.detail-modal-card {
  max-width: 800px;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #f3e9ff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--purple);
  font-weight: 900;
}

.close-btn:hover {
  background: var(--purple);
  color: white;
}

#addModalTitle {
  color: var(--purple-dark);
  margin: 0 0 1.2rem;
  font-size: 1.4rem;
}

.photo-upload-label {
  display: block;
  cursor: pointer;
}

.photo-preview {
  height: 180px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f3f0ff, #ffeef6);
  border: 3px dashed #d9c9ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--text-soft);
  font-weight: 700;
  overflow: hidden;
  margin-bottom: 1.2rem;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-icon {
  font-size: 2.2rem;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.field-group label {
  display: block;
  font-weight: 800;
  color: var(--purple-dark);
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.field-group input[type="text"],
.field-group textarea {
  width: 100%;
  border: 2px solid #ecdfff;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fbf9ff;
}

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

.field-group input[type="text"]:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--purple);
}

.star-picker {
  display: flex;
  gap: 0.3rem;
  font-size: 1.8rem;
}

.star-picker .star-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #e3d9f5;
  padding: 0;
  line-height: 1;
}

.star-picker .star-btn.selected {
  color: var(--pink-dark);
}

.save-btn {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--green), var(--blue-dark));
  color: white;
  border: none;
  padding: 0.9rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.3);
  transition: transform 0.15s ease;
}

.save-btn:hover {
  transform: translateY(-2px);
}

/* ---------- Detail modal ---------- */
.detail-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
}

.detail-modal-image {
  border-radius: var(--radius-md);
  min-height: 260px;
  background: linear-gradient(135deg, #cdeeff, #e6d6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  overflow: hidden;
}

.detail-modal-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-modal-info h2 {
  color: var(--purple-dark);
  margin: 0 0 0.6rem;
  font-size: 1.6rem;
}

.detail-modal-info .item-stars {
  font-size: 1.3rem;
  display: block;
  margin-bottom: 0.8rem;
}

.detail-modal-info .item-tags {
  margin-bottom: 0.8rem;
}

.detail-modal-info .quote-box {
  background: #ffeef6;
  border-left: 5px solid var(--pink);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  font-style: italic;
  color: var(--text);
}

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 1.5rem;
  color: var(--text-soft);
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .detail-modal-grid {
    grid-template-columns: 1fr;
  }
  .world-header {
    justify-content: center;
    text-align: center;
  }
}
