.prealg-consecration-screen {
  --study-indigo: #3f3f8b;
  --study-indigo-dark: #171936;
  --study-violet: #5b2a86;
  --study-gold: #d4af37;
  --study-paper: #f5edd8;
  --study-ink: #1f1815;
  --study-thread: #8b1a3a;
  color: #fff3d2;
  overflow-y: auto;
}

.prealg-consecration-topbar {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin-bottom: 10px;
}

.prealg-consecration-topbar div {
  min-width: 0;
  text-align: center;
}

.prealg-consecration-topbar span {
  color: var(--text-secondary);
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.prealg-consecration-topbar strong {
  color: var(--text-primary);
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 2.2rem);
  line-height: 1;
}

.prealg-consecration-topbar p {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 900;
  margin: 0;
  text-align: right;
}

.prealg-consecration-progress {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.prealg-consecration-progress span {
  background: linear-gradient(90deg, #7fa36f, var(--study-gold), #c9794a, var(--study-thread));
  display: block;
  height: 100%;
  transition: width 420ms ease;
}

.prealg-consecration-stage {
  background:
    radial-gradient(circle at 50% 14%, rgba(212, 175, 55, 0.18), transparent 22%),
    radial-gradient(circle at 50% 45%, rgba(91, 42, 134, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(31, 36, 84, 0.98), rgba(26, 23, 48, 0.98) 48%, rgba(43, 32, 28, 0.98));
  border: 1px solid rgba(225, 197, 126, 0.28);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  height: min(760px, calc(100vh - 126px));
  min-height: 650px;
  overflow: hidden;
  position: relative;
}

.study-architecture {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.study-architecture::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 10%),
    repeating-linear-gradient(90deg, transparent 0 9%, rgba(245, 237, 216, 0.07) 9% 10%, transparent 10% 20%),
    radial-gradient(ellipse at 50% -8%, transparent 0 27%, rgba(245, 237, 216, 0.12) 27.5% 28.5%, transparent 29%);
  content: "";
  inset: 0;
  position: absolute;
}

.study-architecture span {
  background:
    repeating-linear-gradient(180deg, rgba(245, 237, 216, 0.1) 0 4px, transparent 4px 16px),
    linear-gradient(180deg, rgba(38, 30, 53, 0.9), rgba(18, 15, 28, 0.92));
  border: 1px solid rgba(255, 236, 184, 0.12);
  border-radius: 42px 42px 4px 4px;
  bottom: 0;
  position: absolute;
  top: 12%;
  width: 7%;
}

.study-architecture span:nth-child(1) { left: 5%; }
.study-architecture span:nth-child(2) { left: 17%; opacity: 0.78; }
.study-architecture span:nth-child(3) { right: 17%; opacity: 0.78; }
.study-architecture span:nth-child(4) { right: 5%; }

.study-table {
  bottom: 4%;
  height: 180px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  width: min(860px, 74%);
  z-index: 3;
}

.study-table span {
  background:
    repeating-linear-gradient(90deg, rgba(245, 237, 216, 0.07) 0 1px, transparent 1px 80px),
    linear-gradient(180deg, #7a5139, #2d1c16);
  border: 1px solid rgba(245, 237, 216, 0.18);
  border-radius: 50% 50% 16px 16px / 12% 12% 16px 16px;
  bottom: 0;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.34);
  height: 120px;
  left: 0;
  position: absolute;
  right: 0;
}

.study-table i {
  background: var(--study-thread);
  border-radius: 6px;
  box-shadow: 0 0 18px rgba(139, 26, 58, 0.32);
  height: 34px;
  left: 53%;
  position: absolute;
  top: 28px;
  transform: rotate(-5deg);
  width: 88px;
}

.solution-board {
  background:
    radial-gradient(circle at 18% 28%, rgba(31, 24, 21, 0.09) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 18%, rgba(31, 24, 21, 0.08) 0 2px, transparent 3px),
    repeating-linear-gradient(38deg, rgba(31, 24, 21, 0.04) 0 1px, transparent 1px 18px),
    #7a5a3f;
  border: 10px solid rgba(63, 39, 28, 0.96);
  border-radius: 8px;
  box-shadow: inset 0 0 34px rgba(31, 24, 21, 0.28), 0 28px 50px rgba(0, 0, 0, 0.32);
  height: clamp(410px, 49vw, 470px);
  left: 50%;
  padding: 16px;
  position: absolute;
  top: 4%;
  transform: translateX(-50%);
  width: min(720px, 62%);
  z-index: 5;
}

.solution-board__title {
  align-items: baseline;
  color: var(--study-paper);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.solution-board__title span {
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.solution-board__title strong {
  font-family: var(--font-display);
  font-size: 1.24rem;
}

.solution-board__slots {
  display: grid;
  gap: clamp(92px, 11vw, 120px) 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: 92px 92px;
  position: relative;
  z-index: 1;
}

.solution-slot {
  background: rgba(31, 24, 21, 0.62);
  border: 1px solid rgba(245, 237, 216, 0.22);
  border-radius: 6px;
  color: rgba(245, 237, 216, 0.58);
  display: grid;
  overflow: hidden;
  padding: 8px;
  place-items: center;
  position: relative;
  text-align: center;
  transition: background 600ms ease, box-shadow 600ms ease, color 600ms ease;
}

.solution-slot.is-placed {
  border-style: solid;
}

.solution-slot.is-lit {
  color: #fff6d8;
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.28), inset 0 0 20px rgba(255, 255, 255, 0.08);
}

.solution-slot--solen.is-lit { background: linear-gradient(180deg, rgba(127, 163, 111, 0.86), rgba(41, 77, 54, 0.86)); }
.solution-slot--aldra.is-lit { background: linear-gradient(180deg, rgba(212, 175, 55, 0.9), rgba(72, 61, 41, 0.92)); }
.solution-slot--pellan.is-lit { background: linear-gradient(180deg, rgba(201, 121, 74, 0.9), rgba(67, 39, 31, 0.92)); }
.solution-slot--veth.is-lit { background: linear-gradient(180deg, rgba(139, 26, 58, 0.9), rgba(42, 28, 38, 0.94)); }

.solution-slot span {
  background: rgba(245, 237, 216, 0.86);
  border-radius: 50%;
  color: var(--study-ink);
  font-size: 0.68rem;
  font-weight: 900;
  height: 20px;
  left: 6px;
  line-height: 20px;
  position: absolute;
  top: 6px;
  width: 20px;
}

.solution-slot strong {
  font-size: clamp(0.68rem, 0.9vw, 0.82rem);
  line-height: 1.1;
}

.solution-slot i {
  background: var(--study-thread);
  border-radius: 999px;
  bottom: 7px;
  height: 3px;
  left: 16px;
  opacity: 0.72;
  position: absolute;
  right: 16px;
}

.solution-parchment {
  background: linear-gradient(180deg, #fff8e2, #e6d2a6);
  border: 2px solid rgba(31, 24, 21, 0.22);
  border-radius: 7px;
  box-shadow: 0 16px 28px rgba(31, 24, 21, 0.28);
  color: var(--study-ink);
  cursor: pointer;
  display: grid;
  gap: 4px;
  left: 50%;
  min-height: 136px;
  padding: 14px 18px;
  place-items: center;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -42%);
  width: min(420px, 70%);
  z-index: 3;
}

.solution-parchment:disabled {
  cursor: default;
}

.solution-parchment.is-target {
  animation: solutionPulse 1300ms ease-in-out infinite;
}

.solution-parchment em {
  color: rgba(31, 24, 21, 0.54);
  font-style: normal;
}

.solution-parchment span,
.solution-parchment strong,
.solution-parchment b {
  animation: writeSolution 520ms ease both;
  display: block;
}

.solution-parchment span {
  font-size: 0.82rem;
  line-height: 1.2;
}

.solution-parchment strong,
.solution-parchment b {
  color: var(--study-violet);
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 1.8vw, 1.52rem);
  line-height: 1;
}

.solution-parchment strong:nth-of-type(2) {
  animation-delay: 160ms;
}

.solution-parchment b {
  animation-delay: 300ms;
  color: var(--study-gold);
}

.prealg-master,
.prealg-apprentice {
  background: transparent;
  border: 0;
  color: #fff3d2;
  cursor: pointer;
  padding: 0;
  position: absolute;
  z-index: 8;
}

.prealg-master:disabled,
.prealg-apprentice:disabled {
  cursor: default;
}

.prealg-master.is-target .prealg-master__sprite,
.prealg-apprentice.is-target .prealg-apprentice__sprite {
  filter: drop-shadow(0 0 18px rgba(245, 211, 122, 0.82));
  transform: translateY(-4px);
}

.prealg-master__sprite,
.prealg-apprentice__sprite {
  display: block;
  height: 128px;
  margin: 0 auto 6px;
  position: relative;
  transition: transform 240ms ease, filter 240ms ease;
  width: 82px;
}

.prealg-master__sprite i,
.prealg-apprentice__sprite i {
  background: #bd815c;
  border-radius: 42% 42% 48% 48%;
  height: 46px;
  left: 22px;
  position: absolute;
  top: 0;
  width: 38px;
}

.prealg-master__sprite b,
.prealg-apprentice__sprite b {
  background: linear-gradient(180deg, var(--study-violet), #35204f);
  border-radius: 24px 24px 10px 10px;
  height: 82px;
  left: 14px;
  position: absolute;
  top: 43px;
  width: 54px;
}

.prealg-master__sprite em,
.prealg-apprentice__sprite em {
  background: rgba(245, 237, 216, 0.82);
  border-radius: 999px;
  height: 8px;
  left: 16px;
  position: absolute;
  top: 72px;
  transform: rotate(-16deg);
  width: 50px;
}

.prealg-master__name,
.prealg-master__role,
.prealg-apprentice strong {
  display: block;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

.prealg-master__name,
.prealg-apprentice strong {
  font-family: var(--font-display);
  font-size: 0.96rem;
}

.prealg-master__role {
  color: rgba(255, 243, 210, 0.76);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.prealg-master__line {
  background: rgba(245, 237, 216, 0.96);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 8px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.26);
  color: var(--study-ink);
  display: block;
  font-size: 0.88rem;
  left: 50%;
  line-height: 1.2;
  min-width: 190px;
  padding: 9px 11px;
  position: absolute;
  top: -54px;
  transform: translateX(-50%);
}

.prealg-master--solen { left: 13%; top: 17%; }
.prealg-master--aldra { right: 13%; top: 17%; }
.prealg-master--pellan { left: 12%; bottom: 18%; }
.prealg-master--veth { right: 12%; bottom: 18%; }

.prealg-master--solen .prealg-master__sprite b { background: linear-gradient(180deg, #708a5c, #304c38); }
.prealg-master--aldra .prealg-master__sprite b { background: linear-gradient(180deg, #b18a33, #332d25); }
.prealg-master--pellan .prealg-master__sprite b { background: linear-gradient(180deg, #b65f3f, #4b2c22); }
.prealg-master--veth .prealg-master__sprite b { background: linear-gradient(180deg, #5b2a86, #2d1b42); }

.prealg-apprentice {
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
}

.prealg-apprentice__bundle {
  background: linear-gradient(180deg, #d4af37, #8b1a3a);
  border-radius: 5px;
  display: block;
  height: 34px;
  left: 50%;
  opacity: 1;
  position: absolute;
  top: 66px;
  transform: translateX(-50%) rotate(-5deg);
  transition: opacity 420ms ease;
  width: 56px;
}

.prealg-apprentice.has-placed .prealg-apprentice__bundle {
  opacity: 0.18;
}

.prealg-consecration-cue {
  background: rgba(20, 18, 34, 0.88);
  border: 1px solid rgba(245, 237, 216, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
  color: #fff3d2;
  left: 50%;
  max-width: min(560px, 58%);
  padding: 10px 14px;
  position: absolute;
  text-align: center;
  top: 18px;
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: none;
}

.prealg-consecration-cue span {
  color: rgba(255, 243, 210, 0.68);
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.prealg-consecration-cue h1 {
  color: #fff8d8;
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 2vw, 1.65rem);
  line-height: 1;
  margin: 2px 0 6px;
}

.prealg-consecration-cue p {
  color: rgba(255, 243, 210, 0.86);
  font-size: 0.86rem;
  line-height: 1.25;
  margin: 0;
}

.prealg-consecration-cue strong {
  color: var(--study-gold);
  display: block;
  font-size: 0.86rem;
  margin-top: 8px;
  text-transform: uppercase;
}

.prealg-title-card {
  background:
    radial-gradient(circle at 50% 18%, rgba(212, 175, 55, 0.2), transparent 28%),
    linear-gradient(180deg, #30306f, #171936);
  border: 1px solid rgba(212, 175, 55, 0.34);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.44);
  display: grid;
  min-height: min(760px, calc(100vh - 126px));
  overflow: hidden;
  padding: 42px 24px;
  place-items: center;
  position: relative;
  text-align: center;
}

.prealg-title-card > span {
  color: rgba(245, 237, 216, 0.72);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prealg-title-card p {
  color: #fff3d2;
  font-size: 1.05rem;
  margin: 0;
}

.prealg-title-card h1 {
  color: #f8dc83;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 0.94;
  margin: 10px 0 6px;
  max-width: 900px;
}

.prealg-title-stars {
  color: rgba(255, 255, 255, 0.24);
  font-size: 1.8rem;
  margin-bottom: 18px;
}

.prealg-title-stars span.is-filled {
  color: var(--study-gold);
}

.prealg-title-card__dust {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.prealg-title-card__dust span {
  animation: studyDust 4200ms ease-in-out infinite;
  background: rgba(212, 175, 55, 0.44);
  border-radius: 50%;
  height: 8px;
  position: absolute;
  width: 8px;
}

.prealg-title-card__dust span:nth-child(1) { left: 18%; top: 32%; }
.prealg-title-card__dust span:nth-child(2) { left: 72%; top: 24%; animation-delay: 600ms; }
.prealg-title-card__dust span:nth-child(3) { left: 28%; top: 70%; animation-delay: 1100ms; }
.prealg-title-card__dust span:nth-child(4) { left: 82%; top: 64%; animation-delay: 1700ms; }

@keyframes solutionPulse {
  0%, 100% { box-shadow: 0 16px 28px rgba(31, 24, 21, 0.28), 0 0 0 0 rgba(212, 175, 55, 0.32); }
  50% { box-shadow: 0 16px 28px rgba(31, 24, 21, 0.28), 0 0 0 12px rgba(212, 175, 55, 0); }
}

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

@keyframes studyDust {
  0%, 100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-24px);
  }
}

@media (max-width: 980px) {
  .prealg-consecration-stage {
    height: auto;
    min-height: 760px;
  }

  .solution-board {
    width: 84%;
  }

  .prealg-master--solen { left: 4%; top: 20%; }
  .prealg-master--aldra { right: 4%; top: 20%; }
  .prealg-master--pellan { left: 4%; bottom: 23%; }
  .prealg-master--veth { right: 4%; bottom: 23%; }

  .prealg-consecration-cue {
    max-width: calc(100% - 32px);
  }
}

@media (max-width: 720px) {
  .prealg-consecration-topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .prealg-consecration-topbar p {
    text-align: center;
  }

  .solution-board {
    height: 520px;
    top: 3%;
    width: calc(100% - 28px);
  }

  .solution-board__slots {
    gap: 148px 8px;
  }

  .solution-slot strong {
    font-size: 0.62rem;
  }

  .solution-parchment {
    width: 82%;
  }

  .prealg-master__line {
    min-width: 150px;
  }

  .prealg-master__name,
  .prealg-master__role {
    display: none;
  }
}
