:root {
  --bg-main: #f0e8d8;
  --text-main: #333;
  --surface: #ffffff;
  --surface-muted: #f4f4f4;
  --border-soft: #dfdfdf;
  --button-bg: #eee;
  --button-bg-hover: #ddd;
  --modal-shadow: rgba(0, 0, 0, 0.2);
  --strip-shadow: rgba(0, 0, 0, 0.15);
  --footer-link: #ff6b6b;
  --footer-link-hover: #ff4a4a;
  --menu-border: #1f9d8d;
}

.cause-heading {
  font-family: "Cause", cursive;
  font-optical-sizing: auto;
  font-weight: 800;
  font-style: normal;
}

.cause-display {
  font-family: "Cause", cursive;
  font-optical-sizing: auto;
  font-weight: 900;
  font-style: normal;
}

.cause-subtle {
  font-family: "Cause", cursive;
  font-optical-sizing: auto;
  font-weight: 300;
  font-style: normal;
}

.cause-cta {
  font-family: "Cause", cursive;
  font-optical-sizing: auto;
  font-weight: 600;
  font-style: normal;
}

body[data-theme="dark"] {
  --bg-main: #14171c;
  --text-main: #ffffff;
  --surface: #1f252d;
  --surface-muted: #2a313a;
  --border-soft: #3a434f;
  --button-bg: #333c47;
  --button-bg-hover: #424d5b;
  --modal-shadow: rgba(0, 0, 0, 0.45);
  --strip-shadow: rgba(0, 0, 0, 0.5);
  --footer-link: #ffa98f;
  --footer-link-hover: #ff8f70;
  --bg-image: url("dark-bkg.png");
  --bg-image-opacity: 0.75;
}

html,
body {
  height: 100%;
  min-height: 100vh;
}

body {
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
  background-color: var(--bg-main);
  --bg-image: url("light-bkg.png");
  --bg-image-opacity: 0.90;
  color: var(--text-main);
  text-align: center;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, color 0.25s ease;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 9000;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-image-opacity, 1);
  transition: opacity 0.25s ease;
}

body.modal-open::before {
  opacity: 1;
  pointer-events: auto;
}

#theme-toggle-wrap {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 10px var(--modal-shadow);
}

.theme-label {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cfd6de;
  border-radius: 999px;
  transition: background-color 0.2s ease;
}

.theme-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
}

.theme-switch input:checked + .theme-slider {
  background-color: #4d79ff;
}

.theme-switch input:checked + .theme-slider::before {
  transform: translateX(22px);
}

header {
  padding: 20px;
}

header h1 {
  margin-bottom: 5px;
}

main {
  margin-top: 20px;
}

#cookie-container {
  position: relative;
  margin: 40px auto 0;
  width: 380px;
  height: 260px;
}

#cookie-container img {
  width: 380px;
  cursor: pointer;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transition: transform 0.2s ease;
}

#cookie-whole:hover {
  transform: translateX(-50%) scale(1.05);
}

#cookie-left,
#cookie-right {
  display: none;
  top: 0;
  opacity: 0;
}

#cookie-left {
  clip-path: inset(0 50% 0 0);
}

#cookie-right {
  clip-path: inset(0 0 0 50%);
}

#fortune-strip {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -10px) scale(0.8);
  background: var(--surface);
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: 0 2px 6px var(--strip-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#fortune-strip.visible {
  opacity: 1;
  transform: translate(-50%, -40px) scale(1);
  pointer-events: auto;
}

#fortune-strip-text {
  margin: 0;
  font-size: 1.1rem;
}

@keyframes cookie-shake {
  0% {
    transform: translateX(-50%) rotate(0deg);
  }
  20% {
    transform: translateX(-50%) rotate(5deg);
  }
  40% {
    transform: translateX(-50%) rotate(-5deg);
  }
  60% {
    transform: translateX(-50%) rotate(4deg);
  }
  80% {
    transform: translateX(-50%) rotate(-4deg);
  }
  100% {
    transform: translateX(-50%) rotate(0deg);
  }
}

.shake {
  animation: cookie-shake 0.5s ease;
}

.grow {
  transform: translateX(-50%) scale(1.15);
}

.fall-left {
  animation: fallLeft 0.7s forwards ease-in;
}

.fall-right {
  animation: fallRight 0.7s forwards ease-in;
}

@keyframes fallLeft {
  0% {
    opacity: 1;
    transform: translateX(-50%) translate(0, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translate(-180px, 260px) rotate(-40deg);
  }
}

@keyframes fallRight {
  0% {
    opacity: 1;
    transform: translateX(-50%) translate(0, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translate(180px, 260px) rotate(40deg);
  }
}

#rating-buttons {
  margin-top: 40px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#rating-buttons.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#rating-buttons button {
  margin: 0 10px;
  padding: 10px 22px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s ease, transform 0.1s ease;
}

#rating-buttons button:active {
  transform: scale(0.96);
}

#love-button {
  background: #ff6b6b;
  color: white;
}

#love-button:hover {
  background: #ff4a4a;
}

#meh-button {
  background: #ffd93d;
}

#meh-button:hover {
  background: #f5c400;
}

#hate-button {
  background: #6c757d;
  color: white;
}

#hate-button:hover {
  background: #555d63;
}

footer {
  margin-top: 50px;
  padding: 30px 20px 20px;
  background: linear-gradient(180deg, rgba(31, 157, 141, 0.08) 0%, transparent 100%);
  border-top: 2px solid var(--border-soft);
}

.footer-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.footer-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background: var(--button-bg);
  color: var(--text-main);
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
}

.footer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: var(--button-bg-hover);
}

.footer-btn.primary-btn {
  background: linear-gradient(135deg, #1f9d8d 0%, #17896b 100%);
  color: white;
}

.footer-btn.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(31, 157, 141, 0.4);
}

footer button {
  margin: 5px;
  padding: 8px 15px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--button-bg);
  color: var(--text-main);
  transition: background 0.2s ease;
}

footer button:hover {
  background: var(--button-bg-hover);
}

#footer-link {
  color: var(--footer-link);
  font-weight: bold;
  text-decoration: none;
  transition: 0.2s ease;
}

#footer-link:hover {
  color: var(--footer-link-hover);
  text-decoration: underline;
}

#stats-modal {
  display: none;
  background: var(--surface);
  color: var(--text-main);
  padding: 20px;
  width: 92%;
  max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  border: 4px solid var(--menu-border);
  box-shadow: 0 2px 10px var(--modal-shadow);
  text-align: left;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 9100;
}

#custom-snack-modal,
#achievements-modal,
#export-options-modal,
#reset-confirm-modal {
  display: none;
  background: var(--surface);
  color: var(--text-main);
  padding: 20px;
  width: 92%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 8px;
  border: 4px solid var(--menu-border);
  box-shadow: 0 2px 10px var(--modal-shadow);
  text-align: left;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 9100;
}

#more-options-modal {
  display: none;
  background: var(--surface);
  color: var(--text-main);
  padding: 30px;
  width: 92%;
  max-width: 480px;
  border-radius: 12px;
  border: none;
  box-shadow: 0 20px 60px var(--modal-shadow);
  text-align: left;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 9100;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, -40%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

#more-options-modal h2 {
  margin-top: 0;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #1f9d8d 0%, #17896b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.8rem;
}

.more-options-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.more-options-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  border: none;
  border-radius: 10px;
  background: var(--surface-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
  border: 2px solid transparent;
}

.more-options-item:hover {
  background: linear-gradient(135deg, rgba(31, 157, 141, 0.15) 0%, rgba(23, 137, 107, 0.1) 100%);
  border-color: var(--menu-border);
  transform: translateX(4px);
}

.more-options-item.danger {
  border-color: rgba(255, 107, 107, 0.3);
}

.more-options-item.danger:hover {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15) 0%, rgba(255, 75, 75, 0.1) 100%);
  border-color: #ff6b6b;
}

.option-icon {
  font-size: 1.8rem;
  min-width: 50px;
  text-align: center;
}

.option-text {
  flex: 1;
}

.option-text strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.option-text span {
  display: block;
  font-size: 0.85rem;
  opacity: 0.7;
}

#stats-modal h2,
#custom-snack-modal h2,
#achievements-modal h2,
#export-options-modal h2,
#reset-confirm-modal h2,
#more-options-modal h2 {
  margin-top: 0;
}

#achievements-modal {
  max-width: 680px;
}

.achievements-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}

.achievement-item {
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  padding: 10px 12px;
  background: var(--surface);
}

.achievement-item h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.achievement-item p {
  margin: 0;
  font-size: 0.88rem;
}

.achievement-item.unlocked {
  border-color: #f2cd5c;
  background: linear-gradient(120deg, #fff9de, #fff4c3);
}

.achievement-item.locked {
  background: var(--surface-muted);
  border-color: var(--border-soft);
  color: #888;
  filter: grayscale(0.35);
}

.achievement-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  opacity: 0.85;
}

#achievement-toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.achievement-toast {
  min-width: 240px;
  max-width: 300px;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff3b0, #ffd86b);
  color: #5a4300;
  box-shadow: 0 0 0 rgba(255, 204, 0, 0.4);
  animation: achievement-pop 3.2s ease forwards;
}

.achievement-toast strong {
  display: block;
  margin-bottom: 2px;
}

@keyframes achievement-pop {
  0% {
    transform: translateY(-8px) scale(0.95);
    opacity: 0;
    box-shadow: 0 0 0 rgba(255, 204, 0, 0.1);
  }
  12% {
    transform: translateY(0) scale(1);
    opacity: 1;
    box-shadow: 0 0 18px rgba(255, 191, 0, 0.7);
  }
  75% {
    opacity: 1;
  }
  100% {
    transform: translateY(-4px) scale(0.98);
    opacity: 0;
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.2);
  }
}

@media (max-width: 640px) {
  #achievement-toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .achievement-toast {
    max-width: none;
    min-width: 0;
  }
}

.modal-actions {
  margin-top: 20px;
  text-align: right;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  margin-left: 0;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--button-bg);
  color: var(--text-main);
  transition: all 0.3s ease;
  font-weight: 600;
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.modal-actions button:hover {
  background: var(--button-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.modal-actions button:active {
  transform: translateY(0);
}

.modal-field {
  margin: 12px 0;
}

.modal-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 2px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.95rem;
  box-sizing: border-box;
  transition: all 0.2s ease;
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
}

.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: var(--menu-border);
  box-shadow: 0 0 0 3px rgba(31, 157, 141, 0.1);
}

.shopping-toggle-btn {
  transition: all 0.2s ease !important;
}

.shopping-toggle-btn:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

@media (max-width: 640px) {
  #theme-toggle-wrap {
    top: 10px;
    left: 10px;
    padding: 7px 9px;
    gap: 6px;
  }

  #stats-modal,
  #custom-snack-modal,
  #achievements-modal,
  #export-options-modal,
  #reset-confirm-modal {
    width: calc(100% - 24px);
    max-height: 82vh;
    padding: 16px;
  }
}

#tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: transparent;
  opacity: 0;
  transition: opacity 0.24s ease;
  pointer-events: none;
}

.tutorial-shade {
  position: absolute;
  background: rgba(9, 12, 18, 0.72);
  backdrop-filter: blur(4px) saturate(120%);
  pointer-events: auto;
}

#tutorial-pointer {
  display: none;
  position: fixed;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  box-shadow: 0 0 0 9999px rgba(8, 12, 18, 0.6), 0 0 0 2px rgba(31, 157, 141, 0.35), 0 0 42px rgba(31, 157, 141, 0.55);
  z-index: 9501;
  pointer-events: none;
  opacity: 0;
  transition: all 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

#tutorial-overlay.visible,
#tutorial-pointer.visible {
  opacity: 1;
}

body.tutorial-active {
  overflow: hidden;
}

.tutorial-card {
  position: fixed;
  z-index: 9502;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, rgba(31, 157, 141, 0.98) 0%, rgba(23, 137, 107, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px rgba(8, 12, 18, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(10px);
  animation: tutorial-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.tutorial-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 36%);
  pointer-events: none;
}

.tutorial-card.below::after,
.tutorial-card.above::after {
  content: "";
  position: absolute;
  left: 32px;
  width: 18px;
  height: 18px;
  background: inherit;
  transform: rotate(45deg);
}

.tutorial-card.below::after {
  top: -9px;
}

.tutorial-card.above::after {
  bottom: -9px;
}

.tutorial-card-kicker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-self: flex-start;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tutorial-card h3 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: 'Cause', cursive, 'Inter', Arial, sans-serif;
  font-size: 1.4rem;
  line-height: 1.05;
}

.tutorial-card p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.94);
}

.tutorial-card-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-card-meta span {
  font-size: 0.82rem;
  opacity: 0.88;
}

#tutorial-next-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 20px rgba(8, 12, 18, 0.15);
}

#tutorial-next-btn:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

#tutorial-next-btn:active {
  transform: translateY(0);
}

@keyframes tutorial-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}