:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #182132;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #a7b0c0;
  --accent: #2dd4bf;
  --danger: #fb7185;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.18), transparent 34rem),
    linear-gradient(160deg, #0f172a 0%, #111827 55%, #18181b 100%);
  color: var(--text);
  overscroll-behavior: none;
  touch-action: manipulation;
  overflow-x: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  min-height: 44px;
  padding: 0 14px;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  color: #657184;
  cursor: not-allowed;
  transform: none;
}

.app-shell {
  max-width: 620px;
  width: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 14px;
  overflow: hidden;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 64px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 10vw, 3.5rem);
  line-height: 0.96;
  margin: 0;
}

.icon-button {
  align-items: center;
  aspect-ratio: 1;
  background: var(--accent);
  color: #042f2e;
  display: inline-grid;
  font-size: 1.5rem;
  justify-content: center;
  padding: 0;
  width: 46px;
}

.status-band {
  background: rgba(17, 24, 39, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-width: 0;
  overflow: hidden;
}

.status-band > div {
  padding: 10px 8px;
  text-align: center;
}

.status-band > div + div {
  border-left: 1px solid var(--line);
}

.label {
  color: var(--muted);
  display: block;
  font-size: 0.7rem;
  font-weight: 750;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.status-band strong {
  font-size: 1.1rem;
}

.game-stage {
  align-self: center;
  aspect-ratio: 1;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  justify-self: center;
  min-width: 0;
  overflow: hidden;
  position: relative;
  width: min(100%, 620px, calc(100dvh - 256px));
}

canvas {
  display: block;
  height: 100%;
  min-width: 0;
  touch-action: none;
  width: 100%;
}

.completion {
  align-items: center;
  background: rgba(8, 13, 25, 0.74);
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
}

.completion[hidden] {
  display: none;
}

.completion > div {
  align-items: center;
  background: rgba(248, 250, 252, 0.94);
  border-radius: 8px;
  color: #0f172a;
  display: grid;
  gap: 12px;
  min-width: min(82%, 280px);
  padding: 22px;
  text-align: center;
}

.completion p {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  margin: 0;
}

.completion button {
  background: #0f172a;
}

.controls {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
}

.controls button {
  padding: 0 8px;
  white-space: normal;
}

.level-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  min-width: 0;
}

.level-chip {
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  position: relative;
}

.level-chip.active {
  background: var(--accent);
  color: #042f2e;
}

.level-chip.solved::after {
  border-bottom: 3px solid #22c55e;
  border-left: 3px solid #22c55e;
  content: "";
  height: 6px;
  position: absolute;
  right: 8px;
  top: 8px;
  transform: rotate(-45deg);
  width: 12px;
}

.level-chip.active.solved::after {
  border-color: #064e3b;
}

.best-times {
  background: rgba(17, 24, 39, 0.56);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.best-times-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.best-times h2 {
  font-size: 1rem;
  line-height: 1;
  margin: 0;
}

.best-times-header button {
  font-size: 0.82rem;
  min-height: 34px;
  padding: 0 10px;
}

.best-times-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 26px;
}

.best-times-list:empty::before {
  color: var(--muted);
  content: "Noch keine komplette Runde.";
  display: block;
  margin-left: -26px;
}

.best-times-list li {
  color: var(--muted);
  font-size: 0.9rem;
  padding-left: 4px;
}

.best-times-list strong {
  color: var(--text);
}

@media (max-width: 420px) {
  .app-shell {
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .level-strip {
    grid-template-columns: repeat(4, minmax(40px, 1fr));
  }
}
