@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Playfair+Display:ital,wght@0,600;0,800;1,600&display=swap');

:root {
  --primary: #ff5277;
  --primary-hover: #ff335e;
  --secondary: #ff758c;
  --bg-start: #ff758c;
  --bg-end: #ff7eb3;
  --text-dark: #2d3748;
  --text-muted: #718096;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(255, 117, 140, 0.15);
  --radius-lg: 20px;
  --radius-md: 12px;
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  padding: 20px;
}

/* Background floating elements */
#floating-hearts {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -50px;
  background-color: rgba(255, 255, 255, 0.3);
  display: inline-block;
  width: 20px;
  height: 20px;
  transform: rotate(-45deg);
  animation: floatUp 8s ease-in-out infinite;
}

.floating-heart::before,
.floating-heart::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.3);
}

.floating-heart::before {
  top: -10px;
  left: 0;
}

.floating-heart::after {
  top: 0;
  left: 10px;
}

@keyframes floatUp {
  0% {
    transform: bottom -50px rotate(-45deg) scale(0.5);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.8;
  }
  100% {
    bottom: 105%;
    transform: rotate(-45deg) translateX(100px) scale(1.2);
    opacity: 0;
  }
}

/* Containers & Layouts */
.app-container {
  width: 100%;
  max-width: 550px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-lg);
  padding: 30px;
  z-index: 1;
  position: relative;
  transition: var(--transition-spring);
  animation: cardAppear 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardAppear {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Sound toggler */
.sound-toggle-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  font-size: 1.2rem;
  transition: var(--transition);
  z-index: 10;
}

.sound-toggle-btn:hover {
  background: #fff;
  transform: scale(1.1);
}

/* Heading Typography */
h1.title {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  font-size: 2.2rem;
  margin-bottom: 15px;
  line-height: 1.2;
}

p.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 25px;
}

/* Unified Button Styling */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-spring);
  font-size: 1rem;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 82, 119, 0.4);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 20px rgba(255, 82, 119, 0.5);
}

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

.btn-secondary {
  background: #edf2f7;
  color: var(--text-dark);
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: rgba(255, 82, 119, 0.05);
  transform: translateY(-2px);
}

/* Interactive Hearts for Customization */
.heart-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}

.heart-divider::before,
.heart-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.heart-icon-bounce {
  color: var(--primary);
  font-size: 1.4rem;
  animation: heartPulse 1.5s infinite;
}

@keyframes heartPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Switcher / Views */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* Portal Panel styles */
.portal-choices {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.portal-heart-btn {
  background: #fff;
  border: 2px solid rgba(255, 82, 119, 0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: var(--transition-spring);
  text-align: left;
}

.portal-heart-btn:hover {
  border-color: var(--primary);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 20px rgba(255, 82, 119, 0.1);
}

.portal-heart-btn .icon {
  background: #ffeef2;
  color: var(--primary);
  font-size: 1.8rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.portal-heart-btn:hover .icon {
  background: var(--primary);
  color: white;
  transform: rotate(15deg);
}

.portal-heart-btn .text-group h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.portal-heart-btn .text-group p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.3;
}

/* Question Designer Form (Maker Mode) */
.maker-form-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.form-input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  outline: none;
  background: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 82, 119, 0.15);
  background: #fff;
}

/* Steps Progress Maker */
.maker-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
  position: relative;
}

.maker-steps::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 10px;
  right: 10px;
  height: 3px;
  background: #edf2f7;
  z-index: 0;
}

.step-bar-active {
  position: absolute;
  top: 15px;
  left: 10px;
  height: 3px;
  background: var(--primary);
  z-index: 0;
  transition: var(--transition);
  width: 0%;
}

.maker-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #edf2f7;
  border: 2px solid #e2e8f0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: var(--transition);
  position: relative;
  background-color: white;
}

.maker-step-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 10px rgba(255, 82, 119, 0.4);
}

.maker-step-dot.completed {
  background: #ffecf0;
  border-color: var(--primary);
  color: var(--primary);
}

/* Option Creator styling */
.options-creator {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.radio-check-custom {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #cbd5e0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.radio-check-custom::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transition: var(--transition);
}

.option-edit-row.correct .radio-check-custom {
  border-color: var(--primary);
}

.option-edit-row.correct .radio-check-custom::after {
  background: var(--primary);
}

.option-edit-row input {
  flex: 1;
}

/* Floating translator bar (Fun extra widget) */
.translator-widget {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 15px;
  margin-top: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.translator-header {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.translator-bubble {
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.88rem;
  font-style: italic;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.03);
}

.translator-bubble strong {
  color: var(--primary);
  font-style: normal;
}

/* Link share container */
.share-link-container {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 15px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.link-input-group {
  display: flex;
  gap: 8px;
}

.link-input-group input {
  flex: 1;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  outline: none;
  font-family: monospace;
}

/* Player Mode Styles */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.love-meter-container {
  flex: 1;
  background: #edf2f7;
  height: 12px;
  border-radius: 6px;
  margin: 0 15px;
  overflow: hidden;
  position: relative;
}

.love-meter-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
  width: 0%;
  border-radius: 6px;
  transition: width 0.5s ease-out;
}

.love-meter-icon {
  font-size: 1.3rem;
  color: var(--primary);
  animation: heartPulse 1.2s infinite;
}

.question-counter {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Question play card */
.question-card-container {
  position: relative;
  min-height: 250px;
  margin-bottom: 25px;
}

.question-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 25px;
  box-shadow: 0 10px 25px rgba(255, 117, 140, 0.08);
  border: 1px solid rgba(255, 82, 119, 0.1);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: cardSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardSlideIn {
  0% { opacity: 0; transform: translateX(50px) rotate(2deg); }
  100% { opacity: 1; transform: translateX(0) rotate(0deg); }
}

.question-card.wrong-shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.question-card.correct-pop {
  animation: popSuccess 0.5s ease;
}

@keyframes popSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); border-color: #4caf50; box-shadow: 0 0 15px rgba(76, 175, 80, 0.3); }
  100% { transform: scale(1); }
}

.question-text {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  color: var(--text-dark);
  line-height: 1.35;
}

.game-options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-choice-btn {
  background: #fdfdfd;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1rem;
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-spring);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--text-dark);
}

.option-choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #fff5f7;
  transform: translateY(-2px);
}

.option-choice-btn:active:not(:disabled) {
  transform: translateY(0);
}

.option-choice-btn.selected-correct {
  border-color: #4caf50;
  background-color: #e8f5e9;
  color: #2e7d32;
  box-shadow: 0 4px 10px rgba(76, 175, 80, 0.15);
}

.option-choice-btn.selected-wrong {
  border-color: #f44336;
  background-color: #ffebee;
  color: #c62828;
  box-shadow: 0 4px 10px rgba(244, 67, 54, 0.15);
}

.option-choice-btn.reveal-correct {
  border-color: #4caf50;
  background-color: #e8f5e9;
  color: #2e7d32;
}

.option-marker {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hint panel popup styling */
.hint-button {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--secondary);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-top: 5px;
}

.hint-button:hover {
  color: var(--primary);
}

.hint-box {
  background: #fff9ea;
  border: 1px dashed #ffd885;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  text-align: center;
  color: #b7791f;
  animation: fadeIn 0.3s ease-out;
  display: none;
}

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

/* Results / Rewards Screen */
.result-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.circular-score {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--percentage) * 1%), #edf2f7 0);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.circular-score::after {
  content: "";
  position: absolute;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: white;
}

.circular-score .score-inner-text {
  position: relative;
  z-index: 2;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary);
}

.score-rank-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--primary);
}

.score-rank-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 10px;
}

/* The Envelope Interactive Prize (Love Letter) */
.prize-envelope-container {
  width: 100%;
  max-width: 320px;
  height: 200px;
  position: relative;
  margin: 20px auto;
  cursor: pointer;
  perspective: 1000px;
}

.envelope-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #f77f98;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 15px 35px rgba(255, 82, 119, 0.25);
  transition: transform 0.4s ease;
}

.envelope-wrapper:hover {
  transform: translateY(-5px);
}

.envelope-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 100px solid #f25574;
  transform-origin: top;
  transition: transform 0.4s ease 0.2s, z-index 0.2s ease 0.2s;
  z-index: 4;
}

.envelope-left {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid #f990a4;
  border-top: 100px solid transparent;
  border-bottom: 100px solid #f990a4;
  border-radius: 0 0 0 10px;
  z-index: 3;
}

.envelope-right {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-right: 160px solid #f990a4;
  border-top: 100px solid transparent;
  border-bottom: 100px solid #f990a4;
  border-radius: 0 0 10px 0;
  z-index: 3;
}

.envelope-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-bottom: 100px solid #f77f98;
  border-radius: 0 0 10px 10px;
  z-index: 3;
}

.envelope-letter {
  position: absolute;
  bottom: 5px;
  left: 15px;
  right: 15px;
  height: 200px;
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 2;
  transition: transform 0.4s ease 0s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px dashed #f990a4;
}

.envelope-letter h4 {
  font-family: var(--font-heading);
  color: var(--primary);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.envelope-letter p {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.envelope-letter .prize-code {
  margin-top: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  color: #d82c50;
  border: 2px dotted #ff5277;
  padding: 5px 12px;
  background: #fff3f5;
  border-radius: 6px;
  letter-spacing: 1px;
}

.heart-seal {
  position: absolute;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.2rem;
  color: #d82c50;
  z-index: 5;
  cursor: pointer;
  transition: var(--transition-spring);
}

.heart-seal:hover {
  transform: translateX(-50%) scale(1.15);
}

/* Open Envelope States */
.prize-envelope-container.open .envelope-top {
  transform: rotateX(180deg);
  z-index: 1;
}

.prize-envelope-container.open .envelope-letter {
  transform: translateY(-135px);
  z-index: 5;
}

.prize-envelope-container.open .heart-seal {
  opacity: 0;
  pointer-events: none;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* Modal styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(45, 55, 72, 0.4);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 450px;
  padding: 25px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.15);
  animation: modalScaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

@keyframes modalScaleUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 12px;
  text-align: center;
}

.modal-body {
  color: var(--text-dark);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

/* Responsive adjust */
@media(max-width: 480px) {
  .app-container {
    padding: 20px;
  }
  h1.title {
    font-size: 1.8rem;
  }
  .portal-heart-btn {
    padding: 15px;
  }
  .portal-heart-btn .icon {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
}
