:root {
  --bg: #05070d;
  --bg-2: #080d18;
  --panel: rgba(19, 26, 43, 0.62);
  --panel-solid: #101725;
  --line: rgba(148, 178, 226, 0.14);
  --line-strong: rgba(200, 170, 110, 0.38);
  --text: #e8eefb;
  --muted: #8f9db8;
  --gold: #c8aa6e;
  --gold-bright: #f0e6d2;
  --teal: #0ac8b9;
  --teal-dim: #0a6d68;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.95);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(10, 200, 185, 0.13), transparent 60%),
    radial-gradient(900px 560px at 92% 8%, rgba(200, 170, 110, 0.13), transparent 62%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(148, 178, 226, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 178, 226, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(900px 620px at 50% 0%, #000 15%, transparent 78%);
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }

.kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.muted { color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

button:disabled { cursor: not-allowed; opacity: 0.45; }

.btn-primary {
  padding: 0.85rem 1.4rem;
  font-weight: 620;
  letter-spacing: 0.04em;
  color: #0a0d14;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  box-shadow: 0 14px 34px -18px rgba(200, 170, 110, 0.9);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }

.btn-ghost {
  padding: 0.6rem 1rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 0.9rem 1rem;
  font: inherit;
  color: var(--text);
  background: rgba(6, 10, 18, 0.75);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10, 200, 185, 0.16);
}

.notice {
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  font-size: 0.92rem;
}

.notice.error { color: #ffd5d5; background: rgba(255, 107, 107, 0.11); border: 1px solid rgba(255, 107, 107, 0.32); }
.notice.good { color: #c9fff6; background: rgba(10, 200, 185, 0.11); border: 1px solid rgba(10, 200, 185, 0.32); }

/* ------------------------------------------------------------------ login */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.login-card {
  position: relative;
  width: min(430px, 100%);
  display: grid;
  gap: 1rem;
  padding: 2.4rem 2.1rem;
  background: var(--panel);
  backdrop-filter: blur(22px);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.crest {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin-bottom: 0.3rem;
  font-size: 1.5rem;
  border-radius: 16px;
  color: var(--gold-bright);
  background: linear-gradient(140deg, rgba(200, 170, 110, 0.28), rgba(10, 200, 185, 0.16));
  border: 1px solid var(--line-strong);
}

.login-card h1 { font-size: 1.6rem; }
.login-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.login-card label { display: grid; gap: 0.45rem; font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

/* ------------------------------------------------------------------- app */

.shell {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 2.6rem 1.25rem 5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.2rem;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }

.brand .crest { width: 44px; height: 44px; margin: 0; font-size: 1.1rem; border-radius: 13px; }

.brand strong { display: block; font-size: 1.02rem; letter-spacing: -0.01em; }

.progress-rail {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.6rem;
}

.pip {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 178, 226, 0.12);
  transition: background 0.45s ease, box-shadow 0.45s ease;
}

.pip.done { background: linear-gradient(90deg, var(--teal-dim), var(--teal)); box-shadow: 0 0 16px -2px rgba(10, 200, 185, 0.65); }
.pip.active { background: linear-gradient(90deg, var(--gold), var(--gold-bright)); box-shadow: 0 0 16px -2px rgba(200, 170, 110, 0.7); }

.card {
  padding: 2rem;
  background: var(--panel);
  backdrop-filter: blur(22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card + .card { margin-top: 1.1rem; }

.card h2 { font-size: 1.45rem; margin: 0.45rem 0 0.9rem; }

.puzzle-text {
  margin: 0 0 1.4rem;
  white-space: pre-wrap;
  color: #cfd8ea;
}

.answer-row { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.answer-row input { flex: 1 1 240px; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.3rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--muted);
}

.hints { display: grid; gap: 0.55rem; margin-top: 1.1rem; }

.hint {
  padding: 0.7rem 0.95rem;
  font-size: 0.9rem;
  color: #d8c9a4;
  background: rgba(200, 170, 110, 0.08);
  border-left: 2px solid var(--gold);
  border-radius: 0 10px 10px 0;
  animation: rise 0.35s ease both;
}

/* ---------------------------------------------------------------- lights */

.lights-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
  width: min(430px, 100%);
  margin: 0 auto 1.2rem;
}

.crystal {
  aspect-ratio: 1;
  border-radius: 10px;
  background: rgba(10, 16, 28, 0.85);
  border: 1px solid var(--line);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.crystal:hover { transform: scale(1.04); }
.crystal:active { transform: scale(0.96); }

.crystal.on {
  background: linear-gradient(140deg, rgba(240, 230, 210, 0.95), var(--gold));
  border-color: var(--gold-bright);
  box-shadow: 0 0 18px -4px rgba(200, 170, 110, 0.85), inset 0 0 12px rgba(255, 255, 255, 0.35);
}

/* ------------------------------------------------------------------ echo */

.rune-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  width: min(320px, 100%);
  margin: 0 auto 1.2rem;
}

.rune {
  aspect-ratio: 1.35;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--rune-dim);
  transition: filter 0.14s ease, box-shadow 0.14s ease, transform 0.12s ease;
}

.rune[data-rune="0"] { --rune-dim: #123a4d; --rune-lit: #35e0ff; }
.rune[data-rune="1"] { --rune-dim: #4a3717; --rune-lit: #ffc65c; }
.rune[data-rune="2"] { --rune-dim: #123f2d; --rune-lit: #46f0a6; }
.rune[data-rune="3"] { --rune-dim: #42183a; --rune-lit: #ff6ad5; }

.rune.lit {
  background: var(--rune-lit);
  box-shadow: 0 0 34px -4px var(--rune-lit);
  transform: scale(1.03);
}

.rune:disabled { cursor: default; }

.echo-status { text-align: center; font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }

.echo-dots { display: flex; justify-content: center; gap: 0.4rem; margin-bottom: 1.1rem; }
.echo-dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(148, 178, 226, 0.2); }
.echo-dots span.filled { background: var(--teal); box-shadow: 0 0 12px -1px var(--teal); }

.center-row { display: flex; justify-content: center; gap: 0.7rem; flex-wrap: wrap; }

/* ----------------------------------------------------------------- vault */

.vault { text-align: center; }
.vault h2 { font-size: 1.9rem; }

.password-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.6rem 0 1rem;
  padding: 1.4rem 1.6rem;
  background: rgba(6, 10, 18, 0.8);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  font-family: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
  font-size: clamp(1.05rem, 3.6vw, 1.5rem);
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  word-break: break-all;
}

.solved-list { display: grid; gap: 0.5rem; margin-top: 1.4rem; text-align: left; }

.solved-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(10, 200, 185, 0.06);
  border: 1px solid rgba(10, 200, 185, 0.18);
  border-radius: 10px;
}

.solved-item span:first-child { color: var(--teal); }

/* ------------------------------------------------------------ task bits */

.hint-inline {
  color: #d8c9a4;
  background: rgba(200, 170, 110, 0.1);
  border-left: 2px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.86rem;
  max-width: 30rem;
}

.center-column { display: grid; justify-items: center; gap: 1rem; }

.mantra {
  margin: 0 0 1.3rem;
  padding: 1.1rem 1.3rem;
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--gold-bright);
  background: rgba(6, 10, 18, 0.72);
  border-left: 3px solid var(--gold);
  border-radius: 0 14px 14px 0;
  user-select: none;
}

.scramble-row { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.scramble-row input { flex: 1 1 180px; }

.scramble-word {
  flex: 0 0 auto;
  min-width: 9.5rem;
  padding: 0.55rem 0.85rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.02rem;
  letter-spacing: 0.22em;
  color: var(--teal);
  background: rgba(10, 200, 185, 0.07);
  border: 1px solid rgba(10, 200, 185, 0.22);
  border-radius: 10px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.2rem, 1fr));
  gap: 0.35rem;
  margin-bottom: 1.3rem;
  padding: 1rem;
  font-size: 1.35rem;
  line-height: 1.5;
  text-align: center;
  background: rgba(6, 10, 18, 0.6);
  border: 1px solid var(--line);
  border-radius: 14px;
  user-select: none;
}

.code-plate {
  margin: 0 auto 1.2rem;
  padding: 1.5rem 1rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(1.5rem, 7vw, 2.6rem);
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--gold-bright);
  background: rgba(6, 10, 18, 0.8);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
}

.code-plate.faded { color: var(--muted); letter-spacing: 0.2em; border-color: var(--line); }

.timer-bar { height: 4px; border-radius: 999px; background: rgba(148, 178, 226, 0.14); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), var(--teal)); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-bottom: 1.1rem; }

.chip {
  padding: 0.75rem 1.15rem;
  font-weight: 550;
  color: var(--text);
  background: rgba(19, 26, 43, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 3.4rem;
}

.chip:hover:not(.used) { border-color: var(--teal); transform: translateY(-1px); }
.chip.used { color: var(--teal-dim); background: rgba(10, 200, 185, 0.08); border-color: rgba(10, 200, 185, 0.3); opacity: 0.5; cursor: default; }

.hold-ring {
  --fill: 0deg;
  position: relative;
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  background: conic-gradient(var(--gold) var(--fill), rgba(148, 178, 226, 0.13) 0);
  transition: box-shadow 0.3s ease;
}

.hold-ring::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: linear-gradient(160deg, #131b2b, #0a0f1a);
  border: 1px solid var(--line);
}

.hold-ring.holding { box-shadow: 0 0 60px -12px rgba(200, 170, 110, 0.8); }
.hold-ring.filled { box-shadow: 0 0 70px -10px rgba(10, 200, 185, 0.9); }

.hold-label {
  position: relative;
  z-index: 1;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.9rem;
  color: var(--gold-bright);
}

.breathe-orb {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  transform: scale(0.55);
  background: radial-gradient(circle at 35% 30%, rgba(10, 200, 185, 0.95), rgba(10, 109, 104, 0.55) 55%, rgba(10, 200, 185, 0.05) 75%);
  box-shadow: 0 0 70px -14px rgba(10, 200, 185, 0.85);
}

.breathe-label { margin: 0; font-size: 1.15rem; letter-spacing: 0.12em; color: var(--gold-bright); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.shake { animation: shake 0.4s ease; }

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

@media (max-width: 560px) {
  .card { padding: 1.5rem 1.2rem; }
  .login-card { padding: 2rem 1.4rem; }
}
