:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #62718a;
  --line: #dbe3ef;
  --primary: #1769e0;
  --green: #18995a;
  --danger: #c83c3c;
  --gold: #f5b632;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #eaf0f8;
  border-right: 1px solid var(--line);
  padding: 24px;
}

.brand h1,
.brand p,
h2,
p {
  margin: 0;
}

.brand {
  margin-bottom: 20px;
}

.brand h1 {
  font-size: 30px;
}

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

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

.panel + .panel {
  margin-top: 14px;
}

.panel-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

h2 {
  font-size: 18px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 10px;
}

button {
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font: inherit;
  height: 38px;
  margin-top: 14px;
  padding: 0 16px;
}

button.ghost {
  background: transparent;
  color: var(--primary);
  height: auto;
  margin: 0;
  padding: 0;
}

button.secondary {
  background: #e9eef8;
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.message {
  color: var(--muted);
  min-height: 24px;
}

.message.ok {
  color: var(--green);
}

.message.error {
  color: var(--danger);
}

.levels {
  display: grid;
  gap: 10px;
}

.level-button {
  align-items: start;
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  gap: 2px;
  height: auto;
  line-height: 1.35;
  margin: 0;
  min-height: 72px;
  padding: 10px 10px 12px;
  text-align: left;
}

.level-button.active {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.level-button.completed {
  border-color: rgba(24, 153, 90, 0.45);
}

.level-button.locked {
  cursor: not-allowed;
  opacity: 0.58;
}

.level-button small {
  color: var(--muted);
  display: block;
}

.level-button span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.workspace {
  padding: 28px;
}

.workspace.empty {
  align-items: center;
  display: flex;
  justify-content: center;
}

.hero {
  color: var(--muted);
  text-align: center;
}

.challenge {
  display: grid;
  gap: 16px;
  max-width: 980px;
}

.story {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.badge {
  background: #e8f0fe;
  border-radius: 999px;
  color: var(--primary);
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
}

.story h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

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

.prompt {
  border-top: 1px solid var(--line);
  color: var(--ink) !important;
  margin-top: 14px;
  padding-top: 14px;
}

.stage {
  align-items: end;
  background: linear-gradient(#bfe4ff 0 68%, #73bd66 68% 100%);
  border: 1px solid #a6cee9;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 80px 1fr 90px;
  height: 210px;
  overflow: hidden;
  padding: 0 28px 32px;
}

.player {
  background: var(--primary);
  border-radius: 8px 8px 4px 4px;
  height: 52px;
  width: 36px;
}

.reward {
  align-self: center;
  background: var(--gold);
  border-radius: 999px;
  color: #402800;
  justify-self: center;
  padding: 12px 18px;
}

.gate {
  background: #39506b;
  border-radius: 8px 8px 0 0;
  color: white;
  height: 92px;
  padding-top: 18px;
  text-align: center;
}

textarea {
  background: #111827;
  color: #f7fafc;
  font: 16px/1.45 Consolas, "Courier New", monospace;
  min-height: 190px;
  resize: vertical;
}

.actions {
  align-items: center;
  display: flex;
  gap: 14px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
  }
}
