﻿:root {
  --bg: #f4efe6;
  --panel: #fffaf2;
  --ink: #1f2a30;
  --muted: #5d696f;
  --line: #d3cabf;
  --accent: #22577a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #fff6e6 0, transparent 35%),
    radial-gradient(circle at 90% 90%, #e8f5ff 0, transparent 40%),
    var(--bg);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

header h1 {
  margin: 0;
  font-size: 2rem;
}

header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.panel {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.panel h2 {
  margin: 0 0 12px;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
}

.palette {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}

.color-btn.active {
  border-color: var(--accent);
  transform: scale(1.06);
}

.cube-net {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  grid-template-areas:
    ". U . ."
    "L F R B"
    ". D . .";
}

.face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.face[data-face="U"] { grid-area: U; }
.face[data-face="R"] { grid-area: R; }
.face[data-face="F"] { grid-area: F; }
.face[data-face="D"] { grid-area: D; }
.face[data-face="L"] { grid-area: L; }
.face[data-face="B"] { grid-area: B; }

.sticker {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #444;
  border-radius: 6px;
  cursor: pointer;
}

.sticker.center {
  cursor: not-allowed;
  box-shadow: inset 0 0 0 2px #00000022;
}

.counts {
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}

.count-item {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.count-item.bad {
  border-color: #b42318;
  color: #b42318;
}

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

button {
  border: 1px solid #27506c;
  background: #22577a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}

button#reset {
  background: #fff;
  color: #22577a;
}

.camera-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.camera-controls select {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.camera-wrap {
  position: relative;
  margin-top: 12px;
  width: min(100%, 360px);
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0f172a;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-guide {
  position: absolute;
  inset: 20%;
  border: 2px solid #ffffffcc;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px #00000044;
  pointer-events: none;
}

.scan-guide::before,
.scan-guide::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, transparent calc(33.33% - 1px), #ffffffaa calc(33.33% - 1px), #ffffffaa calc(33.33% + 1px), transparent calc(33.33% + 1px), transparent calc(66.66% - 1px), #ffffffaa calc(66.66% - 1px), #ffffffaa calc(66.66% + 1px), transparent calc(66.66% + 1px)),
    linear-gradient(to bottom, transparent calc(33.33% - 1px), #ffffffaa calc(33.33% - 1px), #ffffffaa calc(33.33% + 1px), transparent calc(33.33% + 1px), transparent calc(66.66% - 1px), #ffffffaa calc(66.66% - 1px), #ffffffaa calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.anim-playing {
  background: #12683b;
  border-color: #12683b;
}

.status {
  margin: 0;
  color: #7a1c1c;
  min-height: 1.5em;
}

.solution {
  margin: 10px 0 0;
  background: #0b132b;
  color: #e0fbfc;
  padding: 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 760px) {
  .cube-net {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }

  .camera-wrap {
    width: 100%;
  }
}
