:root {
  color-scheme: dark;
  --ink: #11130f;
  --panel: rgba(255, 253, 248, 0.08);
  --panel-strong: rgba(255, 253, 248, 0.14);
  --paper: #fffdf8;
  --muted: rgba(255, 253, 248, 0.68);
  --line: rgba(255, 253, 248, 0.16);
  --citron: #dfff56;
  --aqua: #00b8a9;
  --blue: #3d7df2;
  --coral: #ff6b5f;
  --magenta: #e449a2;
  --prism: linear-gradient(90deg, #ff5a5f, #ffb000, #d7f64a, #00b8a9, #3d7df2, #8067f2, #e449a2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 14%, rgba(223, 255, 86, 0.22), transparent 28rem),
    radial-gradient(circle at 86% 8%, rgba(61, 125, 242, 0.26), transparent 30rem),
    radial-gradient(circle at 50% 100%, rgba(228, 73, 162, 0.20), transparent 26rem),
    var(--ink);
  color: var(--paper);
  font-family: "Avenir Next", Manrope, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.55;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 253, 248, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 253, 248, 0.04) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea {
  font: inherit;
}

button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.08);
  color: var(--paper);
  font-weight: 850;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(255, 253, 248, 0.44);
  background: rgba(255, 253, 248, 0.14);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

button.is-busy {
  cursor: wait;
  opacity: 1;
}

button.is-busy::before {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  content: "";
  opacity: 0.82;
  animation: busy-spin 760ms linear infinite;
}

button.is-busy.primary::before {
  opacity: 0.72;
}

button.primary {
  border: 0;
  background: var(--prism);
  color: #11130f;
  box-shadow: 0 18px 40px rgba(61, 125, 242, 0.22);
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10;
  transform: translateY(-150%);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 900;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(17, 19, 15, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}

.brand,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  padding-left: 6px;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 7px;
  background: var(--prism);
  color: #11130f;
  font-size: 0.72rem;
  font-weight: 800;
}

.brand-word {
  color: var(--paper);
  font-weight: 650;
}

.nav {
  gap: 4px;
}

.nav a {
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 8px 12px;
  color: rgba(255, 253, 248, 0.72);
  font-size: 0.88rem;
  font-weight: 600;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: rgba(255, 253, 248, 0.11);
  color: var(--paper);
}

.report-bug-button {
  min-height: 40px;
  padding: 8px 12px;
  color: rgba(255, 253, 248, 0.76);
  font-size: 0.84rem;
  white-space: nowrap;
}

.report-bug-button:hover,
.report-bug-button:focus-visible {
  color: var(--paper);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  align-items: center;
  gap: 44px;
  padding: 74px 0 42px;
}

.eyebrow,
.kicker {
  margin: 0 0 10px;
  color: var(--citron);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 20px;
  font-size: clamp(3.4rem, 9vw, 8.2rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 660px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.hero-copy .inspiration-note,
.hero-copy .alpha-note {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  width: fit-content;
  margin: 4px 0 0;
  border: 1px solid rgba(255, 253, 248, 0.13);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255, 253, 248, 0.055);
  color: rgba(255, 253, 248, 0.58);
  font-size: 0.82rem;
  font-weight: 850;
}

.hero-copy .alpha-note {
  border-color: rgba(255, 176, 0, 0.28);
  background: rgba(255, 176, 0, 0.09);
  color: rgba(255, 253, 248, 0.72);
}

.inspiration-note a {
  color: var(--citron);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.inspiration-note a:hover,
.inspiration-note a:focus-visible {
  color: var(--paper);
}

.logic-map {
  width: min(100%, 430px);
  justify-self: end;
  filter: drop-shadow(0 28px 50px rgba(0, 0, 0, 0.34));
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 20px;
  align-items: start;
}

.puzzle-card,
.workbench-card,
.feedback-card,
.hint-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.09);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.puzzle-card {
  padding: clamp(22px, 4vw, 38px);
}

.card-header,
.workbench-heading,
.feedback-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-header h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4.8vw, 4.2rem);
  line-height: 0.95;
}

.status-pill,
.feedback-top span,
.workbench-heading small {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.is-on {
  border-color: rgba(0, 184, 169, 0.45);
  color: #7effef;
}

.status-pill.is-fallback {
  border-color: rgba(255, 176, 0, 0.45);
  color: #ffe08a;
}

.hook {
  margin: 26px 0 18px;
  color: var(--paper);
  font-size: 1.2rem;
  font-weight: 850;
}

.prompt-box {
  border-left: 5px solid var(--citron);
  padding: 18px 20px;
  border-radius: 0 10px 10px 0;
  background: rgba(17, 19, 15, 0.42);
  color: rgba(255, 253, 248, 0.88);
  font-size: 1.02rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 24px;
}

.detail-grid section,
.level-face,
.level-sizer {
  border: 1px solid rgba(255, 253, 248, 0.12);
  border-radius: 10px;
  padding: 16px;
  background: rgba(255, 253, 248, 0.055);
}

.detail-grid h3,
.levels h3,
.feedback-card h3 {
  margin-bottom: 8px;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.clean-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.clean-list li + li {
  margin-top: 8px;
}

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
  align-items: stretch;
}

.level {
  display: grid;
  perspective: 900px;
}

.level-flip {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 168px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.level-flip:hover,
.level-flip:focus-visible {
  border-color: transparent;
  background: transparent;
  transform: none;
}

.level-flip:focus-visible {
  outline: 3px solid rgba(223, 255, 86, 0.54);
  outline-offset: 4px;
}

.level-inner {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 168px;
  transform-style: preserve-3d;
  transition: transform 560ms cubic-bezier(0.22, 1, 0.36, 1);
}

.level.is-revealed .level-inner {
  transform: rotateY(180deg);
}

.level-face {
  position: absolute;
  inset: 0;
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-wrap: anywhere;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.16);
}

.level-sizer {
  grid-area: 1 / 1;
  display: flex;
  min-height: 168px;
  flex-direction: column;
  justify-content: flex-start;
  overflow-wrap: anywhere;
  pointer-events: none;
  visibility: hidden;
}

.level-front {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.14), rgba(255, 253, 248, 0.045)),
    rgba(255, 253, 248, 0.055);
}

.level-front::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  content: "";
  background: var(--prism);
}

.level-front strong {
  margin-bottom: 0;
  font-size: 1.04rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.level-back {
  align-items: flex-start;
  justify-content: flex-start;
  border-color: rgba(223, 255, 86, 0.24);
  background:
    linear-gradient(145deg, rgba(223, 255, 86, 0.10), rgba(61, 125, 242, 0.11)),
    rgba(17, 19, 15, 0.74);
  transform: rotateY(180deg);
}

.level-back strong {
  display: block;
  margin-bottom: 5px;
  color: var(--citron);
}

.level-sizer strong {
  display: block;
  margin-bottom: 5px;
}

.level-back span,
.level-sizer span,
.detail-grid p {
  margin-bottom: 0;
  color: var(--muted);
}

.level-back span {
  display: block;
}

.workbench {
  display: grid;
  gap: 14px;
}

.workbench-card,
.feedback-card,
.hint-card {
  padding: 18px;
}

.workbench-heading {
  margin-bottom: 12px;
}

.workbench-heading span {
  font-size: 0.95rem;
  font-weight: 950;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  outline: 0;
  background: rgba(17, 19, 15, 0.54);
  color: var(--paper);
}

textarea:focus {
  border-color: rgba(223, 255, 86, 0.58);
  box-shadow: 0 0 0 4px rgba(223, 255, 86, 0.09);
}

.button-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.7fr;
  gap: 8px;
  margin-top: 10px;
}

.share-status {
  min-height: 1.35em;
  margin: 8px 2px 0;
  color: var(--citron);
  font-size: 0.82rem;
  font-weight: 850;
}

.share-status:empty {
  visibility: hidden;
}

.feedback-card {
  border-color: rgba(223, 255, 86, 0.28);
}

.feedback-card[hidden] {
  display: none;
}

.verdict.solved {
  color: #8cffb2;
}

.verdict.partial {
  color: #ffe08a;
}

.verdict.needs-work {
  color: #ffb0aa;
}

.hint-stack {
  display: grid;
  gap: 10px;
}

.hint-card {
  background: rgba(61, 125, 242, 0.12);
}

.hint-card strong {
  display: block;
  margin-bottom: 6px;
  color: #a9c5ff;
}

.about-puzzle {
  display: grid;
  grid-template-columns: minmax(0, 0.42fr) minmax(0, 0.58fr);
  gap: 28px;
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 34px;
}

.about-puzzle h2 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.98;
}

.about-puzzle p {
  color: var(--muted);
}

.about-grid {
  display: grid;
  gap: 12px;
}

.about-grid article {
  border: 1px solid rgba(255, 253, 248, 0.12);
  border-radius: 10px;
  padding: 18px;
  background: rgba(255, 253, 248, 0.055);
}

.about-grid h3 {
  margin-bottom: 8px;
  color: var(--citron);
  font-size: 0.92rem;
  text-transform: uppercase;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: rgba(255, 253, 248, 0.58);
  font-size: 0.84rem;
  font-weight: 800;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-links a {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.13);
  border-radius: 8px;
  padding: 7px 11px;
  color: rgba(255, 253, 248, 0.72);
  font-size: 0.76rem;
  font-weight: 900;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  border-color: rgba(255, 253, 248, 0.34);
  background: rgba(255, 253, 248, 0.08);
  color: var(--paper);
}

.bug-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.bug-modal[hidden] {
  display: none;
}

.bug-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 2, 0.72);
  backdrop-filter: blur(10px);
}

.bug-panel {
  position: relative;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 19, 15, 0.96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.bug-panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 20px;
}

.bug-panel h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
}

.bug-panel-top button {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.bug-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.bug-form p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.bug-form textarea {
  min-height: 150px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
  background: rgba(255, 253, 248, 0.08);
  color: var(--paper);
  outline: none;
}

.bug-form textarea:focus {
  border-color: rgba(223, 255, 86, 0.6);
}

.bug-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.bug-actions span {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

@media (max-width: 860px) {
  .topbar,
  .hero,
  .game-grid,
  .detail-grid,
  .levels,
  .about-puzzle {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .nav {
    justify-content: stretch;
  }

  .nav a {
    flex: 1;
    text-align: center;
  }

  .report-bug-button {
    width: 100%;
  }

  .logic-map {
    justify-self: center;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 22px, 1180px);
  }

  .topbar {
    flex-direction: column;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .card-header,
  .feedback-top,
  .bug-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .level-inner {
    transition: none;
  }

  button.is-busy::before {
    animation-duration: 1400ms;
  }
}
