/* ============================================================
   SPIN TOP — 팽이 스핀
   mobile first / 100dvh / lacquer & brass arcade
   ============================================================ */

:root {
  --gold: #f6c65b;
  --gold-hi: #ffe9b0;
  --brass: #c8932f;
  --teal: #3fe6cf;
  --cyan: #9ff6ff;
  --red: #ff4d61;
  --orange: #ff9a4d;
  --ink: #f7f1e3;
  --dim: #8fa3b8;
  --bg: #07090e;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans CJK KR", "Liberation Sans", "Helvetica Neue",
    system-ui, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(120% 80% at 50% 30%, #0d1824 0%, #06090f 70%);
}

#stage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ================= HUD ================= */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(var(--safe-t) + 10px) 16px 0;
  pointer-events: none;
  z-index: 3;
}

.hud-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 84px;
}

.hud-block.right {
  align-items: flex-end;
  text-align: right;
}

.hud-block .lab {
  font-size: 9px;
  letter-spacing: 1.8px;
  color: #7d8ea3;
  font-weight: 700;
}

.hud-block .val {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  line-height: 1.05;
}

.hud-block .val.small {
  font-size: 14px;
  color: #b9c7d4;
  font-weight: 800;
}

.hud-wave {
  padding: 5px 12px;
  border: 1px solid rgba(246, 198, 91, 0.3);
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.6);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gold);
  font-weight: 800;
  white-space: nowrap;
}

.hud-wave b {
  font-size: 12px;
  margin-left: 2px;
}

.charge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  height: 14px;
}

.charge-track {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.charge-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3fe6cf, #f6c65b);
  box-shadow: 0 0 10px rgba(246, 198, 91, 0.5);
  transition: width 0.1s linear;
}

.charge-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 23px,
    rgba(0, 0, 0, 0.45) 23px 25px
  );
  pointer-events: none;
}

.charge-lab {
  font-size: 8.5px;
  letter-spacing: 1.7px;
  color: #8ea0b4;
  font-weight: 800;
  min-width: 62px;
  text-align: right;
}

.charge.od .charge-fill {
  background: linear-gradient(90deg, #ff9a4d, #ff4d61);
  box-shadow: 0 0 14px rgba(255, 77, 97, 0.6);
}

.charge.od .charge-lab {
  color: var(--orange);
}

/* ================= COMBO ================= */
.combo {
  position: absolute;
  right: 20px;
  bottom: calc(var(--safe-b) + 194px);
  display: flex;
  align-items: baseline;
  gap: 4px;
  opacity: 0;
  transform: translateY(-4px) scale(0.94);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 3;
  pointer-events: none;
}

.combo.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.combo .cnum {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(246, 198, 91, 0.55), 0 2px 6px rgba(0, 0, 0, 0.8);
  line-height: 1;
}

.combo .cmul {
  font-size: 12px;
  font-weight: 900;
  color: var(--teal);
  letter-spacing: 0.4px;
}

.combo.pop .cnum {
  animation: comboPop 0.18s ease-out;
}

@keyframes comboPop {
  0% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

/* ================= 하단 패널 ================= */
#panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px calc(var(--safe-b) + 12px);
  background: linear-gradient(
    180deg,
    rgba(7, 10, 15, 0) 0%,
    rgba(7, 10, 15, 0.72) 22%,
    rgba(6, 9, 14, 0.96) 55%,
    #06090e 100%
  );
  z-index: 4;
  pointer-events: auto;
}

.spin-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spin-lab {
  font-size: 10px;
  letter-spacing: 2.2px;
  color: #8fa3b8;
  font-weight: 800;
  width: 36px;
  flex: 0 0 auto;
}

.spin-track {
  position: relative;
  flex: 1;
  height: 26px;
  border-radius: 9px;
  background: #0b131c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.spin-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 70%;
  border-radius: 8px;
  background: linear-gradient(90deg, #ff4d61 0%, #ff9a4d 22%, #f6c65b 55%, #9ff6ff 100%);
  box-shadow: 0 0 16px rgba(246, 198, 91, 0.35);
  transition: width 0.08s linear;
}

.spin-seg {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 17px,
    rgba(0, 0, 0, 0.4) 17px 19px
  );
  pointer-events: none;
}

.spin-num {
  width: 46px;
  flex: 0 0 auto;
  text-align: right;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  color: var(--ink);
  line-height: 1;
}

.spin-track.low {
  border-color: rgba(255, 77, 97, 0.5);
  animation: lowPulse 0.46s infinite alternate;
}

.spin-num.low {
  color: var(--red);
}

@keyframes lowPulse {
  0% {
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 0 rgba(255, 77, 97, 0);
  }
  100% {
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 18px rgba(255, 77, 97, 0.55);
  }
}

.spin-track.hot {
  border-color: rgba(159, 246, 255, 0.45);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 16px rgba(159, 246, 255, 0.3);
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.grind {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9.5px;
  letter-spacing: 1.6px;
  color: #7e93a8;
  font-weight: 800;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.grind.on {
  opacity: 1;
}

.grind b {
  color: var(--teal);
  font-size: 12px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.gbar {
  width: 56px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: block;
}

.gbar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1e7f78, #3fe6cf);
  transition: width 0.08s linear;
}

.panel-btns {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font-size: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
}

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 150px);
  transform: translateX(-50%);
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.2px;
  color: rgba(226, 238, 248, 0.6);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.8s;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.hint b {
  color: var(--gold);
  font-weight: 800;
}

.hint.hide {
  opacity: 0;
}

/* ================= 오버레이 ================= */
.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(58% 38% at 50% 24%, rgba(246, 198, 91, 0.14), rgba(246, 198, 91, 0) 72%),
    radial-gradient(62% 40% at 50% 92%, rgba(63, 230, 207, 0.09), rgba(63, 230, 207, 0) 72%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 18px) 20px calc(var(--safe-b) + 18px);
  background: radial-gradient(90% 70% at 50% 40%, rgba(10, 16, 24, 0.6), rgba(4, 6, 10, 0.9));
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 10;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.ov-inner {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 22px 18px 20px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(24, 34, 46, 0.94), rgba(8, 12, 18, 0.97));
  border: 1px solid rgba(246, 198, 91, 0.22);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.2, 1.2);
}

.overlay.show .ov-inner {
  transform: translateY(0) scale(1);
}

#titleScreen .ov-inner::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 54px;
  width: 260px;
  height: 260px;
  margin-left: -130px;
  border-radius: 50%;
  border: 1px dashed rgba(246, 198, 91, 0.18);
  animation: orbit 26s linear infinite;
  pointer-events: none;
}

#titleScreen .ov-inner::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 84px;
  width: 190px;
  height: 190px;
  margin-left: -95px;
  border-radius: 50%;
  border: 1px solid rgba(63, 230, 207, 0.09);
  pointer-events: none;
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

.ov-badge {
  position: relative;
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 8.5px;
  letter-spacing: 2.2px;
  font-weight: 800;
  color: var(--gold);
  border: 1px solid rgba(246, 198, 91, 0.35);
  background: rgba(246, 198, 91, 0.08);
}

.ov-badge.danger {
  color: #ff8794;
  border-color: rgba(255, 77, 97, 0.42);
  background: rgba(255, 77, 97, 0.1);
}

.ov-logo {
  margin: 16px 0 6px;
  font-size: 58px;
  line-height: 0.86;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--ink);
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.7);
}

.ov-logo span {
  display: block;
  font-size: 42px;
  letter-spacing: 13px;
  margin-left: 6px;
  background: linear-gradient(180deg, #fff2c9 0%, #f6c65b 48%, #b97d1c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(246, 198, 91, 0.45));
}

.ov-sub {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: #93a6ba;
}

.ov-steps {
  display: grid;
  gap: 7px;
  margin: 17px 0 16px;
  text-align: left;
}

.ov-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.ov-step b {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: var(--gold);
  background: rgba(246, 198, 91, 0.13);
  border: 1px solid rgba(246, 198, 91, 0.28);
}

.ov-step p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: #c9d6e2;
  font-weight: 500;
}

.ov-step i {
  font-style: normal;
  color: var(--gold);
  font-weight: 800;
}

.ov-btn {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe08c 0%, #f6c65b 45%, #d99b2c 100%);
  color: #241703;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.2px;
  font-family: inherit;
  box-shadow: 0 10px 26px rgba(246, 198, 91, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  animation: btnBreath 2.6s ease-in-out infinite;
}

.ov-btn:active {
  transform: translateY(1px) scale(0.995);
}

@keyframes btnBreath {
  0%,
  100% {
    box-shadow: 0 10px 26px rgba(246, 198, 91, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  }
  50% {
    box-shadow: 0 10px 34px rgba(246, 198, 91, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  }
}

.ov-btn-continue {
  margin-top: 6px;
}

.ov-btn-ghost {
  margin-top: 9px;
  padding: 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cfdbe6;
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
  animation: none;
}

.ov-best,
.ov-continue-note,
.ov-record {
  margin: 10px 0 0;
  font-size: 11px;
  color: #8ea2b6;
}

.ov-record {
  font-size: 11.5px;
}

.ov-record.hot {
  color: var(--gold);
  font-weight: 800;
}

.ov-over {
  margin: 10px 0 12px;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1;
  color: #ff5b6d;
  text-shadow: 0 0 34px rgba(255, 77, 97, 0.45);
}

.ov-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 4px;
}

.ov-stats span {
  display: block;
  font-size: 8.5px;
  letter-spacing: 1.4px;
  color: #7f93a8;
  font-weight: 700;
}

.ov-stats b {
  display: block;
  margin-top: 2px;
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.4px;
}

@media (max-height: 720px) {
  .ov-inner {
    padding: 16px 16px 15px;
  }
  .ov-logo {
    font-size: 46px;
  }
  .ov-logo span {
    font-size: 34px;
  }
  .ov-steps {
    gap: 5px;
    margin: 12px 0;
  }
  .ov-step {
    padding: 5px 8px;
  }
  .ov-btn {
    padding: 13px;
  }
}
