:root {
  --bg: #000;
  --panel: #071012;
  --green: #34ff77;
  --muted: #7fdfac;
  --accent: #00ff88;
  --danger: #ff6b6b;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono",
    monospace;
  background: var(--bg);
  color: var(--green);
  margin: 0;
}
.container {
  max-width: 1000px;
  margin: 28px auto;
  padding: 16px;
}
.terminal {
  background: linear-gradient(180deg, #000 0%, #030303 100%);
  border-radius: 8px;
  padding: 18px;
  border: 1px solid rgba(52, 255, 119, 0.06);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8) inset;
  transition: all 0.3s ease;
}
.term-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
h1 {
  font-size: 1.25rem;
  margin: 0;
  color: var(--accent);
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s ease;
}
.level-title {
  color: var(--muted);
  font-size: 0.95rem;
}
.code-area {
  margin-top: 14px;
}
.code {
  display: block;
  white-space: pre-wrap;
  background: #010101;
  color: var(--green);
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  border: 1px solid rgba(52, 255, 119, 0.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  transition: all 0.3s ease;
}
.fade-in {
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.success-glow {
  box-shadow: 0 0 30px rgba(52, 255, 119, 0.8),
    0 20px 60px rgba(0, 0, 0, 0.8) inset;
}
.fail-glitch {
  animation: glitch 0.3s ease;
}
@keyframes glitch {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  75% {
    transform: translateX(2px);
  }
}
.input-area {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}
input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  background: #020202;
  border: 1px solid rgba(52, 255, 119, 0.08);
  color: var(--green);
  border-radius: 6px;
}
input[type="text"]::placeholder {
  color: rgba(52, 255, 119, 0.28);
}
input[type="text"]:focus {
  outline: none;
  box-shadow: 0 0 8px rgba(52, 255, 119, 0.12),
    0 0 12px rgba(52, 255, 119, 0.06);
  border-color: var(--accent);
  transition: all 0.2s ease;
}
button {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(52, 255, 119, 0.12);
  background: transparent;
  color: var(--green);
  cursor: pointer;
  transition: all 0.2s ease;
}
button:hover {
  background: rgba(52, 255, 119, 0.08);
  transform: translateY(-1px);
}
button.primary {
  background: rgba(52, 255, 119, 0.06);
  border-color: rgba(52, 255, 119, 0.18);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.flash-red {
  background-color: #ff4444 !important;
  color: white !important;
  animation: flash 0.5s ease;
}
@keyframes flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.message {
  margin-left: 8px;
  color: var(--green);
}
.message.error {
  color: var(--danger);
}
.message.success {
  color: #6bff9d;
}
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.nav button {
  margin-right: 6px;
}
.hint-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hint-instruction {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.hint-content {
  color: var(--muted);
  margin-top: 8px;
}
.hint-line {
  display: flex;
  margin: 4px 0;
  align-items: center;
}
.hint-label {
  color: var(--green);
  font-weight: bold;
}
.hint-text {
  cursor: pointer;
  transition: filter 0.2s ease, opacity 0.2s ease;
}
.blurred {
  filter: blur(6px);
  user-select: none;
  opacity: 0.7;
}
.blurred:hover {
  filter: blur(4px);
  opacity: 0.9;
}
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
.sr-only {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .input-area {
    flex-direction: column;
    align-items: stretch;
  }
  button {
    width: 100%;
  }
  .term-header {
    gap: 4px;
  }
  .progress-bar {
    height: 4px;
  }
  h1 {
    font-size: 1.1rem;
  }
}

/* Congratulations page */
.congrats-page {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  z-index: 100;
  color: var(--green);
}
.matrix-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}
.congrats-content {
  text-align: center;
  padding: 20px;
  border: 1px solid rgba(52, 255, 119, 0.12);
  border-radius: 8px;
  background: #050705;
  max-width: 400px;
}
.congrats-content h1 {
  color: var(--accent);
  margin-bottom: 10px;
}
.congrats-content p {
  margin: 10px 0;
}
.stats p {
  margin: 5px 0;
  font-size: 1.1rem;
}
.stats span {
  font-weight: bold;
  color: var(--muted);
}
#play-again {
  margin-top: 15px;
  padding: 10px 20px;
  border-radius: 6px;
  background: rgba(52, 255, 119, 0.06);
  border: 1px solid rgba(52, 255, 119, 0.18);
  color: var(--green);
  cursor: pointer;
}
#play-again:hover {
  background: rgba(52, 255, 119, 0.12);
}

/* Info bar */
.info-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
  border-top: 1px dashed rgba(52, 255, 119, 0.04);
  padding-top: 12px;
}
.info-bar .progress {
  font-weight: 600;
  color: var(--accent);
}
.info-bar .attempts {
  color: var(--muted);
}
.info-bar .usage {
  color: rgba(52, 255, 119, 0.5);
  font-size: 0.92rem;
}

/* Messages */
.message {
  transition: all 180ms ease;
  animation: fadeIn 0.3s ease;
}
.message.success {
  color: #6bff9d;
}
.message.error {
  color: var(--danger);
}
.message.weak {
  color: var(--muted);
}

/* subtle code highlight */
.code {
  max-height: 280px;
}

/* Modal / onboarding */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.modal {
  background: #050705;
  border: 1px solid rgba(52, 255, 119, 0.12);
  padding: 18px;
  border-radius: 10px;
  max-width: 720px;
  color: var(--green);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}
.modal h2 {
  color: var(--accent);
  margin: 0 0 8px;
}
.modal p {
  color: var(--muted);
  line-height: 1.45;
  margin: 6px 0;
}
.modal ul {
  color: var(--muted);
  line-height: 1.45;
  margin: 6px 0;
  padding-left: 20px;
}
.modal li {
  margin: 4px 0;
}
.modal code {
  background: #010101;
  padding: 2px 4px;
  border-radius: 3px;
  color: var(--green);
}
.modal .modal-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  gap: 12px;
}
.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.modal button {
  padding: 8px 10px;
  border-radius: 6px;
}
.modal[hidden] {
  display: none;
}
.modal-overlay[hidden] {
  display: none;
}

/* Cinematic popup */
.cinema-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  pointer-events: none;
}
.cinema-content {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--green);
  text-shadow: 0 0 24px rgba(52, 255, 119, 0.18),
    0 0 48px rgba(52, 255, 119, 0.06);
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.35));
  padding: 28px 48px;
  border-radius: 8px;
  border: 2px solid rgba(52, 255, 119, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  transform: scale(0.92);
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cinema-popup.show .cinema-content {
  pointer-events: auto;
  opacity: 1;
  transform: scale(1);
}
.cinema-content.success {
  color: #b9ffcf;
  text-shadow: 0 0 28px rgba(107, 255, 157, 0.32);
}
.cinema-content.fail {
  color: #ff9aa0;
  text-shadow: 0 0 28px rgba(255, 106, 106, 0.28);
}
.cinema-content.small {
  font-size: 1.25rem;
  padding: 10px 14px;
  border-radius: 6px;
}
