:root {
  --bg: #06110c;
  --panel: #0d2118;
  --panel-2: #123023;
  --line: rgba(80, 255, 170, 0.16);
  --text: #e6f6ec;
  --muted: #8fb3a0;
  --accent: #35e08f;
  --accent-2: #c6f432;
  --bad: #ff7b6b;
  --radius: 16px;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.5 var(--sans);
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
  z-index: 0;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 30%, transparent 0%, rgba(6, 17, 12, 0.75) 70%, var(--bg) 100%);
}

/* ---------- hud ---------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 10px;
  background: linear-gradient(var(--bg) 60%, transparent);
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mute {
  appearance: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font: 500 10px/1.4 var(--mono);
  letter-spacing: 0.08em;
  color: var(--muted);
  cursor: pointer;
}

.mute[aria-pressed="true"] {
  opacity: 0.6;
}

.hud-label {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--accent);
}

.hud-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  margin-top: 9px;
}

.hud-bars i {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.hud-bars i.is-done {
  background: var(--accent);
}

.hud-bars i.is-now {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(53, 224, 143, 0.6);
}

/* ---------- layout ---------- */

#app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#app.is-in {
  opacity: 1;
  transform: none;
}

.screen {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 68px) 20px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen--center {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-top: calc(env(safe-area-inset-top) + 32px);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.kicker {
  color: var(--accent);
}

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

.center {
  text-align: center;
}

h1 {
  font: 700 30px/1.1 var(--sans);
  letter-spacing: -0.02em;
}

.lede {
  color: var(--muted);
  max-width: 34ch;
}

.quote {
  font-style: italic;
  color: var(--text);
}

.quote--big {
  font-size: 21px;
  line-height: 1.35;
  text-align: center;
  padding: 8px 4px;
  color: var(--accent-2);
}

/* ---------- butoane ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), #1fb872);
  color: #04130c;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 8px 28px rgba(53, 224, 143, 0.28);
}

.btn--lg {
  padding: 18px 28px;
  font-size: 17px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 8px;
}

.card--tight {
  gap: 4px;
  padding: 14px 18px;
}

.problem {
  font-size: 19px;
  line-height: 1.4;
}

.problem b {
  color: var(--accent-2);
  font-weight: 700;
}

.hint {
  color: var(--accent-2);
  font-size: 15px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.status {
  min-height: 1.5em;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}

.status.is-ok {
  color: var(--accent);
  font-weight: 700;
}

.status.is-bad {
  color: var(--bad);
}

.challenge {
  gap: 14px;
}

.challenge-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- intro / boot ---------- */

.intro {
  gap: 22px;
}

.big18 {
  display: flex;
  gap: 4px;
  font: 700 clamp(130px, 44vw, 210px) / 0.9 var(--mono);
  color: var(--accent);
  text-shadow: 0 0 40px rgba(53, 224, 143, 0.55), 0 0 90px rgba(53, 224, 143, 0.25);
  animation: flicker 4s infinite;
}

.big18 span:last-child {
  color: var(--accent-2);
}

@keyframes flicker {
  0%,
  92%,
  100% {
    opacity: 1;
  }
  94% {
    opacity: 0.7;
  }
  96% {
    opacity: 1;
  }
  97% {
    opacity: 0.8;
  }
}

.terminal {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 260px;
}

.terminal .mono {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.terminal .quote {
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.35;
  font-style: normal;
}

.scan {
  display: grid;
  gap: 22px;
  justify-items: center;
  animation: rise 0.5s ease both;
}

.scan[hidden] {
  display: none;
}

.scan-ring {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  box-shadow: 0 0 30px rgba(53, 224, 143, 0.35), inset 0 0 20px rgba(53, 224, 143, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

.scan-ring span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent), transparent 70%);
}

@keyframes pulse {
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 46px rgba(53, 224, 143, 0.55), inset 0 0 26px rgba(53, 224, 143, 0.3);
  }
}

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

/* ---------- matematică ---------- */

.code-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 66px;
  align-items: center;
}

.code-display span {
  min-width: 46px;
  padding: 8px 6px;
  text-align: center;
  font: 700 36px/1 var(--mono);
  color: var(--accent-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.code-display .placeholder {
  color: var(--muted);
  background: none;
  border: none;
  letter-spacing: 0.3em;
}

.code-display.is-ok span {
  color: #04130c;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(53, 224, 143, 0.5);
}

.shake {
  animation: shake 0.4s;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 0;
  font: 500 24px/1 var(--mono);
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.key:active {
  transform: scale(0.94);
  background: var(--panel-2);
}

.key--ok {
  background: var(--accent);
  color: #04130c;
  font-weight: 700;
  border-color: transparent;
}

/* ---------- fizică ---------- */

.sim {
  width: 100%;
  aspect-ratio: 100 / 56;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

.sliders {
  display: grid;
  gap: 12px;
}

.sliders label {
  display: grid;
  gap: 6px;
}

.sliders label span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 15px;
}

.sliders b {
  color: var(--accent-2);
  font-family: var(--mono);
}

input[type="range"] {
  width: 100%;
  height: 32px;
  accent-color: var(--accent);
}

/* ---------- chimie ---------- */

.ptable {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.tile {
  appearance: none;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.tile small {
  font: 400 8px/1 var(--mono);
  color: var(--muted);
}

.tile b {
  font: 700 clamp(14px, 4.6vw, 20px) / 1.1 var(--sans);
}

.tile:active {
  transform: scale(0.92);
}

.tile.is-on {
  background: var(--accent);
  color: #04130c;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(53, 224, 143, 0.5);
}

.tile.is-on small {
  color: #04130c;
}

.tile--empty {
  border: none;
  background: none;
  cursor: default;
}

.lab {
  min-height: 74px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

.atom {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8ff0c0, var(--accent) 60%, #1fb872);
  color: #04130c;
  font: 700 20px/1 var(--sans);
}

.plus {
  color: var(--muted);
  font-size: 22px;
}

.bond {
  width: 0;
  height: 6px;
  border-radius: 3px;
  background: var(--accent-2);
  box-shadow: 0 0 14px var(--accent-2);
  animation: bond 0.8s 0.1s forwards;
}

@keyframes bond {
  to {
    width: 54px;
  }
}

.lab.is-bonded {
  border-style: solid;
  border-color: var(--accent);
}

/* ---------- circuit ---------- */

.circuit {
  width: 100%;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  display: block;
}

.circuit .wire {
  fill: none;
  stroke: var(--muted);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.circuit .wire--loop {
  stroke: #3b6a55;
}

.circuit .wire--loop.is-live {
  stroke: var(--accent-2);
  stroke-dasharray: 10 8;
  animation: flow 0.6s linear infinite;
  filter: drop-shadow(0 0 4px var(--accent-2));
}

@keyframes flow {
  to {
    stroke-dashoffset: -18;
  }
}

.circuit .wire--hint {
  stroke: var(--accent);
  stroke-width: 2;
}

.circuit .wire--plate {
  stroke-width: 4;
}

.circuit .wire--lever {
  stroke: var(--accent-2);
}

.circuit .part-body {
  fill: var(--panel-2);
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.circuit .part-body.is-lit {
  fill: var(--accent-2);
  stroke: var(--accent-2);
}

.circuit .rays {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.circuit .dot {
  fill: var(--accent);
}

.circuit .slot {
  cursor: pointer;
}

.circuit .slot-ring {
  fill: rgba(53, 224, 143, 0.06);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  animation: spin 14s linear infinite;
  transform-origin: center;
}

@keyframes spin {
  to {
    stroke-dashoffset: -100;
  }
}

.circuit .bat-plus,
.circuit .bat-minus {
  text-anchor: middle;
  font: 700 13px var(--mono);
  fill: var(--accent-2);
}

.circuit .bat-minus {
  fill: var(--muted);
}

.circuit.is-burning .part-body {
  fill: var(--bad);
  stroke: var(--bad);
  animation: shake 0.3s 3;
}

.tray {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.part {
  appearance: none;
  display: grid;
  gap: 4px;
  justify-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px;
  font-size: 14px;
  cursor: pointer;
}

.part svg {
  width: 72px;
  height: 40px;
  overflow: visible;
}

.part .wire {
  fill: none;
  stroke: var(--muted);
  stroke-width: 3;
  stroke-linecap: round;
}

.part .part-body {
  fill: var(--panel-2);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.part .rays {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
}

.part .dot {
  fill: var(--accent);
}

.part.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.part:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- dezvăluire ---------- */

.reveal {
  gap: 16px;
  padding-left: 0;
  padding-right: 0;
}

.reveal > .kicker,
.reveal > h1,
.reveal > .quote,
.reveal > .btn {
  margin-left: 20px;
  margin-right: 20px;
}

.reveal-title {
  font-size: 26px;
}

.strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 20px 12px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.strip::-webkit-scrollbar {
  display: none;
}

.strip.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

.strip-item img {
  -webkit-user-drag: none;
  user-select: none;
}

.strip-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.strip-nav .btn {
  min-width: 64px;
  padding: 10px 20px;
  font-size: 20px;
}

@media (hover: none) {
  .strip-nav {
    display: none;
  }
}

.strip-item {
  appearance: none;
  flex: 0 0 72%;
  max-width: 340px;
  height: 52vh;
  max-height: 460px;
  padding: 0;
  position: relative;
  scroll-snap-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  cursor: pointer;
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  animation: appear 0.6s var(--d) ease forwards;
}

.strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.strip-item span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(6, 17, 12, 0.72);
  color: var(--accent);
}

@keyframes appear {
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- arhivă ---------- */

.archive {
  gap: 14px;
}

.grid {
  columns: 3;
  column-gap: 8px;
}

.grid-tile,
.grid-note {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0 0 8px;
  break-inside: avoid;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.grid-tile {
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.grid-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-note {
  padding: 12px 10px;
  text-align: left;
  font-size: 13px;
  line-height: 1.35;
  color: var(--accent-2);
  background: var(--panel-2);
  border: 1px solid var(--accent);
}

/* ---------- viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 9, 6, 0.97);
}

.viewer[hidden] {
  display: none;
}

.viewer-track {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.viewer-track::-webkit-scrollbar {
  display: none;
}

.viewer-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + 56px) 12px calc(env(safe-area-inset-bottom) + 20px);
}

.viewer-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.viewer-note {
  max-width: 24ch;
  font-size: 26px;
  line-height: 1.3;
  text-align: center;
  color: var(--accent-2);
}

.viewer-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 14px;
  z-index: 2;
  appearance: none;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(13, 33, 24, 0.9);
  cursor: pointer;
}

.viewer-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  appearance: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(13, 33, 24, 0.9);
  font-size: 22px;
  cursor: pointer;
}

.viewer-arrow--prev {
  left: 12px;
}

.viewer-arrow--next {
  right: 12px;
}

@media (hover: none) {
  .viewer-arrow {
    display: none;
  }
}

.viewer-count {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 20px);
  left: 18px;
  z-index: 2;
  font: 500 12px var(--mono);
  color: var(--accent);
  letter-spacing: 0.1em;
}

/* ---------- ține apăsat ---------- */

.hold {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-top: 6px;
}

.hold-btn {
  --p: 0;
  appearance: none;
  position: relative;
  width: 100%;
  padding: 22px 16px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform 0.15s;
  box-shadow: 0 0 24px rgba(53, 224, 143, 0.2);
}

.hold-btn.is-holding {
  transform: scale(0.98);
}

.hold-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  transform: scaleX(var(--p));
}

.hold-label {
  position: relative;
  mix-blend-mode: normal;
  color: var(--text);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

/* ---------- cadou ---------- */

.gift {
  gap: 22px;
}

.gift-title {
  font-size: 38px;
  color: var(--accent-2);
  text-shadow: 0 0 30px rgba(198, 244, 50, 0.35);
}

.envelope {
  position: relative;
  width: 240px;
  height: 160px;
  perspective: 700px;
  margin: 96px 0 8px;
}

.envelope > div {
  position: absolute;
  inset: 0;
}

.envelope-back {
  background: #0f6b45;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(53, 224, 143, 0.25);
}

.cash {
  inset: 10px 18px 14px !important;
  background: linear-gradient(135deg, #cfe9a5, #9fd36e);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #28521b;
  font: 700 26px var(--mono);
  transition: transform 1s 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
  box-shadow: inset 0 0 0 3px rgba(40, 82, 27, 0.25);
}

.envelope.is-open .cash {
  transform: translateY(-70px);
}

.envelope-front {
  background: linear-gradient(135deg, transparent 49.5%, #14884f 50%) left / 50% 100% no-repeat,
    linear-gradient(225deg, transparent 49.5%, #14884f 50%) right / 50% 100% no-repeat,
    linear-gradient(0deg, #1aa062 0%, #1aa062 100%);
  border-radius: 8px;
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
  bottom: 40% !important;
  background: #14884f;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.7s ease, z-index 0s 0.35s;
  border-radius: 8px 8px 0 0;
  z-index: 3;
}

.envelope.is-open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.gift-text {
  display: grid;
  gap: 12px;
  max-width: 36ch;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s, transform 0.8s;
}

.gift-text.is-shown {
  opacity: 1;
  transform: none;
}

.gift-envelope {
  color: var(--accent);
  font-weight: 700;
  font-size: 19px;
}

.gift-from {
  color: var(--muted);
  font-style: italic;
}

@media (min-width: 700px) {
  .grid {
    columns: 4;
  }
  .strip-item {
    flex-basis: 300px;
  }
}

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