:root {
    --bg: #17141d;
    --panel: #221e2b;
    --accent: #ff5fa2;
    --accent2: #a06bff;
    --text: #f2eef7;
    --sub: #b9b2c6;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }   /* display:flex 등이 hidden을 덮어쓰지 않게 */
  body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0%, #2a2236 0%, #14111b 60%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Malgun Gothic", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 16px 60px;
  }
  h1 {
    font-size: 20px;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
  }
  p.sub {
    color: var(--sub);
    font-size: 13px;
    margin: 0 0 20px;
    text-align: center;
  }
  .game-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
  }
  .stage {
    position: relative;
    height: min(70vh, 680px);
    width: auto;
    aspect-ratio: 1 / 1;
    background: var(--panel);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  }
  canvas {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.35s ease;
  }
  #zoomBtn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: auto;
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.25);
  }
  #zoomBtn:disabled { opacity: 0.4; cursor: default; }
  .badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.55);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--sub);
    backdrop-filter: blur(4px);
  }
  .controls {
    width: min(30vw, 190px);
    min-width: 150px;
    margin-top: 0;
    background: var(--panel);
    border-radius: 16px;
    padding: 22px 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .vslider-row {
    display: flex;
    flex-direction: row;
    gap: 14px;
    margin-bottom: 22px;
  }
  .vslider-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  .vlabel {
    font-size: 11px;
    color: var(--sub);
    font-weight: 700;
    letter-spacing: 0.04em;
  }
  .vslider-wrap .val {
    font-size: 12px;
    color: var(--text);
    font-weight: 600;
  }
  .vtrack {
    height: 494px;
    width: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  input[type="range"] {
    -webkit-appearance: none;
    height: 21px;
    border-radius: 999px;
    outline: none;
  }
  .vtrack input[type="range"] {
    width: 494px;
    flex-shrink: 0;
    transform: rotate(-90deg);
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent2);
    cursor: pointer;
  }
  .swatch {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.15);
  }
  button {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 10px;
  }
  button.secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--sub);
  }
  #resultBox {
    display: none;
    width: min(94vw, 960px);
    margin-top: 16px;
    background: var(--panel);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
  }
  #scoreNum {
    font-size: 44px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 4px 0;
  }
  .compare {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 14px 0;
  }
  .compare div { text-align: center; }
  .compare .swatch { width: 56px; height: 56px; margin: 0 auto 6px; }
  .compare .fullimg {
    max-height: 62vh;
    max-width: 42vw;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    display: block;
    margin: 0 auto 6px;
    background: var(--panel);
  }
  .compare .lbl { font-size: 11px; color: var(--sub); }
  #deltaLine { font-size: 12px; color: var(--sub); margin-bottom: 14px; }

  input[type="range"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  /* ---------- 시작 화면 ---------- */
  #startScreen {
    width: min(94vw, 900px);
    margin: 6vh auto 0;
    text-align: center;
  }
  #logo {
    display: block;
    width: min(42vw, 228px);
    margin: 0 auto 6px;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.45));
  }
  #startScreen .title {
    font-size: 34px;
    margin-bottom: 34px;
    letter-spacing: -0.03em;
  }
  .step-label {
    color: var(--sub);
    font-size: 14px;
    margin: 0 0 16px;
  }
  #categoryList, #countList {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 22px;
  }
  .cat-btn {
    width: auto;
    min-width: 240px;
    padding: 20px 22px 18px;
    font-size: 20px;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform 0.15s ease;
  }
  .cat-btn:hover { transform: translateY(-3px); }
  .cat-thumb {
    width: 150px;
    height: 150px;
    object-fit: contain;
    border-radius: 14px;
    background: rgba(255,255,255,0.9);
    margin-bottom: 10px;
    padding: 6px;
  }
  .cat-btn .cat-name {
    font-weight: 800;
    letter-spacing: -0.02em;
  }
  .cat-btn .cat-count {
    display: block;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 2px;
  }
  .count-btn {
    width: auto;
    min-width: 92px;
    padding: 15px 20px;
    margin: 0;
  }
  #backBtn { width: auto; padding: 10px 18px; font-size: 13px; }

  /* ---------- 게임 화면 로고 / 진행도 ---------- */
  .game-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  .mini-logo { height: 34px; width: auto; }

  .stage-col { display: flex; flex-direction: column; }
  .stage-col .stage { margin-top: auto; margin-bottom: auto; }   /* 작은 그림도 슬라이더 세로 중앙에 */
  .panel-head {
    font-size: 13px;
    font-weight: 700;
    color: var(--sub);
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    text-align: center;
    min-height: 18px;
  }

  /* ---------- 최종 점수 화면 ---------- */
  #finalScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 6vw, 70px);
    flex-wrap: wrap;
    width: min(92vw, 780px);
    margin: 10vh auto 0;
    background: var(--panel);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  }
  .final-left { text-align: center; }
  .final-logo { width: min(38vw, 200px); display: block; margin: 0 auto 10px; }
  .final-label { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
  .final-right { text-align: center; }
  #finalScore {
    font-size: 76px;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .final-sub { font-size: 13px; color: var(--sub); margin: 10px 0 18px; }
  #homeBtn { width: auto; padding: 11px 22px; font-size: 13px; }
