html,
body {
  touch-action: manipulation;
}

html.untangle-dragging,
html.untangle-dragging body {
  overflow: hidden;
  touch-action: none;
}

.untangle-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.untangle-shell [hidden] {
  display: none !important;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.stat-card {
  padding: 8px 8px 10px;
  border-radius: var(--radius-lg);
  border: 2.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.stat-card--level { background: var(--amber-soft); }
.stat-card--drags { background: var(--indigo-soft); }
.stat-card--best { background: var(--sky-soft); }

.stat-label {
  font-size: 0.74rem;
  font-weight: 900;
  color: var(--ink);
}

.stat-value {
  font-size: clamp(1.05rem, 3.6vw, 1.4rem);
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-sub {
  margin-top: 2px;
  min-height: 1em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-secondary);
}

.untangle-stage {
  position: relative;
  height: clamp(240px, calc(100dvh - 420px), 540px);
  min-height: 240px;
  border-radius: var(--radius-xl);
  border: 2.5px solid var(--border);
  background-color: #ffffff;
  background-image: radial-gradient(#cbd5e1 1.15px, transparent 1.15px);
  background-size: 18px 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.untangle-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.untangle-stage canvas.is-grabbing {
  cursor: grabbing;
}

.untangle-stage.is-clear {
  background-color: #f0fdf4;
}

.untangle-live {
  min-height: 1.35em;
  margin: 8px 0 0;
  text-align: center;
  font-weight: 900;
  color: var(--mint-hover);
}

.untangle-card {
  margin-top: 10px;
  padding: 14px 14px 16px;
  border-radius: var(--radius-lg);
  border: 2.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.untangle-card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.untangle-card p {
  margin: 0 0 10px;
}

.untangle-kicker {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--indigo);
}

.untangle-best {
  font-weight: 800;
  color: var(--ink-secondary);
}

.untangle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.untangle-wide {
  flex: 1 1 140px;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.untangle-card--results {
  background: var(--mint-soft);
}

.untangle-res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 10px;
}

.untangle-res-grid div {
  padding: 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: #ffffff;
  text-align: center;
}

.untangle-res-grid span {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-secondary);
}

.untangle-res-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
}

.untangle-new {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  background: var(--amber);
  font-size: 0.75rem;
  font-weight: 900;
}

.untangle-shell .arcade-hint {
  margin-top: 12px;
}

.untangle-shell .privacy-note {
  margin-top: 16px;
}

.untangle-card button:focus-visible,
.untangle-card a:focus-visible,
.untangle-actions button:focus-visible {
  outline: 3px solid var(--indigo);
  outline-offset: 2px;
}
