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

:root {
  --bg: #0b0508;
  --bg-soft: #140910;
  --panel: rgba(18, 6, 12, 0.55);
  --panel-strong: rgba(26, 8, 17, 0.75);
  --line: rgba(230, 179, 179, 0.15);
  --line-strong: rgba(230, 179, 179, 0.3);
  --text: #fdf5f7;
  --muted: #c9aeb7;
  --accent: #e6b3b3;
  --accent-strong: #ffc2c2;
  --accent-deep: #9e2a46;
  --gold: #d4af37;
  --success: #8db596;
  --danger: #cf6679;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --radius: 20px;
  --radius-sm: 12px;
  --font-body: 'Montserrat', sans-serif;
  --font-display: 'Cormorant Garamond', serif;
}

@keyframes sensualBreathe {
  0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.4; }
  50% { transform: scale(1.1) translate(2%, 2%); opacity: 0.7; }
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(15px) scale(0.98); filter: blur(5px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

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

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.veil {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: screen;
}

.veil-a { width: 40vw; height: 40vh; top: -5vh; left: -5vw; background: radial-gradient(circle, rgba(158, 42, 70, 0.5) 0%, transparent 70%); animation: sensualBreathe 20s ease-in-out infinite alternate; }
.veil-b { width: 50vw; height: 50vh; bottom: -10vh; right: -5vw; background: radial-gradient(circle, rgba(74, 15, 34, 0.7) 0%, transparent 70%); animation: sensualBreathe 25s ease-in-out infinite alternate-reverse; }
.veil-c { width: 30vw; height: 30vh; top: 30vh; left: 30vw; background: radial-gradient(circle, rgba(230, 179, 179, 0.1) 0%, transparent 70%); animation: sensualBreathe 18s ease-in-out infinite alternate; }

.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.shell {
  position: relative; z-index: 1;
  width: min(100%, 1400px);
  height: 100dvh;
  padding: 2vh 4vw;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5vh; flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 4px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.3em;
  font-size: 0.65rem; font-weight: 600;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin-top: 0; line-height: 1.1; }

h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-style: italic;
  background: linear-gradient(45deg, var(--text), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

h2 { font-size: clamp(1.3rem, 2.5vw, 1.8rem); margin-bottom: 8px; color: var(--accent-strong); }
h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--accent); }
p { line-height: 1.5; margin-top: 0; margin-bottom: 8px; color: var(--muted); font-size: 0.95rem; }

#app {
  flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 2vh 2vw;
  display: flex; flex-direction: column; justify-content: center;
  max-height: 100%;
  overflow: hidden;
}

.panel::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 50%, rgba(255,255,255,0.01) 100%);
  border-radius: inherit;
}

#app[data-animate="in"] .panel { animation: panelFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards; }

.hero-copy, .step-intro { font-size: 1.05rem; color: var(--muted); max-width: 90%; font-weight: 300; margin-bottom: 1.5vh; }

.poem {
  display: flex; flex-direction: column; gap: 8px;
  padding: 2vh 2vw; margin: 1.5vh 0;
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--accent-deep);
  font-family: var(--font-display); font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-style: italic; color: var(--accent-strong);
}

.poem-text-container {
  margin: 1.5vh 0; padding: 2vh 2vw;
  border-radius: var(--radius-sm); background: rgba(255,255,255,0.01);
  border: 1px solid var(--line); box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

.poem-text {
  font-family: var(--font-display); font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  line-height: 1.8; text-align: center; color: var(--text); margin: 0;
}

.poem-text select {
  font-family: var(--font-display); font-size: inherit; font-style: italic;
  color: var(--accent); border-bottom: 1px dashed var(--accent);
  margin: 0 4px; background: transparent; text-align: center; cursor: pointer;
  transition: all 0.3s; appearance: none; padding: 0 4px;
}

.poem-text select:hover, .poem-text select:focus { color: var(--gold); border-bottom: 1px solid var(--gold); }

#app[data-animate="in"] .poem span { opacity: 0; animation: softRise 600ms ease forwards; }
#app[data-animate="in"] .poem span:nth-child(1) { animation-delay: 100ms; }
#app[data-animate="in"] .poem span:nth-child(2) { animation-delay: 200ms; }
#app[data-animate="in"] .poem span:nth-child(3) { animation-delay: 300ms; }
#app[data-animate="in"] .poem span:nth-child(4) { animation-delay: 400ms; }

.progress-wrap { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1vh; }
.progress-meta { font-family: var(--font-display); color: var(--accent); font-style: italic; font-size: 0.9rem; }
.progress-bar { height: 3px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; margin-bottom: 1.5vh; }
.progress-bar > span { display: block; height: 100%; background: var(--accent-deep); box-shadow: 0 0 10px var(--accent-deep); transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1); }

.banner { margin-bottom: 1.5vh; padding: 10px 14px; border-radius: var(--radius-sm); background: rgba(141, 181, 150, 0.05); border: 1px solid rgba(141, 181, 150, 0.2); color: var(--success); font-weight: 300; font-size: 0.85rem;}
.banner strong { font-family: var(--font-display); font-size: 1rem; display: block; margin-bottom: 2px; }

.card-grid, .choice-grid, .voice-grid, .memory-grid, .classify-grid, .final-seals {
  display: grid; gap: 8px; margin: 1vh 0;
}

.choice-card, .toggle-card, .fragment-card, .memory-card, .classify-card, .seal-button, .selected-card, .voice-card {
  position: relative; width: 100%; text-align: left;
  padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: rgba(255,255,255,0.02);
  color: var(--text); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.choice-card::before, .toggle-card::before, .memory-card::before, .classify-card::before, .voice-card::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  transform: skewX(-20deg); transition: 0.5s;
}

.choice-card:hover::before, .toggle-card:hover::before, .memory-card:hover::before, .classify-card:hover::before { left: 150%; }

.choice-card:hover, .toggle-card:hover, .memory-card:hover, .classify-card:hover, .voice-card:hover {
  background: rgba(255,255,255,0.05); border-color: var(--accent);
  transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.choice-card.active, .toggle-card.active, .memory-card.active, .selected-card.active {
  background: rgba(158, 42, 70, 0.15); border-color: var(--accent-deep);
  box-shadow: inset 0 0 10px rgba(158, 42, 70, 0.1);
}

.choice-title, .memory-card, .voice-card label, .classify-card strong {
  font-family: var(--font-display); font-size: 1.15rem; color: var(--accent-strong);
  margin-bottom: 4px; display: block; font-weight: 600; line-height: 1.1;
}

.choice-subtitle, .helper, .info-box, .hint-box, .success-box, .error-box, label {
  font-size: 0.9rem; line-height: 1.4; color: var(--muted); font-weight: 300; margin: 0;
}

.selected-stack { display: grid; gap: 6px; margin-bottom: 1.5vh; }
.selected-card { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.order-index {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--accent); color: var(--accent);
  font-family: var(--font-display); font-size: 1.1rem; flex-shrink: 0;
}

.inline-actions, .actions, .step-actions, .final-actions {
  display: flex; flex-wrap: wrap; gap: 12px; margin-top: 2vh;
}

button { font-family: var(--font-body); font-size: 0.95rem; letter-spacing: 0.05em; cursor: pointer; }

.primary-button, .secondary-button, .ghost-button, .small-button {
  padding: 12px 24px; border-radius: 50px; transition: all 0.3s ease; position: relative; overflow: hidden;
  text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em;
}

.primary-button { background: var(--accent-deep); color: #fff; border: none; box-shadow: 0 4px 10px rgba(158, 42, 70, 0.3); }
.primary-button:hover { background: #b83353; transform: translateY(-1px); box-shadow: 0 6px 15px rgba(158, 42, 70, 0.4); }

.secondary-button { background: transparent; border: 1px solid var(--line-strong); color: var(--accent); }
.secondary-button:hover { background: rgba(255,255,255,0.05); border-color: var(--accent); }

.small-button { padding: 8px 16px; font-size: 0.85rem; border-radius: 20px; background: transparent; border: 1px solid var(--line); color: var(--accent); }
.small-button:hover { background: rgba(255,255,255,0.05); border-color: var(--accent); }

.ghost-button { padding: 8px 16px; font-size: 0.85rem; background: transparent; border: none; color: var(--muted); }
.ghost-button:hover { color: var(--accent); }

.success-box, .error-box, .hint-box, .info-box {
  padding: 10px 14px; border-radius: var(--radius-sm); margin-top: 1vh; border-left: 2px solid;
}
.error-box { background: rgba(207, 102, 121, 0.05); border-left-color: var(--danger); color: var(--danger); }
.hint-box, .info-box { background: rgba(255,255,255,0.02); border-left-color: var(--accent); }
.hints { padding-left: 16px; margin-top: 6px; }

select {
  width: 100%; margin-top: 8px; padding: 8px 0; border: none;
  border-bottom: 1px solid var(--line-strong); background: transparent;
  color: var(--text); font-family: var(--font-display); font-size: 1.15rem;
  transition: border-color 0.3s;
}
select:focus { outline: none; border-bottom-color: var(--accent); }
select option { background: var(--bg); color: var(--text); font-family: var(--font-body); }

.voice-card label, .classify-card label { display: block; margin-top: 6px; cursor: pointer; }
.classify-card input[type="radio"] { accent-color: var(--accent-deep); margin-right: 6px; }

.sequence-chip, .earned-seal {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 50px; border: 1px solid var(--accent-deep);
  background: rgba(158, 42, 70, 0.2); color: var(--accent-strong);
  font-family: var(--font-display); font-size: 0.9rem; letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(158, 42, 70, 0.2); margin: 2px;
}
.seal-row { display: flex; flex-wrap: wrap; gap: 6px; }

.final-address {
  font-family: var(--font-display); font-size: clamp(2rem, 4vw, 3rem);
  color: var(--gold); margin: 2vh 0; font-style: italic;
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}
.countdown { color: var(--accent); font-weight: 300; letter-spacing: 0.1em; font-size: 1rem; }

/* Grid specific to fit everything */
.choice-grid { grid-template-columns: repeat(3, 1fr); }
.memory-grid { grid-template-columns: repeat(4, 1fr); }
.voice-grid { grid-template-columns: repeat(3, 1fr); }
.classify-grid { grid-template-columns: repeat(3, 1fr); }
.final-seals { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 900px) {
  .choice-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
  .voice-grid { grid-template-columns: repeat(2, 1fr); }
  .classify-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .shell { padding: 1vh 2vw; }
  .panel { padding: 2vh 4vw; }
  .choice-grid, .memory-grid, .voice-grid, .classify-grid { grid-template-columns: 1fr; }
  /* On very small screens where we stack everything 1 by 1, scrolling might be inevitable, but we try */
}

.noscript { margin: 10px; padding: 14px; border-radius: var(--radius-sm); background: #27111f; color: #fff3f9; }
