@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Roboto:wght@300;400;700&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  --bg: #fdf6f0;
  --card-bg: #ffffff;
  --ruby: #9b1b30;
  --ruby-light: #c0354d;
  --ruby-dark: #7a1526;
  --gold: #d4a843;
  --gold-light: #f0d68a;
  --cream: #faf3e8;
  --cream-dark: #ede0cc;
  --text: #3a2025;
  --text-light: #6b4a52;
  --white: #ffffff;
  --border: #e0cfd3;
  --shadow: rgba(155, 27, 48, 0.12);
  --success-green: #2d8a4e;
  --error-red: #c0354d;
  --option-hover: #fef0f2;
  --option-selected: #fde8eb;
  --option-border-selected: var(--ruby);
  --transition-speed: 0.35s;
}

/* ===== RESET ===== */
html, body {
  margin: 0;
  padding: 0;
  outline: none;
}
*, *::before, *::after {
  box-sizing: border-box;
}

/* ===== BASE ===== */
body {
  color: var(--text);
  font-family: "Roboto", "Helvetica", "Arial", sans-serif;
  background: var(--bg);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  line-height: 1.3;
}
h1 {
  font-size: 2em;
  color: var(--ruby);
  margin: 0 0 15px;
}
h2 {
  font-size: 1.4em;
  color: var(--text);
  margin: 0 0 20px;
}
h3 {
  font-size: 1.3em;
  color: var(--ruby);
  margin: 0 0 10px;
}
p {
  margin: 0 0 15px;
}

/* ===== PROGRESS BAR ===== */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  padding: 12px 20px 8px;
  box-shadow: 0 2px 12px var(--shadow);
  display: none;
}
#progress-track {
  width: 100%;
  height: 10px;
  background: var(--cream-dark);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ruby), var(--ruby-light), var(--gold));
  border-radius: 10px;
  transition: width 0.5s ease;
}
#progress-heart {
  position: absolute;
  top: 4px;
  left: 0%;
  transform: translateX(-50%);
  transition: left 0.5s ease;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
}
#progress-heart svg {
  fill: var(--ruby);
}
#progress-label {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
  font-weight: 700;
}

/* ===== SCREENS ===== */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#screen-quiz {
  padding-top: 80px;
  align-items: flex-start;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 35px 25px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: 0 4px 24px var(--shadow), 0 1px 4px rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--ruby), var(--gold), var(--ruby));
}
.card-center {
  text-align: center;
}

/* ===== HEART ICON (SVG) ===== */
.card-icon svg {
  fill: var(--ruby);
  filter: drop-shadow(0 3px 8px rgba(155, 27, 48, 0.3));
  animation: heartPulse 2s ease-in-out infinite;
}
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ===== WELCOME SCREEN ===== */
.subtitle {
  font-size: 1.1em;
  color: var(--text-light);
}
.table-label {
  display: inline-block;
  background: var(--cream);
  border: 2px solid var(--gold);
  color: var(--ruby);
  font-weight: 700;
  font-size: 1.1em;
  padding: 8px 24px;
  border-radius: 50px;
  margin: 10px 0 20px;
}
.table-label .table-flag {
  font-size: 1.4em;
  vertical-align: middle;
  margin-right: 4px;
}

/* ===== CAPTAIN SCREEN ===== */
.captain-input {
  margin: 20px auto;
  max-width: 320px;
}
.captain-input input[type="text"] {
  width: 100%;
  max-width: 320px;
  height: 60px;
  font-size: 20px;
  text-align: center;
  border: 2px solid var(--cream-dark);
  border-radius: 14px;
  background: var(--cream);
  color: var(--text);
  padding: 10px 16px;
  transition: border-color 0.2s ease;
  margin: 0;
}
.captain-input input[type="text"]:focus {
  outline: none;
  border-color: var(--ruby);
  background: var(--white);
}
.captain-input input[type="text"]::placeholder {
  color: var(--darkaccent, #b9cbd8);
  font-style: italic;
}
#screen-captain h2 i {
  color: var(--gold);
  margin-right: 6px;
}
.captain-error {
  color: var(--error-red);
  font-weight: 700;
  font-size: 0.95em;
  margin: 0 0 10px;
}
.hint {
  font-size: 1em;
  color: var(--text-light);
}
.hint i {
  color: var(--ruby);
  margin-right: 6px;
  font-size: 1.3em;
  vertical-align: middle;
}

/* ===== SELFIE / TIEBREAKER ===== */
#screen-selfie h2 {
  margin-bottom: 6px;
}
#screen-selfie h2 i {
  margin-right: 8px;
  color: var(--gold);
}
#screen-selfie .subtitle {
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 1.05em;
}
#selfie-preview-area {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 4/3;
  margin: 0 auto 20px;
  border-radius: 16px;
  overflow: hidden;
  border: 3px dashed var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  position: relative;
}
#selfie-preview-area.has-photo {
  border-style: solid;
  border-color: var(--ruby);
}
#selfie-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-light);
  font-size: 1em;
}
#selfie-placeholder i {
  font-size: 3em;
  color: var(--gold);
  opacity: 0.5;
}
#selfie-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.selfie-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.selfie-actions .button {
  min-width: 170px;
  font-size: 17px;
  padding: 14px 24px;
}
.selfie-actions .button i {
  margin-right: 6px;
  margin-left: 0;
}
.selfie-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.selfie-nav #btn-selfie-skip {
  opacity: 0.8;
}

/* ===== BUTTONS ===== */
.button {
  color: var(--white);
  background: var(--ruby);
  border: 2px solid var(--ruby);
  padding: 16px 32px;
  display: inline-block;
  font-weight: 700;
  min-width: 140px;
  border-radius: 50px;
  font-size: 18px;
  text-align: center;
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  line-height: 1.2;
  min-height: 60px;
  text-decoration: none;
}
.button i {
  margin-left: 6px;
}
.button:hover {
  background: var(--ruby-dark);
  border-color: var(--ruby-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(155, 27, 48, 0.3);
}
.button:active {
  transform: translateY(0);
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.button.secondary {
  background: transparent;
  border: 2px solid var(--ruby);
  color: var(--ruby);
}
.button.secondary:hover {
  background: var(--option-hover);
  color: var(--ruby-dark);
  border-color: var(--ruby-dark);
}

/* ===== QUESTION CARD ===== */
.question-number {
  display: inline-block;
  background: var(--cream);
  color: var(--ruby);
  font-weight: 700;
  font-size: 14px;
  padding: 4px 14px;
  border-radius: 50px;
  margin-bottom: 15px;
  border: 1px solid var(--cream-dark);
}

/* ===== OPTION BUTTONS ===== */
.option-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 18px 20px;
  margin-bottom: 12px;
  background: var(--cream);
  border: 2px solid var(--cream-dark);
  border-radius: 14px;
  font-size: 18px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.4;
  min-height: 60px;
  position: relative;
}
.option-btn:hover {
  background: var(--option-hover);
  border-color: var(--ruby-light);
}
.option-btn.selected {
  background: var(--option-selected);
  border-color: var(--option-border-selected);
  font-weight: 700;
}
.option-btn.selected .option-letter {
  background: var(--ruby);
  color: var(--white);
  border-color: var(--ruby);
}
.option-btn .option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  margin-right: 14px;
  transition: all 0.2s ease;
  color: var(--text-light);
}
.option-btn .option-text {
  flex: 1;
}

/* Select animation */
.option-btn.pop {
  animation: optionPop 0.3s ease;
}
@keyframes optionPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ===== NAVIGATION ===== */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 25px;
  gap: 12px;
}
.nav-buttons .button {
  margin: 0;
  flex: 1;
  max-width: 200px;
}
#btn-back i {
  margin-left: 0;
  margin-right: 6px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 32, 37, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden {
  display: none;
}
.modal {
  background: var(--white);
  border-radius: 20px;
  max-width: 420px;
  width: 100%;
  padding: 35px 25px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-icon {
  font-size: 48px;
  color: var(--gold);
  margin-bottom: 15px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal-actions .button {
  min-width: 140px;
}

/* ===== SUCCESS SCREEN ===== */
.success-icon svg {
  fill: var(--success-green);
  animation: heartPulse 1.5s ease-in-out infinite;
}
.success-icon svg {
  fill: var(--ruby);
}

/* Floating hearts */
.success-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.floating-heart {
  position: absolute;
  bottom: -60px;
  animation: floatUp linear forwards;
  opacity: 0;
}
.floating-heart svg {
  fill: var(--ruby);
  opacity: 0.6;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) rotate(0deg) scale(0.5); }
  10% { opacity: 0.7; }
  90% { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-110vh) rotate(45deg) scale(1); }
}

/* Confetti */
.confetti-piece {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 10px;
  animation: confettiFall linear forwards;
  z-index: 60;
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(110vh) rotate(720deg); }
}

/* ===== ERROR SCREEN ===== */
.error-icon {
  font-size: 64px;
  color: var(--gold);
}

/* ===== SCREEN TRANSITIONS ===== */
.screen.fade-in {
  animation: fadeIn var(--transition-speed) ease forwards;
}
.screen.fade-out {
  animation: fadeOut var(--transition-speed) ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== RESPONSIVE ===== */
@media only screen and (min-width: 600px) {
  .card {
    padding: 45px 40px;
  }
  h1 {
    font-size: 2.4em;
  }
}
@media only screen and (max-width: 400px) {
  body {
    font-size: 16px;
  }
  .card {
    padding: 25px 18px;
    border-radius: 16px;
  }
  .button {
    padding: 14px 20px;
    font-size: 16px;
    min-width: 110px;
  }
  .option-btn {
    padding: 14px 14px;
    font-size: 16px;
  }
  .selfie-actions .button {
    min-width: 140px;
    font-size: 15px;
    padding: 12px 16px;
  }
  .selfie-nav {
    flex-direction: column;
    gap: 10px;
  }
}
