/* Fairy-tale theme shared by every page: twilight sky, gold trim, parchment pages. */
:root {
  --night-1: #120c35;
  --night-2: #2a1d6a;
  --dusk: #6b3fa0;
  --rose: #ec8fba;
  --peach: #ffcaa6;
  --gold: #f4c55b;
  --gold-hi: #ffe9a8;
  --gold-deep: #c18421;
  --parchment: #fffaf0;
  --parchment-2: #f7ead0;
  --ink: #3a1f5c;
  --ink-soft: #6d5690;
  --berry: #d0508c;
  --teal: #37b9c3;
  --radius: 22px;
  --display: 'Cinzel Decorative', 'Georgia', serif;
  --head: 'Fredoka', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --gold-edge: linear-gradient(135deg, var(--gold-hi), var(--gold-deep) 35%, var(--gold-hi) 55%, var(--gold-deep) 80%, var(--gold-hi));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 17px/1.5 var(--body);
  background: var(--night-1);
}
h1, h2, h3 { font-family: var(--head); font-weight: 600; margin: 0; }
a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; }

/* ---------- Twilight sky (fixed behind content) ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: linear-gradient(180deg, var(--night-1) 0%, var(--night-2) 38%, var(--dusk) 70%, var(--rose) 90%, var(--peach) 100%);
}
.sky::before, .sky::after { /* two layers of stars that twinkle out of step */
  content: ''; position: absolute; inset: -50% 0 30% 0;
  background-image:
    radial-gradient(1.6px 1.6px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 140px 90px, #fff8d0 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 160px, #fff 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 200px 210px, #ffe9a8 50%, transparent 51%),
    radial-gradient(1px 1px at 250px 40px, #fff 50%, transparent 51%);
  background-size: 280px 240px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
.sky::after { background-size: 410px 330px; background-position: 120px 60px; animation-delay: -2s; opacity: .7; }
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }
.sky .moon {
  position: absolute; top: 7vh; right: 9vw; width: 86px; height: 86px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe6, #ffe9a8 60%, #f4c55b);
  box-shadow: 0 0 40px 12px rgba(255, 233, 168, .35), 0 0 120px 40px rgba(255, 233, 168, .15);
}
.sky .shooting {
  position: absolute; top: 12vh; left: -10vw; width: 140px; height: 2px;
  background: linear-gradient(90deg, transparent, #fff);
  border-radius: 2px; transform: rotate(-18deg);
  animation: shoot 9s ease-in 3s infinite;
  opacity: 0;
}
@keyframes shoot {
  0% { translate: 0 0; opacity: 0; }
  3% { opacity: 1; }
  12% { translate: 70vw 22vh; opacity: 0; }
  100% { translate: 70vw 22vh; opacity: 0; }
}
.sky .castle {
  position: absolute; bottom: 9vh; left: 50%; translate: -50% 0; width: min(560px, 90vw);
  opacity: .9; filter: drop-shadow(0 0 30px rgba(244, 197, 91, .25));
}
.sky .hills { position: absolute; bottom: 0; left: 0; width: 100%; height: 22vh; min-height: 110px; }

/* ---------- Parchment card with gold edge ---------- */
.card {
  position: relative;
  background: linear-gradient(var(--parchment), var(--parchment-2)) padding-box, var(--gold-edge) border-box;
  border: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 6px var(--parchment), inset 0 0 0 7.5px rgba(193, 132, 33, .35),
              0 24px 60px -18px rgba(8, 4, 30, .7), 0 0 0 1px rgba(255, 233, 168, .15);
}
.ornate::before, .ornate::after {
  content: ''; position: absolute; top: 8px; width: 46px; height: 46px; pointer-events: none;
  background: url(/img/corner.svg) center/contain no-repeat;
}
.ornate::before { left: 8px; }
.ornate::after { right: 8px; transform: scaleX(-1); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 44px; padding: .55em 1.25em;
  font: 600 16px var(--head); letter-spacing: .2px; color: var(--ink); text-decoration: none;
  background: linear-gradient(180deg, #ffe48f, #f2b544);
  border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .7), inset 0 -3px 0 rgba(160, 100, 10, .25), 0 8px 18px -8px rgba(193, 132, 33, .8);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(160,100,10,.25), 0 12px 24px -8px rgba(193,132,33,.9); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.rose { color: #fff; background: linear-gradient(180deg, #f59ac4, var(--berry)); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.5), inset 0 -3px 0 rgba(120,20,70,.25), 0 8px 18px -8px rgba(208,80,140,.9); }
.btn.teal { color: #fff; background: linear-gradient(180deg, #6fd8de, #2a9fab); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.5), inset 0 -3px 0 rgba(10,80,90,.25), 0 8px 18px -8px rgba(42,159,171,.9); }
.btn.ghost { background: rgba(58, 31, 92, .06); box-shadow: inset 0 0 0 1.5px rgba(58, 31, 92, .22); }
.btn.ghost:hover { background: rgba(58, 31, 92, .1); }
.btn.night { color: var(--gold-hi); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px rgba(255, 233, 168, .45); }
.btn.danger { color: #b0284f; background: rgba(208, 80, 140, .08); box-shadow: inset 0 0 0 1.5px rgba(208, 80, 140, .35); }
.btn.small { min-height: 38px; font-size: 14px; padding: .4em .95em; }
.btn[disabled] { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 12px; }

/* ---------- Form fields ---------- */
label { font: 600 15px var(--head); display: block; margin-bottom: .35em; color: var(--ink); }
label small { font-weight: 500; color: var(--ink-soft); }
input[type=text], input[type=password] {
  width: 100%; min-height: 48px;
  font: 17px var(--body); color: var(--ink);
  padding: .6em .9em;
  background: #fff;
  border: 1.5px solid #e6d2a6; border-radius: 14px;
  box-shadow: inset 0 2px 4px rgba(58, 31, 92, .06);
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=password]:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(244, 197, 91, .3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translateX(-50%) translateY(160%);
  max-width: calc(100% - 32px);
  font: 600 16px var(--head); color: var(--ink);
  background: linear-gradient(180deg, #fffaf0, #f7ead0);
  border: 1.5px solid var(--gold); border-radius: 999px;
  padding: .65em 1.4em; box-shadow: 0 12px 30px -10px rgba(8, 4, 30, .6);
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { color: #fff; background: linear-gradient(180deg, #f59ac4, var(--berry)); border-color: #fff3; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
