*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: #f0f2f5;
  color: #1a1a2e;
  padding: 1.5rem;
}

header {
  text-align: center;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header p.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* ── Main layout: canvas card + terminal side-by-side ── */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  max-width: 820px;
}

/* ── Canvas card ── */
.card {
  background: #ffffff;
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

canvas {
  touch-action: none;
  border-radius: 0.75rem;
  border: 2px dashed #d1d5db;
  cursor: crosshair;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  background: #fafafa;
  transition: border-color 0.2s;
}

canvas:hover {
  border-color: #9ca3af;
}

.hint {
  font-size: 0.8rem;
  color: #9ca3af;
  text-align: center;
}

.scores {
  display: flex;
  gap: 2rem;
  align-items: baseline;
  justify-content: center;
}

#result {
  font-size: 2.5rem;
  font-weight: 700;
  min-height: 3rem;
  text-align: center;
  letter-spacing: -1px;
  transition: color 0.3s;
}

#result:empty::before {
  content: "Draw a circle!";
  font-size: 1rem;
  font-weight: 400;
  color: #9ca3af;
  letter-spacing: 0;
}

#best {
  font-size: 1rem;
  font-weight: 600;
  color: #9ca3af;
  text-align: center;
  transition: color 0.3s;
  white-space: nowrap;
}

/* ── Terminal panel ── */
.terminal-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 0 0 200px;
}

.terminal-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  padding-left: 0.25rem;
}

#py-console {
  width: 100%;
  height: 420px;
  overflow-y: auto;
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.7rem;
  line-height: 1.6;
  border-radius: 0.75rem;
  padding: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  scrollbar-width: thin;
  scrollbar-color: #45475a #1e1e2e;
}

#py-console::-webkit-scrollbar {
  width: 4px;
}

#py-console::-webkit-scrollbar-track {
  background: #1e1e2e;
}

#py-console::-webkit-scrollbar-thumb {
  background: #45475a;
  border-radius: 2px;
}

/* ── Responsive: stack vertically on small screens ── */
@media (max-width: 640px) {
  .layout {
    flex-direction: column;
  }

  .terminal-panel {
    flex: 1 1 auto;
    width: 100%;
  }

  #py-console {
    height: 160px;
  }
}
