:root {
  color-scheme: light;
  --bg: #7b2f1d;
  --ink: #2f1b13;
  --cream: #fff4d6;
  --cream-2: #ffe6a7;
  --marigold: #f7a928;
  --lotus: #d75c7f;
  --leaf: #3f7b4d;
  --blue: #295f7d;
  --shadow: 0 24px 70px rgba(34, 18, 12, 0.32);
  --display: "League Spartan", "Noto Serif Devanagari", Georgia, serif;
  --ui: "League Spartan", "Noto Serif Devanagari", system-ui, sans-serif;
  font-family: var(--ui);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--cream);
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#camera {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.topbar {
  position: fixed;
  z-index: 3;
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 2px 18px rgba(24, 12, 8, 0.72);
  pointer-events: auto;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 244, 214, 0.72);
  border-radius: 50%;
  background: rgba(255, 244, 214, 0.11);
  font-size: 23px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1;
}

.brand small {
  margin-top: 5px;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.82;
}

.coach {
  width: min(390px, 52vw);
  text-align: right;
  text-shadow: 0 2px 16px rgba(24, 12, 8, 0.8);
}

.coach span {
  display: block;
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream-2);
}

.coach p {
  min-height: 3em;
  margin: 8px 0 13px;
  font-family: var(--display);
  font-size: clamp(19px, 1.7vw, 25px);
  line-height: 1.35;
}

.meter {
  width: 150px;
  height: 4px;
  margin-left: auto;
  overflow: hidden;
  background: rgba(255, 244, 214, 0.32);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--marigold);
  transition: width 160ms linear;
}

.intro {
  position: fixed;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(410px, calc(100vw - 36px));
  padding: 30px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 230, 167, 0.42);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 248, 230, 0.96), rgba(255, 231, 181, 0.92));
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(30, 12, 6, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
}

.intro[hidden] {
  display: none;
}

.eyebrow {
  margin: 0 0 12px;
  color: #8a461e;
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0 0 22px;
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.02;
  letter-spacing: 0;
}

.deity-picker {
  display: grid;
  gap: 8px;
  margin: 0 0 22px;
}

.top-picker {
  min-width: min(270px, 34vw);
  margin: 0 0 0 12px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 230, 167, 0.34);
  border-radius: 14px;
  background: rgba(45, 18, 10, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 30px rgba(24, 12, 8, 0.18);
  backdrop-filter: blur(10px);
  text-shadow: none;
}

.deity-picker span {
  color: #8a461e;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.top-picker span {
  color: rgba(255, 230, 167, 0.9);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.deity-picker select {
  width: 100%;
  min-height: 50px;
  padding: 0 42px 0 16px;
  border: 1px solid rgba(138, 70, 30, 0.34);
  border-radius: 12px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #7b2f1d 50%) right 18px center / 8px 8px no-repeat,
    linear-gradient(135deg, #7b2f1d 50%, transparent 50%) right 12px center / 8px 8px no-repeat,
    rgba(255, 250, 240, 0.88);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  outline: none;
}

.top-picker select {
  min-height: 36px;
  padding: 0 34px 0 11px;
  border-color: rgba(255, 230, 167, 0.28);
  border-radius: 10px;
  background:
    linear-gradient(45deg, transparent 50%, #fff4d6 50%) right 15px center / 7px 7px no-repeat,
    linear-gradient(135deg, #fff4d6 50%, transparent 50%) right 10px center / 7px 7px no-repeat,
    rgba(255, 244, 214, 0.12);
  color: var(--cream);
  font-size: 13px;
  box-shadow: none;
}

.top-picker select option {
  color: var(--ink);
}

.deity-picker select:focus-visible {
  border-color: #9b4a22;
  box-shadow: 0 0 0 3px rgba(247, 169, 40, 0.22);
}

.intro ol {
  margin: 0 0 24px;
  padding: 18px 0 0;
  border-top: 1px solid rgba(67, 40, 24, 0.46);
  list-style-position: inside;
  color: rgba(47, 27, 19, 0.86);
  font-size: 14px;
}

.intro li {
  margin: 10px 0;
  line-height: 1.5;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.intro button {
  width: 100%;
  padding: 16px 18px;
  background: linear-gradient(135deg, #7b2f1d, #a65524);
  box-shadow: 0 14px 28px rgba(67, 40, 24, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.intro button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(67, 40, 24, 0.28);
}

.intro button:disabled {
  cursor: progress;
  opacity: 0.7;
}

#note {
  margin: 14px 0 0;
  color: #76513d;
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.5;
}

#note.error {
  color: #a32f20;
  font-style: normal;
  font-weight: 700;
}

.footer {
  position: fixed;
  z-index: 3;
  right: 18px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  color: rgba(255, 244, 214, 0.82);
  font-family: var(--ui);
  font-size: 11px;
  text-shadow: 0 2px 14px rgba(24, 12, 8, 0.72);
  pointer-events: none;
}

.footer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.footer button {
  flex: none;
  padding: 9px 16px;
  background: rgba(255, 244, 214, 0.92);
  color: var(--ink);
  border: 1px solid rgba(255, 230, 167, 0.42);
}

.bg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  border: 1px solid rgba(255, 230, 167, 0.34);
  border-radius: 999px;
  background: rgba(45, 18, 10, 0.42);
  color: rgba(255, 244, 214, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  cursor: pointer;
  user-select: none;
  text-shadow: none;
}

.bg-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bg-toggle-mark {
  width: 16px;
  height: 16px;
  border: 1.5px solid rgba(255, 230, 167, 0.72);
  border-radius: 5px;
  background: rgba(255, 244, 214, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.bg-toggle input:checked + .bg-toggle-mark {
  background: var(--marigold);
  border-color: rgba(255, 244, 214, 0.92);
  box-shadow: inset 0 0 0 3px rgba(45, 18, 10, 0.22);
}

.bg-toggle input:focus-visible + .bg-toggle-mark {
  outline: 2px solid rgba(255, 230, 167, 0.9);
  outline-offset: 2px;
}

.bg-toggle span:last-child {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.music-player {
  position: fixed;
  z-index: 4;
  right: 18px;
  bottom: calc(54px + env(safe-area-inset-bottom));
  width: min(240px, calc(100vw - 32px));
  filter: drop-shadow(0 16px 35px rgba(24, 12, 8, 0.38));
}

.music-player[hidden] {
  display: none;
}

.music-player iframe {
  display: block;
  border: 0;
  border-radius: 12px;
  background: #000;
}

@media (max-width: 700px) {
  .topbar {
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    flex-direction: column;
    gap: 7px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand strong {
    font-size: 23px;
  }

  .brand {
    width: 100%;
    min-height: 76px;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 10px;
    padding-right: min(47vw, 188px);
  }

  .top-picker {
    position: absolute;
    top: 0;
    right: 0;
    width: min(45vw, 182px);
    min-width: 0;
    margin: 0;
    padding: 6px;
    border-radius: 10px;
    flex-basis: auto;
    background: rgba(45, 18, 10, 0.5);
  }

  .top-picker span {
    display: none;
  }

  .top-picker select {
    min-height: 34px;
    padding-left: 10px;
    padding-right: 30px;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  .coach {
    width: 100%;
    margin-top: -28px;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid rgba(255, 230, 167, 0.22);
    border-radius: 12px;
    background: rgba(45, 18, 10, 0.32);
    backdrop-filter: blur(8px);
    text-shadow: 0 2px 12px rgba(24, 12, 8, 0.7);
  }

  .coach span {
    font-size: 9px;
    letter-spacing: 0.14em;
  }

  .coach p {
    min-height: 0;
    margin: 4px 0 8px;
    font-size: 17px;
    line-height: 1.2;
  }

  .meter {
    width: min(180px, 54vw);
    margin-left: 0;
  }

  .intro {
    top: auto;
    bottom: calc(58px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    padding: 24px;
  }

  .footer {
    align-items: flex-end;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 12px;
    gap: 10px;
    font-size: 11px;
  }

  .footer button {
    padding: 10px 16px;
  }

  .bg-toggle {
    padding: 9px 12px 9px 10px;
  }

  .bg-toggle span:last-child {
    font-size: 10px;
  }

  .music-player {
    right: 14px;
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .brand strong {
    font-size: 20px;
  }

  .brand small {
    font-size: 9px;
    letter-spacing: 0.16em;
  }

  .top-picker {
    width: 43vw;
  }

  .top-picker select {
    font-size: 11px;
  }

  .coach p {
    font-size: 16px;
  }

  .footer span {
    max-width: 58vw;
    line-height: 1.28;
  }
}

@media (max-height: 720px) and (max-width: 700px) {
  .coach {
    padding: 8px 10px;
  }

  .coach p {
    font-size: 15px;
  }

  .footer span {
    display: none;
  }
}
