:root {
  --bg: #0b0f14;
  --panel: #141a22;
  --panel-2: #1a222d;
  --border: #2a3544;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d9cf0;
  --accent-2: #5eead4;
  --danger: #f07178;
  --ok: #7fd992;
  --warn: #e6c07b;
  --btn: #243041;
  --btn-hover: #2f3f55;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  font-family: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2a44 0%, transparent 55%),
    radial-gradient(900px 500px at 90% 0%, #14352f 0%, transparent 50%),
    var(--bg);
}

.app {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100%;
}

header.top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
header.top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .02em;
}
header.top .subtitle { color: var(--muted); font-size: .9rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(61,156,240,.12);
  color: var(--accent);
  font-size: .8rem;
  border: 1px solid rgba(61,156,240,.25);
}

.stage {
  position: relative;
  background: linear-gradient(180deg, #121820, #0e141c);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 520px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#cube-canvas {
  width: 100%;
  flex: 1;
  min-height: 420px;
  display: block;
  touch-action: none;
  cursor: grab;
}
#cube-canvas:active { cursor: grabbing; }

.hud {
  position: absolute;
  left: 12px; top: 12px;
  display: flex; gap: 8px; flex-wrap: wrap;
  pointer-events: none;
}
.hud .pill {
  pointer-events: none;
  background: rgba(10,14,20,.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
}
.hud .pill strong { color: var(--accent-2); }

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding-right: 4px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--accent-2);
  font-weight: 700;
}
.card p, .card li { color: var(--muted); font-size: .88rem; line-height: 1.55; }
.card p.strong { color: var(--text); }

.row { display: flex; flex-wrap: wrap; gap: 8px; }

button, .btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: .15s background, .15s transform, .15s border-color;
}
button:hover { background: var(--btn-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, #2b7de0, #1f6fd0);
  border-color: #3d9cf0;
}
button.primary:hover { filter: brightness(1.08); }
button.good {
  background: linear-gradient(135deg, #1f8a5b, #157a4e);
  
  border-color: #3cbc7c;
}
button.warn {
  background: linear-gradient(135deg, #a67c2a, #8a6420);
  border-color: var(--warn);
}
button.ghost { background: transparent; }
button.move-btn {
  min-width: 48px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
button.move-btn.prime { color: #ffb4a2; }

.notation {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 44px;
  word-break: break-word;
  color: #d7e3f4;
  font-size: .85rem;
  line-height: 1.45;
}
.notation .hl { color: var(--accent-2); font-weight: 700; }

.lesson-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.lesson-tabs button.active {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(94,234,212,.08);
}

.phase-box {
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: rgba(61,156,240,.06);
  border-radius: 0 10px 10px 0;
  margin-top: 8px;
}
.phase-box h3 { margin: 0 0 4px; font-size: .9rem; color: var(--text); }
.timer-big {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--accent-2);
}
.ok-flash { color: var(--ok) !important; }
.hint-moves {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--warn);
  font-size: 1rem;
  margin-top: 6px;
}

.footer-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
  padding: 4px 0 12px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { max-height: none; }
  .stage { min-height: 420px; }
}
