:root {
  --bg: #131209; --card: #1F1F1F; --card2: #272727; --line: #313131;
  --text: #F2F1EC; --muted: #9B9B9B; --accent: #FF4FD8; --yellow: #FFD21F;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: 12px; --gap: 8px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Manrope, ui-sans-serif, system-ui, sans-serif; font-weight: 500;
  height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.top { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 12px; }
.row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tabs { position: relative; display: grid; grid-template-columns: repeat(var(--n, 2), auto); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2px; flex: none; }
.tabs .pill { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / var(--n, 2)); border-radius: 10px; background: #FFD21F; transform: translateX(calc(var(--i, 0) * 100%)); transition: transform 500ms var(--ease); }
.tabs button { position: relative; display: flex; align-items: center; justify-content: center; gap: 4px; font: inherit; font-size: 14px; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px 12px; min-height: 40px; border-radius: 10px; cursor: pointer; transition: color 300ms var(--ease); }
.tabs button .n { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 999px; font-size: 12px; border: 1px solid currentColor; }
.tabs button[aria-selected="true"] { color: #131209; }
.tabs button:active { transform: scale(0.98); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.goal { font-size: 12px; line-height: 16px; color: var(--muted); text-wrap: pretty; }
.goal b { color: var(--text); font-weight: 700; }
.title { min-width: 0; }
h1 { font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em;
  background: linear-gradient(90deg, #FFFFFF, #9B9B9B); -webkit-background-clip: text; background-clip: text; color: transparent; }
#group-title { font-size: 12px; color: var(--muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#groups { margin-top: 2px; font: inherit; font-size: 12px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; }

.seg { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2px; flex: none; }
.seg .pill { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / 3); border-radius: 10px; background: var(--card2);
  box-shadow: inset 0 0 0 1px rgba(255,79,216,0.55); transform: translateX(calc(var(--i, 1) * 100%)); transition: transform 500ms var(--ease); }
.seg button { position: relative; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 8px 8px; min-height: 40px; border-radius: 10px; cursor: pointer; transition: color 300ms var(--ease); }
.seg button[aria-checked="true"] { color: var(--text); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.grid { flex: 1; min-height: 0; display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.grid { grid-template-rows: repeat(var(--rows2, 4), minmax(0, 1fr)); }
.grid.even { grid-template-rows: repeat(var(--rows2, 3), minmax(0, 1fr)) auto; }
.grid.even .legend { grid-column: 1 / -1; padding: 8px 12px; }
.grid.even .legend dl { display: flex; flex-wrap: wrap; gap: 0 16px; }
.grid.even .legend dl div { gap: 4px; }
.grid.even .legend dt { min-width: 0; }
@media (min-aspect-ratio: 4/5) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid { grid-template-rows: repeat(var(--rows4, 2), minmax(0, 1fr)); } .grid.even { grid-template-rows: repeat(var(--rows4, 2), minmax(0, 1fr)) auto; } }
@media (min-width: 900px) { body { max-width: 1200px; margin: 0 auto; width: 100%; } }

.tile { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px; transition: transform 300ms var(--ease), border-color 300ms var(--ease), background-color 300ms var(--ease); }
.tile:hover { background: #232323; }
.tile:active { transform: scale(0.98); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile[data-status="playing"], .tile[data-status="done"] { border-color: rgba(255,79,216,0.7); }
.tile[data-status="paused"] { border-color: rgba(255,79,216,0.35); }

.stage { position: relative; flex: 1; min-height: 0; border-radius: 8px; overflow: hidden;
  background: radial-gradient(closest-side, rgba(255,255,255,0.05), transparent); }
.stage canvas.cube { position: absolute; inset: 0; display: block; }
.stage canvas.top { position: absolute; top: 0; left: 0; width: 40px; height: 40px; opacity: 0.95; }
.tile[data-kind="pll"] .stage canvas.top { width: 52px; height: 52px; opacity: 1; }
.name .step { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 4px; border-radius: 999px; font-size: 12px; background: var(--card2); border: 1px solid var(--line); color: var(--yellow); vertical-align: 1px; }
.badge { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 1px 4px; border-radius: 6px; font-size: 12px; font-weight: 700; line-height: 16px; text-align: center; text-wrap: balance;
  color: #131209; background: #FFD21F; box-shadow: 0 -4px 16px rgba(0,0,0,0.35); opacity: 0; transform: translateY(8px); transition: opacity 300ms var(--ease), transform 500ms var(--ease); pointer-events: none; }
.tile[data-status="done"] .badge { opacity: 1; transform: none; }
.state { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 999px; background: rgba(0,0,0,0.45); border: 1px solid var(--line); display: grid; place-items: center; }
.state svg { width: 12px; height: 12px; fill: var(--text); }
.state .ic-pause { display: none; }
.tile[data-status="playing"] .state .ic-play { display: none; }
.tile[data-status="playing"] .state .ic-pause { display: inline; }
.tile[data-status="playing"] .state { background: var(--accent); border-color: var(--accent); }
.tile[data-status="playing"] .state svg { fill: #131209; }
.bar { position: absolute; left: 8px; right: 8px; bottom: 2px; height: 2px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }

.meta { flex: none; padding-top: 4px; }
.name { display: block; font-size: 14px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alg { display: flex; flex-wrap: wrap; gap: 0 2px; margin-top: 2px; font-size: 12px; font-weight: 600; line-height: 18px; font-variant-numeric: tabular-nums; color: #CFCDC6; }
.mv { padding: 0 3px; border-radius: 4px; transition: background-color 200ms var(--ease), color 200ms var(--ease); }
.mv.done { color: #6F6E69; }
.mv.now { background: var(--accent); color: #131209; }

.legend { min-height: 0; min-width: 0; overflow: hidden; background: transparent; border: 1px dashed var(--line); border-radius: 16px; padding: 8px 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.legend .lh { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; text-wrap: pretty; }
.legend dl { display: grid; gap: 0; }
.legend dl div { display: flex; gap: 8px; font-size: 12px; line-height: 18px; }
.legend dt { color: var(--yellow); font-weight: 700; min-width: 36px; }
.legend dd { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-height: 700px) {
  .top { padding-bottom: 8px; }
  .top { gap: 4px; padding-bottom: 8px; }
  .seg button, .tabs button { padding: 4px 8px; min-height: 36px; }
  .tile[data-kind="pll"] .stage canvas.top { width: 44px; height: 44px; }
  .tile { padding: 4px 8px 8px; border-radius: 12px; }
  .stage canvas.top { width: 32px; height: 32px; }
  .legend { border-radius: 12px; padding: 4px 8px; }
  .legend .lh { display: none; }
}
@media (prefers-reduced-motion: reduce) { .seg .pill, .tile, .mv { transition: none; } }
.tile[data-status="idle"] .bar { opacity: 0; }
