/* 색감 테스트 (color.js) */
.ct-hud {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 22px 4px 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.ct-hud b {
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0 2px;
}
.ct-pen {
  position: absolute;
  right: 4px;
  top: -1.2em;
  color: var(--wait);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
}
.ct-pen.on {
  animation: ct-pen 0.9s ease-out;
}
@keyframes ct-pen {
  0% {
    opacity: 1;
    transform: translateY(8px);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}
.ct .timebar {
  margin-top: 8px;
}
.ct .timebar span {
  transition: background-color 0.3s;
}
.ct .timebar.low span {
  background: var(--wait);
}

.ct-stage {
  position: relative;
  /* 판 전체(단계 · 남은 시간 + 격자)가 한 화면에 들어오게 화면 높이에 맞춰 줄인다. 너무 작아지지는 않게 300px 까지만. */
  width: min(100%, max(300px, min(520px, calc(100vh - 200px))));
  width: min(100%, max(300px, min(520px, calc(100svh - 200px))));
  aspect-ratio: 1 / 1;
  margin: 14px auto 0;
}
.ct-board {
  --n: 2;
  --gap: 7px;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: var(--gap);
  width: 100%;
  height: 100%;
  padding: var(--gap);
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ct-board.off {
  pointer-events: none;
}
.ct-stage.is-idle .ct-board {
  filter: blur(6px) saturate(0.7);
  opacity: 0.5;
}
.ct-tile {
  appearance: none;
  position: relative;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  border-radius: clamp(5px, calc(48px / var(--n)), 16px);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ct-tile:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  z-index: 1;
}
.ct-tile.wrong::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.95rem, 4vw, 1.6rem);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.ct-board.shake {
  animation: ct-shake 0.36s ease-in-out;
}
@keyframes ct-shake {
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(3px);
  }
}
.ct-board.pop {
  animation: ct-pop 0.16s ease-out;
}
@keyframes ct-pop {
  50% {
    transform: scale(0.99);
  }
}

/* 시작 · 다시 하기 단추: 판 위를 덮는다 */
.ct-start.pad {
  position: absolute;
  inset: 0;
  min-height: 0;
  border-radius: 22px;
  background: color-mix(in srgb, var(--brand) 92%, transparent);
}
.ct-start.pad:disabled {
  cursor: default;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  color: var(--bg);
}

/* 결과: 마지막에 놓친 칸 */
.ct-missed {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.ct-missed h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}
.ct-mini {
  --n: 2;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 3px;
  width: min(100%, 240px);
  aspect-ratio: 1 / 1;
  margin: 12px auto 8px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}
.ct-mini-tile {
  position: relative;
  border-radius: 4px;
}
.ct-mini-tile.hit {
  z-index: 1;
  outline: 3px solid var(--ink);
  outline-offset: 1px;
  animation: ct-hit 1.2s ease-in-out infinite;
}
@keyframes ct-hit {
  50% {
    outline-color: var(--brand);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ct-board.shake,
  .ct-board.pop,
  .ct-pen.on,
  .ct-mini-tile.hit {
    animation: none;
  }
}
