:root {
  --crust: #181926;
  --mantle: #1e2030;
  --base: #24273a;
  --surface0: #363a4f;
  --surface1: #494d64;
  --surface2: #5b6078;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --overlay2: #9399b2;
  --subtext0: #a5adcb;
  --subtext1: #b8c0e0;
  --text: #cad3f5;
  --lavender: #b7bdf8;
  --blue: #8aadf4;
  --sapphire: #7dc4e4;
  --sky: #91d7e3;
  --teal: #8bd5ca;
  --green: #a6da95;
  --yellow: #eed49f;
  --peach: #f5a97f;
  --maroon: #ee99a0;
  --red: #ed8796;
  --mauve: #c6a0f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(135deg, var(--crust), var(--base));
  color: var(--subtext1);
  min-height: 100vh;
  padding: 1rem;
}

h1, h2, h3, h4, p {
  margin: 0;
}

button {
  cursor: pointer;
  font-family: inherit;
}

a {
  color: var(--sky);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--sapphire);
}

kbd {
  display: inline-block;
  padding: 0.2em 0.5em;
  font-size: 0.8em;
  font-family: monospace;
  background: var(--surface0);
  border-radius: 4px;
  border: 1px solid var(--surface1);
  color: var(--overlay1);
}

.w-full {
  width: 100%;
}
.h-full {
  height: 100%;
}
.min-h-screen {
  min-height: 100vh;
}
.min-h-\[200px\] {
  min-height: 200px;
}

.max-w-5xl {
  max-width: 64rem;
}
.max-w-md {
  max-width: 28rem;
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1 1 0%;
}
.min-w-0 {
  min-width: 0;
}
.items-center {
  align-items: center;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}

.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.fixed {
  position: fixed;
}
.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.top-0 {
  top: 0;
}
.left-0 {
  left: 0;
}
.z-10 {
  z-index: 10;
}
.z-50 {
  z-index: 50;
}
.hidden {
  display: none !important;
}
.opacity-0 {
  opacity: 0;
}
.pointer-events-none {
  pointer-events: none;
}
.cursor-default {
  cursor: default;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}
.text-center {
  text-align: center;
}

.font-mono {
  font-family: monospace;
}
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}
.font-extrabold {
  font-weight: 800;
}
.uppercase {
  text-transform: uppercase;
}
.leading-relaxed {
  line-height: 1.625;
}
.whitespace-pre {
  white-space: pre;
}

.text-xs {
  font-size: 0.75rem;
}
.text-sm {
  font-size: 0.875rem;
}
.text-lg {
  font-size: 1.125rem;
}
.text-xl {
  font-size: 1.25rem;
}
.text-3xl {
  font-size: 1.875rem;
}
.text-5xl {
  font-size: 3rem;
}

@media (min-width: 768px) {
  .md\:flex-row {
    flex-direction: row;
  }
  .md\:text-sm {
    font-size: 0.875rem;
  }
  .md\:text-3xl {
    font-size: 1.875rem;
  }
  .md\:text-7xl {
    font-size: 4.5rem;
  }
}

.mt-2 {
  margin-top: 0.5rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
.mb-3 {
  margin-bottom: 0.75rem;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mb-8 {
  margin-bottom: 2rem;
}

.p-4 {
  padding: 1rem;
}
.p-6 {
  padding: 1.5rem;
}
.p-8 {
  padding: 2rem;
}
.px-2 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}
.px-6 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}
.px-8 {
  padding-left: 2rem;
  padding-right: 2rem;
}
.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}
.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.py-6 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}

.text-text {
  color: var(--text);
}
.text-subtext1 {
  color: var(--subtext1);
}
.text-overlay2 {
  color: var(--overlay2);
}
.text-overlay1 {
  color: var(--overlay1);
}
.text-overlay0 {
  color: var(--overlay0);
}
.text-sky {
  color: var(--sky);
}
.text-blue {
  color: var(--blue);
}
.text-green {
  color: var(--green);
}
.text-yellow {
  color: var(--yellow);
}
.text-mauve {
  color: var(--mauve);
}
.text-surface2 {
  color: var(--surface2);
}
.text-transparent {
  color: transparent;
}

.bg-base {
  background-color: var(--base);
}
.bg-mantle {
  background-color: var(--mantle);
}
.bg-surface0 {
  background-color: var(--surface0);
}
.bg-sky {
  background-color: var(--sky);
}
.bg-blue {
  background-color: var(--blue);
}
.bg-green {
  background-color: var(--green);
}
.bg-yellow {
  background-color: var(--yellow);
}

.border {
  border: 1px solid;
}
.border-t {
  border-top: 1px solid;
}
.rounded {
  border-radius: 0.25rem;
}
.rounded-lg {
  border-radius: 0.5rem;
}
.rounded-xl {
  border-radius: 0.75rem;
}
.rounded-2xl {
  border-radius: 1rem;
}

.shadow-lg {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
}
.shadow-2xl {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.backdrop-blur-sm {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.transition-all {
  transition-property: all;
}
.transition-colors {
  transition-property: color, background-color, border-color;
}
.duration-200 {
  transition-duration: 200ms;
}
.duration-300 {
  transition-duration: 300ms;
}
.transform {
  transform: var(--tw-transform, none);
}
.scale-95 {
  --tw-transform: scale(0.95);
  transform: scale(0.95);
}
.scale-105 {
  --tw-transform: scale(1.05);
  transform: scale(1.05);
}
.hover\:scale-105:hover {
  transform: scale(1.05);
}

.bg-gradient-to-r {
  background-image: linear-gradient(
    to right,
    var(--tw-gradient-from),
    var(--tw-gradient-to)
  );
}

.bg-gradient-to-br {
  background-image: linear-gradient(
    to bottom right,
    var(--tw-gradient-from),
    var(--tw-gradient-via),
    var(--tw-gradient-to)
  );
}

.from-crust {
  --tw-gradient-from: var(--crust);
}
.via-base {
  --tw-gradient-via: var(--base);
}
.to-mantle {
  --tw-gradient-to: var(--mantle);
}

.from-sky {
  --tw-gradient-from: var(--sky);
}
.via-blue {
  --tw-gradient-via: var(--blue);
}
.to-blue {
  --tw-gradient-to: var(--blue);
}
.hover\:from-sapphire:hover {
  --tw-gradient-from: var(--sapphire);
}

.from-sky\/15 {
  --tw-gradient-from: color-mix(in srgb, var(--sky) 15%, transparent);
}

.to-blue\/15 {
  --tw-gradient-to: color-mix(in srgb, var(--blue) 15%, transparent);
}

.bg-clip-text {
  -webkit-background-clip: text;
  background-clip: text;
}

.ascii-logo {
  line-height: 1.2;
  white-space: pre;
  color: var(--sky);
  text-align: center;
  font-size: 0.75rem;
  font-family: monospace;
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .ascii-logo {
    font-size: 0.875rem;
  }
}

.instructions-box {
  background-image: linear-gradient(
    to right,
    color-mix(in srgb, var(--sky) 15%, transparent),
    color-mix(in srgb, var(--blue) 15%, transparent)
  );
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid color-mix(in srgb, var(--sky) 30%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.editor-column {
  display: flex;
  flex-direction: column;
  position: relative;
}

.editor-wrapper {
  background-image: linear-gradient(
    to bottom right,
    var(--mantle),
    var(--surface0)
  );
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 1.5rem;
  border: 1px solid color-mix(in srgb, var(--surface1) 50%, transparent);
  position: relative;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.editor-display {
  position: relative;
  overflow: auto;
  max-height: 600px;
  tab-size: 4;
  font-size: 1.125rem;
  flex: 1;
  min-height: 200px;
  background-color: var(--mantle);
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--surface0) 50%, transparent);
  font-family: monospace;
  line-height: 1.625;
}

.editor-display .line {
  display: flex;
  min-height: 1.5em;
}

.editor-display .line-number {
  color: var(--surface2);
  width: 3em;
  text-align: right;
  padding-right: 1em;
  user-select: none;
  flex-shrink: 0;
}

.editor-display .line-content {
  flex: 1;
  white-space: pre;
}

.editor-display .cursor {
  background-color: var(--yellow);
  color: var(--crust);
  border-radius: 2px;
}

.editor-display .insert-cursor {
  background-color: transparent;
  border-left: 2px solid var(--green);
  animation: blink 1s step-end infinite;
}

.editor-display .selected {
  background-color: color-mix(in srgb, var(--sky) 25%, transparent);
}

.editor-display .selected-cursor {
  background-color: var(--sky);
  color: var(--crust);
  border-radius: 2px;
}

.editor-display .search-match {
  background-color: color-mix(in srgb, var(--yellow) 30%, transparent);
}

.editor-display .search-current {
  background-color: var(--yellow);
  color: var(--crust);
}

.editor-display .target-word {
  background-color: color-mix(in srgb, var(--peach) 30%, transparent);
}

.target-column {
  display: flex;
  flex-direction: column;
}

.target-content {
  font-family: monospace;
  font-size: 1.125rem;
  line-height: 1.625;
  background-color: var(--surface0);
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--surface1) 50%, transparent);
  color: var(--overlay1);
  white-space: pre;
  overflow-x: auto;
  flex: 1;
  min-height: 200px;
}

.status-bar {
  transition: background-color 0.15s ease;
  min-width: 180px;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  font-weight: 700;
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

.status-bar.mode-normal {
  background-color: var(--yellow);
  color: var(--crust);
}

.status-bar.mode-select {
  background-color: var(--sky);
  color: var(--crust);
}

.status-bar.mode-insert {
  background-color: var(--green);
  color: var(--crust);
}

.command-log {
  color: var(--overlay1);
  font-size: 0.875rem;
  font-family: monospace;
  background-color: color-mix(in srgb, var(--surface0) 50%, transparent);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid color-mix(in srgb, var(--surface0) 50%, transparent);
}

.btn {
  font-weight: 700;
  border: none;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  transform: scale(1);
}

.btn:hover {
  transform: scale(1.05);
}

.btn-reset {
  font-weight: 600;
  border: none;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  transition: all 0.3s ease;
  background-image: linear-gradient(to right, var(--surface1), var(--surface2));
  color: var(--subtext1);
  white-space: nowrap;
}

.btn-reset:hover {
  background-image: linear-gradient(to right, var(--surface2), var(--surface1));
  color: var(--text);
}

.btn-primary {
  font-weight: 700;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
  background-image: linear-gradient(to right, var(--sky), var(--blue));
  color: var(--crust);
}

.btn-primary:hover {
  background-image: linear-gradient(to right, var(--sapphire), var(--blue));
  transform: scale(1.05);
}

.btn-primary-lg {
  font-weight: 700;
  border: none;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  background-image: linear-gradient(to right, var(--sky), var(--blue));
  color: var(--crust);
  font-size: 1.125rem;
}

.btn-primary-lg:hover {
  background-image: linear-gradient(to right, var(--sapphire), var(--blue));
  transform: scale(1.05);
}

.btn-next-world {
  font-weight: 700;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  background-color: var(--sky);
  color: var(--crust);
  margin-top: 0.5rem;
}

.btn-next-world:hover {
  background-color: var(--sapphire);
}

#world-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

#world-tabs button {
  white-space: nowrap;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  background-color: var(--surface0);
  color: var(--overlay2);
}

#world-tabs button:hover {
  background-color: var(--surface1);
  color: var(--text);
}

.world-tab-current {
  color: var(--text) !important;
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
  background-color: var(--blue);
}

.level-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-weight: 700;
  transition: all 0.15s ease;
  border: none;
  background-color: var(--surface0);
  color: var(--surface2);
}

.level-btn:hover {
  transform: scale(1.1);
}

.level-btn.completed {
  border: 2px solid color-mix(in srgb, var(--green) 50%, transparent);
}

.level-btn.current {
  background-color: var(--sky);
  color: var(--crust);
}

.level-btn.locked {
  background-color: var(--surface0);
  color: var(--surface2);
  cursor: not-allowed;
}

#level-selection {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.footer {
  text-align: center;
  padding: 1.5rem 0;
  border-top: 1px solid color-mix(in srgb, var(--surface1) 30%, transparent);
  margin-top: 1rem;
}

.modal-bg {
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}

.modal-content {
  background-image: linear-gradient(
    to bottom right,
    var(--surface0),
    var(--base)
  );
  color: var(--text);
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  max-width: 28rem;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--surface1) 50%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-title {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(to right, var(--sky), var(--blue));
}

.modal-message {
  margin-bottom: 1.5rem;
  color: var(--overlay2);
}

.celebration-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.celebration-title {
  font-size: 3rem;
  font-weight: 800;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(
    to right,
    var(--sky),
    var(--blue),
    var(--mauve)
  );
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .celebration-title {
    font-size: 4.5rem;
  }
}

.celebration-text {
  font-size: 1.25rem;
  color: var(--lavender);
  margin-bottom: 2rem;
  font-weight: 500;
}

@media (min-width: 768px) {
  .celebration-text {
    font-size: 1.875rem;
  }
}

.level-complete-flash {
  animation: flash 0.5s ease;
}

@keyframes flash {
  0% {
    box-shadow: 0 0 0 0 rgba(145, 215, 227, 0.7);
  }
  50% {
    box-shadow: 0 0 20px 10px rgba(145, 215, 227, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(145, 215, 227, 0);
  }
}

@keyframes blink {
  50% {
    border-color: transparent;
  }
}

.confetti {
  position: absolute;
  font-size: 1.5rem;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-10vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

.editor-hint {
  color: var(--overlay0);
  font-size: 0.75rem;
}
