*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --text:  #111111;
  --muted: #999999;
  --font:  'Helvetica Neue', 'Helvetica', system-ui, -apple-system, sans-serif;
}

body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  padding-bottom: max(48px, env(safe-area-inset-bottom, 0px) + 24px);
  gap: 24px;
}

@media (min-width: 769px) {
  body {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    gap: 0;
  }
}

.label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.label-right { text-align: center; }

@media (min-width: 769px) {
  .label-left  { width: 150px; text-align: left; }
  .label-right { width: 150px; text-align: right; }
}

.stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
}

@media (min-width: 769px) {
  .stage {
    flex: none;
    width: min(700px, calc(100vw - 364px), calc((100vh - 80px) * 1.4));
    aspect-ratio: 7 / 5;
  }
}

.color-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 2px;
}

.swatch {
  position: relative;
  overflow: hidden;
  cursor: default;
}

.swatch-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
}

.swatch-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  animation: rippleOut 0.55s ease forwards;
  pointer-events: none;
  z-index: 3;
}

@keyframes rippleOut {
  from { transform: scale(0.2); opacity: 0.8; }
  to   { transform: scale(3);   opacity: 0; }
}

.stage.pick .swatch { cursor: pointer; }
.stage.pick .swatch:hover { z-index: 10; }

.stage.pick .swatch:hover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.6);
}

.color-grid.dimmed .swatch {
  filter: brightness(0.4);
  transition: filter 0.25s ease;
}

.color-grid.dimmed .swatch.selected-swatch,
.color-grid.dimmed .swatch.best-match { filter: brightness(1); }

.swatch.best-match::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  box-shadow: inset 0 0 0 2.5px #111;
}

.reveal-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.reveal-overlay.gone { opacity: 0; }

.countdown-ring {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 28px;
  height: 28px;
  display: none;
}

.countdown-ring svg { transform: rotate(-90deg); }

.countdown-ring circle {
  fill: none;
  stroke: rgba(0,0,0,0.1);
  stroke-width: 2.5;
}

.countdown-ring .progress {
  stroke: rgba(0,0,0,0.5);
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.split-view {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  transform: translateY(105%);
  opacity: 0;
  transition:
    transform 0.52s cubic-bezier(0.34, 1.12, 0.64, 1),
    opacity   0.3s ease;
  z-index: 3;
}

.split-view.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.split-half {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
}

.split-divider {
  width: 2px;
  background: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.split-label {
  font-size: 10px;
  color: rgba(255,255,255,0.9);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: rgba(0,0,0,0.24);
  backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 99px;
}

.split-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%) scale(0.85);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 12px 24px;
  text-align: center;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.22s ease 0.28s, transform 0.22s ease 0.28s;
}

.split-view.show .split-badge {
  opacity: 1;
  transform: translate(-50%,-50%) scale(1);
}

.split-badge-score {
  font-size: 40px;
  font-weight: 400;
  line-height: 1;
  color: var(--text);
  letter-spacing: 0.16em;
}

.split-badge-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-top: 4px;
}

.final-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #fff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 56px;
}

.final-screen.show { display: flex; }

.result-block {
  display: flex;
  flex-direction: column;
  gap: 72px;
  width: 308px;
}

.result-score-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.result-total {
  font-size: 50px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-max {
  font-size: 16px;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-rounds { display: flex; gap: 2px; }

.result-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 60px;
}

.result-swatches {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 60px;
}

.result-swatch { width: 60px; height: 60px; }

.result-round-score {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.result-actions { display: flex; gap: 56px; }

.action-btn {
  font-size: 12px;
  font-family: var(--font);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.action-btn:hover  { color: var(--muted); }
.action-btn.copied { color: var(--muted); }

.fade-enter { animation: fadeIn 0.4s ease forwards; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
