* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "IBM Plex Sans KR", system-ui, -apple-system, sans-serif;
  background: #0f1113;
  color: #e9e6e1;
  display: flex;
  justify-content: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 82% at 50% 4%, #1b1c1e 0%, #141618 58%, #0f1113 100%);
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.hint {
  position: absolute;
  top: clamp(14px, 4vh, 32px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: #cfd2d5;
  background: rgba(20, 22, 24, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.07);
  white-space: nowrap;
  z-index: 4;
  animation: hintIn 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.hint[hidden] {
  display: none;
}

@keyframes hintIn {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.camwrap {
  position: absolute;
  top: clamp(12px, 3vw, 22px);
  right: clamp(12px, 3vw, 22px);
  width: clamp(76px, 16%, 150px);
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #07080a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.45s ease,
    transform 0.45s cubic-bezier(0.2, 0.9, 0.2, 1),
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  z-index: 3;
}

.camwrap.on {
  opacity: 1;
  transform: none;
}

.camwrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform: scaleX(-1);
}

.camwrap[data-flash="0"] {
  border-color: #cf8a52;
  box-shadow: 0 0 0 2px rgba(207, 138, 82, 0.35);
}

.camwrap[data-flash="1"] {
  border-color: #4f9e97;
  box-shadow: 0 0 0 2px rgba(79, 158, 151, 0.35);
}

.camwrap[data-flash="miss"] {
  border-color: #a86a6a;
  box-shadow: 0 0 0 2px rgba(168, 106, 106, 0.3);
}

.hud {
  position: absolute;
  top: clamp(12px, 3vw, 22px);
  left: clamp(14px, 3.4vw, 30px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.score {
  font-size: clamp(30px, 5.6vw, 46px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #f2efe9;
}

.hud-row {
  display: flex;
  gap: 14px;
}

.tag {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: #7c8089;
}

.tag b {
  display: inline-block;
  margin-left: 5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #d5d2cc;
}

.tag b.low {
  color: #d79c9c;
}

.pop {
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.24);
  }
  100% {
    transform: scale(1);
  }
}

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 26px);
  background: rgba(10, 12, 15, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

button {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #e8e6e2;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.12s ease,
    box-shadow 0.25s ease,
    opacity 0.2s ease;
}

button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button.ghost.on {
  border-color: rgba(95, 184, 176, 0.45);
  color: #9ddcd4;
}

button:disabled {
  opacity: 0.32;
  cursor: default;
}

.status {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: #8b8f98;
  transition: color 0.25s ease;
}

.status[data-kind="error"] {
  color: #e08a8a;
}

.status[data-kind="ok"] {
  color: #8fc9bd;
}

/* ---------- 게임 끝 ---------- */

.over {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.4vh, 12px);
  padding: 20px;
  text-align: center;
  background: rgba(13, 14, 16, 0.86);
  animation: overIn 0.4s ease;
}

.over[hidden] {
  display: none;
}

.over-label {
  margin: 0;
  font-family: "Gowun Batang", "Nanum Myeongjo", serif;
  font-size: clamp(19px, 3.2vw, 26px);
  letter-spacing: 0.22em;
  color: #cf8a52;
}

.over-score {
  font-size: clamp(46px, 9.5vw, 84px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #f3f0eb;
}

.over-note {
  margin: 0;
  font-size: 12.5px;
  color: #8b8f98;
}

@keyframes overIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------- 인트로 ---------- */

.intro {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.6vh, 24px);
  padding: 24px;
  text-align: center;
  background: rgba(13, 14, 16, 0.9);
  backdrop-filter: blur(8px);
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.intro.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro.is-hidden button.start {
  animation-play-state: paused;
}

.intro-glow {
  position: absolute;
  inset: -15%;
  background:
    radial-gradient(closest-side, rgba(207, 138, 82, 0.13), transparent 70%),
    radial-gradient(closest-side, rgba(79, 158, 151, 0.11), transparent 70%);
  background-position: 28% 38%, 72% 62%;
  background-size: 58% 58%, 52% 52%;
  background-repeat: no-repeat;
  animation: drift 14s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(-3%, -2%, 0) scale(1);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.1);
  }
}

.intro-eyes {
  position: relative;
  display: flex;
  gap: clamp(26px, 5vw, 44px);
}

.ieye {
  position: relative;
  width: clamp(52px, 8vw, 78px);
  height: clamp(28px, 4.3vw, 42px);
  border: 2px solid rgba(233, 230, 225, 0.55);
  border-radius: 50% / 62%;
  animation: blinkA 4.8s ease-in-out infinite;
}

.ieye:nth-child(2) {
  animation-name: blinkB;
}

.ieye i {
  position: absolute;
  inset: 0;
  margin: auto;
  width: clamp(10px, 1.6vw, 15px);
  height: clamp(10px, 1.6vw, 15px);
  border-radius: 50%;
  background: #e8e6e2;
  animation: look 4.8s ease-in-out infinite;
}

@keyframes blinkA {
  0%, 84%, 100% {
    transform: scaleY(1);
  }
  89% {
    transform: scaleY(0.08);
  }
}

@keyframes blinkB {
  0%, 86%, 100% {
    transform: scaleY(1);
  }
  92% {
    transform: scaleY(0.08);
  }
}

@keyframes look {
  0%, 100% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
}

.intro-title {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  margin: 0;
  font-family: "Gowun Batang", "Nanum Myeongjo", serif;
  font-size: clamp(46px, 10.5vw, 96px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: #f3f0eb;
  text-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.intro-title span,
.intro-title em {
  display: inline-block;
  animation: rise 0.75s cubic-bezier(0.2, 0.9, 0.2, 1) backwards;
  animation-delay: calc(var(--i) * 0.09s);
}

.intro-title em {
  margin-left: 0.24em;
  font-style: normal;
  font-weight: 400;
  font-size: 0.62em;
  letter-spacing: 0.06em;
  color: #cf8a52;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(4deg);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes startGlow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(207, 138, 82, 0);
  }
  50% {
    box-shadow: 0 0 26px -6px rgba(207, 138, 82, 0.45);
  }
}

.intro-sub {
  position: relative;
  margin: 0;
  font-size: clamp(13.5px, 2.7vw, 16px);
  color: #9ea4aa;
  letter-spacing: 0.01em;
  animation: rise 0.75s cubic-bezier(0.2, 0.9, 0.2, 1) 0.4s backwards;
}

button.start {
  position: relative;
  margin-top: 10px;
  padding: 15px 58px;
  font-size: clamp(15px, 2.6vw, 17px);
  font-weight: 600;
  letter-spacing: 0.08em;
  border-radius: 999px;
  border: 1px solid rgba(207, 138, 82, 0.5);
  background: linear-gradient(180deg, rgba(207, 138, 82, 0.24), rgba(207, 138, 82, 0.09));
  color: #f4e3d1;
  animation:
    rise 0.75s cubic-bezier(0.2, 0.9, 0.2, 1) 0.48s backwards,
    startGlow 3.4s ease-in-out 1.4s infinite;
}

button.start:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(207, 138, 82, 0.36), rgba(207, 138, 82, 0.16));
  border-color: rgba(207, 138, 82, 0.75);
  box-shadow: 0 0 24px -8px rgba(207, 138, 82, 0.6);
}

button.start:active:not(:disabled) {
  transform: scale(0.98);
}

.intro-note {
  position: relative;
  margin: 0;
  font-size: 11.5px;
  color: #6b7075;
  letter-spacing: 0.02em;
  animation: rise 0.75s cubic-bezier(0.2, 0.9, 0.2, 1) 0.56s backwards;
}

@media (max-height: 540px) {
  .intro {
    gap: 10px;
  }

  .intro-eyes {
    display: none;
  }

  .intro-title {
    font-size: clamp(32px, 7vw, 52px);
  }

  .intro-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 루캣 결제 ---------- */

.bar {
  flex-wrap: wrap;
}

.bar-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.store-note {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: #8b8f98;
}

.store-note[data-kind="ok"] {
  color: #8fc9bd;
}

.store-note[data-kind="error"] {
  color: #e08a8a;
}

.lucat-info {
  align-self: center;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #a9adb4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.revive-btn {
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 999px;
  border: 1px solid rgba(79, 158, 151, 0.55);
  background: linear-gradient(180deg, rgba(79, 158, 151, 0.3), rgba(79, 158, 151, 0.1));
  color: #cdeee9;
}

.revive-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(79, 158, 151, 0.42), rgba(79, 158, 151, 0.18));
  border-color: rgba(79, 158, 151, 0.8);
  box-shadow: 0 0 22px -8px rgba(79, 158, 151, 0.7);
}

.revive-btn[hidden] {
  display: none;
}

/* ---------- 상점 ---------- */

.hud-fx {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: #8fc9bd;
}

.hud-fx[hidden] {
  display: none;
}

.shop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 28px);
  background: rgba(9, 10, 12, 0.74);
}

.shop[hidden] {
  display: none;
}

.shop-panel {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(14px, 2.4vw, 20px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #14161a;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}

.shop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.shop-title {
  margin: 0;
  font-family: "Gowun Batang", "Nanum Myeongjo", serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #f0ede8;
}

.shop-head button {
  margin-left: auto;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.shop-item-main {
  min-width: 0;
}

.shop-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f0ede8;
}

.shop-desc {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: #8b8f98;
}

.shop-own {
  margin: 6px 0 0;
  font-size: 12px;
  color: #a9adb4;
}

.shop-own b {
  color: #e8bb92;
  font-variant-numeric: tabular-nums;
}

.shop-item-side {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.shop-price {
  font-size: 12px;
  color: #cf8a52;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shop-buy {
  border-color: rgba(207, 138, 82, 0.45);
  background: rgba(207, 138, 82, 0.14);
  color: #f4e3d1;
}

.shop-buy:hover:not(:disabled) {
  border-color: rgba(207, 138, 82, 0.75);
  background: rgba(207, 138, 82, 0.24);
}

.shop-note {
  min-height: 16px;
  margin: 12px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: #8b8f98;
}

.shop-note[data-kind="ok"] {
  color: #8fc9bd;
}

.shop-note[data-kind="error"] {
  color: #e08a8a;
}

@media (max-width: 460px) {
  .shop-item {
    flex-direction: column;
    align-items: stretch;
  }

  .shop-item-side {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
}
