/* 색깔 반응 테스트 — 밝은 크림 배경 + 캔디 컬러, 통통 튀는 느낌 */
:root {
  --bg: #fff6ea;
  --ink: #2b1d33;
  --sub: #7d6a85;
  --red: #ff4d5e;
  --blue: #3d7bff;
  --green: #22c26a;
  --yellow: #ffc23a;
  --card: #fff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Jua", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(40% 30% at 8% 12%, rgba(255, 77, 94, 0.14), transparent 70%),
    radial-gradient(40% 30% at 94% 20%, rgba(61, 123, 255, 0.14), transparent 70%),
    radial-gradient(45% 30% at 10% 92%, rgba(34, 194, 106, 0.14), transparent 70%),
    radial-gradient(45% 30% at 92% 88%, rgba(255, 194, 58, 0.18), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

body.is-play {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.stage {
  position: relative;
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(64px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

.c-red { background: var(--red); }
.c-blue { background: var(--blue); }
.c-green { background: var(--green); }
.c-yellow { background: var(--yellow); }

/* ---------- 시작 ---------- */
.title {
  min-height: calc(100dvh - 100px);
  justify-content: center;
}

.swatches {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.swatches i {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  box-shadow: 0 5px 0 rgba(43, 29, 51, 0.18);
  animation: hop 1.6s ease-in-out infinite;
}

.swatches i:nth-child(2) { animation-delay: 0.15s; }
.swatches i:nth-child(3) { animation-delay: 0.3s; }
.swatches i:nth-child(4) { animation-delay: 0.45s; }

@keyframes hop {
  0%, 60%, 100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-12px) rotate(-6deg); }
}

.kicker {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: #fff;
  background: var(--ink);
}

.title h1 {
  margin: 14px 0 0;
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-weight: 400;
  font-size: clamp(38px, 11vw, 52px);
  line-height: 1.05;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--red), var(--yellow) 35%, var(--green) 65%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 10px 0 0;
  font-size: 20px;
}

.sub b {
  color: var(--blue);
}

.hint {
  margin: 4px 0 26px;
  font-size: 15px;
  color: var(--sub);
}

.go {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: min(78vw, 300px);
  min-height: 84px;
  border-radius: 28px;
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-size: 40px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 0 #000, 0 18px 40px rgba(43, 29, 51, 0.25);
  touch-action: manipulation;
}

.go:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #000;
}

.title-stat {
  margin: 20px 0 0;
  min-height: 1.3em;
  font-size: 15px;
  color: var(--sub);
}

.title-stat b {
  color: var(--ink);
}

/* ---------- 플레이 ---------- */
.play {
  position: fixed;
  inset: 0;
  padding: max(64px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  justify-content: space-between;
  width: min(480px, 100%);
  margin: 0 auto;
}

.play-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dots {
  display: flex;
  gap: 5px;
}

.dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(43, 29, 51, 0.12);
  transition: background 0.2s, transform 0.2s;
}

.dots i.now { transform: scale(1.3); background: var(--ink); }
.dots i.ok { background: var(--green); }
.dots i.bad { background: var(--red); }

.round-label {
  margin: 0;
  font-size: 18px;
  color: var(--sub);
}

.round-label b {
  font-size: 26px;
  color: var(--ink);
}

.rule {
  margin: 6px 0 0;
  min-height: 1.4em;
  font-size: 19px;
  color: var(--sub);
}

.rule.alert {
  color: var(--red);
  animation: pulse 0.6s ease 2;
}

@keyframes pulse {
  50% { transform: scale(1.12); }
}

.blob-wrap {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
}

.blob {
  width: min(58vw, 36vh, 240px);
  aspect-ratio: 1;
  border-radius: 38% 42% 40% 44% / 42% 38% 44% 40%;
  display: grid;
  place-items: center;
  background: #ece3d8;
  box-shadow: inset 0 -14px 0 rgba(0, 0, 0, 0.12), 0 18px 40px rgba(43, 29, 51, 0.18);
  transition: transform 0.12s ease;
}

.blob.wait {
  background: #ece3d8;
  animation: breathe 1.3s ease-in-out infinite;
}

.blob.fade {
  background: #d9cfc3 !important;
}

.blob.fade::after {
  content: "?";
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-size: 80px;
  color: rgba(43, 29, 51, 0.35);
}

.blob.fade .blob-word {
  display: none;
}

@keyframes breathe {
  50% { transform: scale(0.94); }
}

.blob-word {
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-size: clamp(34px, 11vw, 52px);
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.blob.hit {
  animation: popok 0.3s ease;
}

@keyframes popok {
  40% { transform: scale(1.15); }
}

.blob.miss {
  animation: shake 0.3s;
}

@keyframes shake {
  25% { transform: translateX(-10px) rotate(-3deg); }
  75% { transform: translateX(10px) rotate(3deg); }
}

.float {
  position: absolute;
  top: 8%;
  margin: 0;
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-size: 30px;
  opacity: 0;
  pointer-events: none;
}

.float.show {
  animation: floatup 0.55s ease-out;
}

.float.good { color: var(--green); }
.float.bad { color: var(--red); }

@keyframes floatup {
  0% { opacity: 0; transform: translateY(10px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

.pads {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 10px;
}

.pad {
  position: relative;
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: clamp(78px, 13vh, 104px);
  border-radius: 24px;
  font-family: "Jua", sans-serif;
  font-size: 24px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.16), 0 6px 0 rgba(43, 29, 51, 0.2);
  touch-action: manipulation;
  transition: transform 0.08s ease;
}

.pad.c-yellow {
  color: #5a3d00;
  text-shadow: none;
}

.pad:active,
.pad.down {
  transform: translateY(4px) scale(0.98);
}

.pad.wrong {
  animation: shake 0.3s;
}

.pad kbd {
  position: absolute;
  top: 8px;
  left: 12px;
  font-family: inherit;
  font-size: 13px;
  opacity: 0.7;
}

@media (hover: none) {
  .pad kbd {
    display: none;
  }
}

/* ---------- 결과 ---------- */
.result {
  padding-top: 6px;
}

.result-q {
  margin: 0;
  font-size: 19px;
  color: var(--sub);
}

.result-avg {
  margin: 6px 0 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  line-height: 1;
}

.bolt {
  font-size: 54px;
  align-self: center;
}

.result-avg b {
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-weight: 400;
  font-size: clamp(72px, 22vw, 104px);
  letter-spacing: -2px;
  background: linear-gradient(180deg, var(--blue), #7a4dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-avg .unit {
  font-size: 28px;
  color: var(--sub);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(360px, 100%);
  margin-top: 14px;
}

.result-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(43, 29, 51, 0.08);
}

.result-stats span {
  font-size: 12px;
  color: var(--sub);
}

.result-stats b {
  font-weight: 400;
  font-size: 20px;
}

.result-line {
  margin: 12px 0 0;
  font-size: 17px;
}

.newbest {
  margin: 8px 0 0;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 16px;
  background: var(--yellow);
}

#record-panel {
  width: 100%;
  margin-top: 16px;
  text-align: left;
}

.rc {
  --rc-accent: var(--blue);
  --rc-accent-ink: #fff;
  --rc-card: #fff;
  --rc-line: rgba(43, 29, 51, 0.1);
  --rc-ink: var(--ink);
  --rc-sub: var(--sub);
}

.rc .rc-btn {
  box-shadow: 0 4px 0 rgba(43, 29, 51, 0.08);
}

.rc .rc-retry {
  background: linear-gradient(90deg, var(--red), #ff7a45);
  box-shadow: 0 6px 0 #c9303f;
}

.rc-rank .today-rank-form input {
  border-color: rgba(43, 29, 51, 0.15);
}

.home-link {
  margin: 22px 0 6px;
  font-size: 15px;
  color: var(--sub);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .swatches i,
  .blob.wait {
    animation: none;
  }
}
