:root {
  --bg: #14161a;
  --panel: #1f2228;
  --line: #2e323a;
  --text: #eef0f3;
  --muted: #9aa1ac;
  --accent: #3d8bff;
  --bad: #ff4d5e;
  --ok: #36c27a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: the hidden attribute must win over display rules like .btn */
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px / 1.45 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
}

section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
section[hidden] {
  display: none;
}

h1 {
  margin: 4px 0 0;
  font-size: 28px;
  text-align: center;
}
.lead {
  color: var(--muted);
  text-align: center;
  margin: 0;
}
.small {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.center {
  text-align: center;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0;
}
.row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.row > .big {
  flex: 1;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.big {
  padding: 14px 18px;
  font-size: 17px;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.logo {
  width: 96px;
  height: 96px;
  margin: 28px auto 4px;
  background: url(icons/icon.svg) center / contain no-repeat;
}

.bar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.bar > span:nth-child(2) {
  text-align: center;
}
.icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--panel);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  padding: 0 0 4px;
  cursor: pointer;
}

.dots {
  display: flex;
  gap: 5px;
}
.dots i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid var(--c);
  opacity: 0.45;
}
.dots i.done {
  background: var(--c);
  opacity: 1;
}
.dots i.cur {
  opacity: 1;
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* --- scan --- */

.instr {
  display: flex;
  gap: 12px;
  align-items: center;
}
.instr p {
  margin: 0;
  font-size: 15px;
}
.mini {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 12px);
  gap: 2px;
  padding: 3px;
  background: #0b0c0e;
  border-radius: 4px;
}
.mini i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: #555b66;
}
.mini.edge-top {
  border-top: 6px solid var(--edge);
}
.mini.edge-bottom {
  border-bottom: 6px solid var(--edge);
}

.viewport {
  position: relative;
  width: min(100%, 58vh);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  touch-action: none;
}
.viewport video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.viewport img {
  position: absolute;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.grid {
  position: absolute;
  left: 15%;
  top: 15%;
  width: 70%;
  height: 70%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 3%;
  pointer-events: none;
}
.cell {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 10%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.cell::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  height: 26%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--c, transparent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
}
.grid.flash .cell::after {
  width: 100%;
  height: 100%;
  border-radius: 10%;
  transition: all 0.2s;
}
.cam-msg {
  position: absolute;
  inset: auto 12px 12px;
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(20, 22, 26, 0.92);
  font-size: 14px;
  text-align: center;
}
.cam-msg .btn {
  margin-top: 8px;
}
.shoot {
  min-width: 40%;
}

/* --- review --- */

.net {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas: ". U . ." "L F R B" ". D . .";
  gap: 6px;
}
.face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  align-content: start;
}
.st {
  aspect-ratio: 1;
  border: 0;
  border-radius: 18%;
  padding: 0;
  background: #3a3f48;
  cursor: pointer;
  touch-action: manipulation;
}
.st.unknown {
  background: repeating-linear-gradient(45deg, #3a3f48 0 4px, #2b2f36 4px 8px);
}
.st.center {
  cursor: default;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.st.locked {
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.5),
    inset 0 0 0 4px rgba(255, 255, 255, 0.5);
}
.st.auto {
  outline: 2px dashed #fff;
  outline-offset: 1px;
}
.st.bad {
  outline: 3px solid var(--bad);
  outline-offset: 1px;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse {
  to {
    outline-color: transparent;
  }
}
.face-label {
  grid-column: 1 / -1;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.pal {
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 6px 2px;
  font: inherit;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.pal::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--c);
}
.pal.sel {
  border-color: #fff;
}
.hold small {
  color: var(--muted);
}
.pal small {
  color: var(--muted);
}
.pal.off small {
  color: var(--bad);
  font-weight: 700;
}

.msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 77, 94, 0.12);
  border: 1px solid rgba(255, 77, 94, 0.4);
  font-size: 14px;
}
.msg.ok {
  background: rgba(54, 194, 122, 0.12);
  border-color: rgba(54, 194, 122, 0.4);
}

/* --- solve --- */

.hold {
  margin: 0;
  text-align: center;
  font-size: 15px;
}

.cube3d {
  height: 270px;
  position: relative;
  touch-action: none;
  cursor: grab;
}
.scene {
  perspective: 900px;
  overflow: hidden;
  --s: 46px;
}
.cube {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.cubie,
.layer {
  position: absolute;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
}
.cface {
  position: absolute;
  width: var(--s);
  height: var(--s);
  left: calc(var(--s) / -2);
  top: calc(var(--s) / -2);
  background: #0c0d0f;
  border-radius: 9%;
}
.cface.sticker::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 14%;
  background: var(--c);
}

.now {
  text-align: center;
  min-height: 92px;
}
.now .move {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.02em;
}
.now .desc {
  color: var(--muted);
  font-size: 15px;
}

.controls {
  display: grid;
  grid-template-columns: 52px 52px 1fr 52px;
  gap: 8px;
}
.icon-btn {
  padding: 0;
  font-size: 18px;
}

.moves {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.moves button {
  min-width: 44px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.moves button.done {
  opacity: 0.35;
}
.moves button.cur {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.notation {
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
}
.notation summary {
  cursor: pointer;
  font-weight: 600;
}
.notation p {
  margin: 8px 0 0;
  color: var(--muted);
}
.notation b {
  color: var(--text);
}

@media (min-width: 420px) {
  .scene {
    --s: 52px;
  }
  .cube3d {
    height: 300px;
  }
}

/* --- snap --- */

.iso {
  flex: none;
  width: 54px;
}
.iso svg {
  display: block;
  width: 100%;
}
.viewport.tall {
  aspect-ratio: 3 / 4;
  width: min(100%, 46vh);
}
#snap-photo {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#snap-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.viewport.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0.6;
  animation: fade 0.3s forwards;
}
@keyframes fade {
  to {
    opacity: 0;
  }
}
.status {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(20, 22, 26, 0.85);
  font-size: 14px;
  text-align: center;
}
.status.ok {
  background: rgba(28, 120, 72, 0.9);
}
.thumbs {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.thumb {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  border: 2px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  position: relative;
}
.thumb.cur {
  border-color: var(--accent);
  color: var(--text);
}
.thumb.done {
  border-style: solid;
  border-color: var(--ok);
}
.thumb canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb.done span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  text-align: center;
}
