/* ===== БАЗА ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b0d17;
  --bg2: #131628;
  --card: #1a1e33;
  --card-hover: #232847;
  --text: #e8e9f3;
  --muted: #8b90a8;
  --gold: #d4af37;
  --gold-light: #f4e4a1;
  --gryffindor: #ae0001;
  --gryffindor-light: #e8b923;
  --slytherin: #1a472a;
  --slytherin-light: #5d8a6a;
  --ravenclaw: #0e1a40;
  --ravenclaw-light: #946b2d;
  --hufflepuff: #ecb939;
  --hufflepuff-light: #372e29;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

#app {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* Звёзды */
.stars {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 80% 20%, #fff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent),
    radial-gradient(1px 1px at 90% 50%, #fff, transparent),
    radial-gradient(2px 2px at 15% 60%, var(--gold), transparent);
  background-size: 200% 200%;
  opacity: 0.4;
  animation: twinkle 8s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes twinkle { 0% { opacity: .3; } 100% { opacity: .6; } }

/* Экраны */
.screen {
  display: none;
  animation: fadeIn .5s ease;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 60px);
  flex-direction: column;
}
.screen.active { display: flex; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Заголовки */
h1 {
  font-size: clamp(28px, 7vw, 42px);
  font-weight: normal;
  line-height: 1.15;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 32px;
  border: 2px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-family: inherit;
  font-size: 17px;
  border-radius: 12px;
  cursor: pointer;
  transition: all .25s ease;
  font-weight: 600;
  letter-spacing: .5px;
  min-width: 200px;
  text-align: center;
}
.btn:hover, .btn:active {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 30px rgba(212,175,55,.6);
  transform: translateY(-2px);
}
.btn-primary { background: var(--gold); color: var(--bg); }
.btn-primary:hover { background: var(--gold-light); box-shadow: 0 0 40px rgba(212,175,55,.8); }

/* ===== ГЛАВНАЯ ===== */
#screen-home { justify-content: center; align-items: center; text-align: center; }
.home-content { display: flex; flex-direction: column; align-items: center; max-width: 500px; }
.owl {
  font-size: 90px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(212,175,55,.5));
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.lead { color: var(--muted); font-size: 17px; font-style: italic; margin-bottom: 32px; max-width: 400px; }

/* ===== ПИСЬМО (ПЕРГАМЕНТ) ===== */
#screen-letter { justify-content: center; align-items: center; }
.parchment {
  background: linear-gradient(135deg, #f4e4c1 0%, #e8d4a8 100%);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 40px rgba(120,80,20,.2);
  max-width: 520px;
  width: 100%;
  position: relative;
  animation: letterAppear .8s cubic-bezier(.34,1.56,.64,1);
}
@keyframes letterAppear {
  from { opacity: 0; transform: scale(.85) rotate(-3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
.parchment::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence baseFrequency='0.8' numOctaves='3' /></filter><rect width='100' height='100' filter='url(%23n)' opacity='0.06'/></svg>");
  border-radius: 8px;
  pointer-events: none;
}
.parchment-inner {
  background: rgba(255,255,255,.15);
  padding: 32px 24px;
  border-radius: 6px;
  color: #3a2a14;
  font-family: Georgia, serif;
}
.letter-seal {
  width: 60px; height: 60px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #7a1f1f, #4a0e0e);
  color: #f4e4c1;
  font-size: 30px;
  font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 10px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.3);
  font-family: Georgia, serif;
}
.parchment h2 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 20px;
  color: #4a2e0e;
  line-height: 1.3;
}
.letter-text { font-size: 15px; margin-bottom: 12px; line-height: 1.5; color: #3a2a14; }
.form-group { margin-top: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 6px;
  color: #5a3a14;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(80,50,20,.3);
  border-radius: 6px;
  background: rgba(255,255,255,.4);
  font-family: Georgia, serif;
  font-size: 16px;
  color: #2a1a04;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus { border-color: #7a4e1f; background: rgba(255,255,255,.6); }
.form-error { color: #8b1a1a; font-size: 14px; margin-top: 10px; min-height: 20px; text-align: center; font-weight: bold; }
.parchment .btn { margin-top: 20px; width: 100%; }
.parchment .btn-primary { background: #6b2e0e; border-color: #6b2e0e; color: #f4e4c1; }
.parchment .btn-primary:hover { background: #8b3e1e; border-color: #8b3e1e; box-shadow: 0 0 30px rgba(107,46,14,.6); }

/* ===== СЛАЙДЫ ===== */
#screen-slides { justify-content: center; align-items: center; }
.slides-wrap { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; }
.slide-card {
  background: var(--card);
  border: 1px solid rgba(212,175,55,.25);
  border-radius: 18px;
  padding: 36px 28px;
  width: 100%;
  margin-bottom: 24px;
  text-align: center;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn .4s ease;
}
.slide-num {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 16px;
  text-transform: uppercase;
}
.slide-text { font-size: 20px; line-height: 1.4; color: var(--text); font-style: italic; }

/* ===== ЭМБЛЕМЫ ===== */
#screen-houses { justify-content: center; align-items: center; text-align: center; }
.screen-title { font-size: 26px; color: var(--gold); margin-bottom: 8px; }
.screen-sub { color: var(--muted); font-size: 15px; margin-bottom: 28px; font-style: italic; }
.houses-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 460px;
}
.house-card {
  background: var(--card);
  border: 1px solid rgba(212,175,55,.2);
  border-radius: 16px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: houseAppear .6s ease both;
}
.house-card:nth-child(1) { animation-delay: .1s; }
.house-card:nth-child(2) { animation-delay: .2s; }
.house-card:nth-child(3) { animation-delay: .3s; }
.house-card:nth-child(4) { animation-delay: .4s; }
@keyframes houseAppear {
  from { opacity: 0; transform: scale(.7) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.house-card svg { width: 70px; height: 70px; margin-bottom: 10px; }
.house-card-name { font-size: 15px; font-weight: 600; }

/* ===== ТЕСТ ===== */
#screen-quiz { padding-top: 10px; }
.quiz-header { margin-bottom: 28px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: system-ui, sans-serif;
}
.progress-bar { height: 6px; background: var(--card); border-radius: 10px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 10px;
  transition: width .4s ease;
  box-shadow: 0 0 10px rgba(212,175,55,.6);
}
.question-num {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.question-text { font-size: clamp(20px, 5vw, 26px); line-height: 1.3; margin-bottom: 28px; font-weight: normal; }
.answers { display: flex; flex-direction: column; gap: 12px; }
.answer-btn {
  background: var(--card);
  border: 1.5px solid transparent;
  color: var(--text);
  padding: 18px 20px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: all .2s ease;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}
.answer-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--gold);
  transform: scaleY(0);
  transition: transform .2s;
}
.answer-btn:hover, .answer-btn:active {
  background: var(--card-hover);
  border-color: var(--gold);
  transform: translateX(4px);
}
.answer-btn:hover::before { transform: scaleY(1); }
.answer-btn.selected {
  background: var(--card-hover);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,175,55,.3);
}

/* ===== РЕЗУЛЬТАТ ===== */
#screen-result { align-items: center; text-align: center; justify-content: center; }
.result-wrap { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; }
.result-label {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.result-crest {
  width: 160px; height: 160px;
  margin-bottom: 20px;
  animation: crestAppear 1s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 0 40px var(--house-glow, rgba(212,175,55,.6)));
}
@keyframes crestAppear {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.result-house { font-size: clamp(30px, 8vw, 44px); margin-bottom: 8px; line-height: 1.1; }
.result-house.gryffindor { color: #e8b923; text-shadow: 0 0 30px rgba(174,0,1,.6); }
.result-house.slytherin  { color: #5d8a6a; text-shadow: 0 0 30px rgba(26,71,42,.8); }
.result-house.ravenclaw  { color: #946b2d; text-shadow: 0 0 30px rgba(14,26,64,.8); }
.result-house.hufflepuff { color: #ecb939; text-shadow: 0 0 30px rgba(236,185,57,.6); }
.result-trait { font-style: italic; color: var(--muted); margin-bottom: 24px; font-size: 15px; }
.result-card {
  background: var(--card);
  border: 1px solid rgba(212,175,55,.2);
  border-radius: 18px;
  padding: 22px;
  margin-bottom: 16px;
  width: 100%;
  text-align: left;
}
.result-card h3 {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  font-weight: 600;
}
.result-card p { font-size: 15px; line-height: 1.6; color: var(--text); }

.percents { width: 100%; }
.percent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
}
.percent-name { width: 100px; text-align: left; color: var(--muted); }
.percent-bar { flex: 1; height: 8px; background: var(--bg2); border-radius: 10px; overflow: hidden; }
.percent-fill { height: 100%; border-radius: 10px; width: 0; transition: width 1.2s cubic-bezier(.34,1.56,.64,1); }
.percent-fill.gryffindor { background: linear-gradient(90deg, #ae0001, #e8b923); }
.percent-fill.slytherin  { background: linear-gradient(90deg, #1a472a, #5d8a6a); }
.percent-fill.ravenclaw  { background: linear-gradient(90deg, #0e1a40, #946b2d); }
.percent-fill.hufflepuff { background: linear-gradient(90deg, #ecb939, #f4d47a); }
.percent-val { width: 40px; text-align: right; color: var(--text); font-weight: 600; }

.result-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 8px; }

/* Адаптив */
@media (max-width: 400px) {
  .result-crest { width: 130px; height: 130px; }
  .answer-btn { padding: 15px 16px; font-size: 15px; }
  .btn { padding: 14px 24px; font-size: 16px; min-width: 0; width: 100%; }
  .parchment-inner { padding: 24px 16px; }
  .slide-text { font-size: 18px; }
}