/* ============================================================
   GROUND BOUNCE — 바닥 튕기기
   mobile first / 100dvh / neon arcade
   ============================================================ */

:root {
  --cyan: #3ff2ff;
  --orange: #ffa23a;
  --magenta: #ff2ec4;
  --red: #ff3b5c;
  --ink: #e9f6ff;
  --dim: #8fa6c8;
  --panel: rgba(10, 12, 30, 0.55);
  --tension: #3ff2ff;
  --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: #04040c;
  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;
}

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

/* ---------------- HUD ---------------- */

#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
  padding: calc(var(--safe-t) + 7px) 12px 14px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(6, 5, 20, 0.92) 0%,
    rgba(8, 6, 24, 0.66) 62%,
    rgba(8, 6, 24, 0) 100%
  );
}

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

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

.hud-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--dim);
  font-weight: 700;
  opacity: 0.85;
}

.hud-value {
  font-family: ui-monospace, "SF Mono", "DIN Alternate", Menlo, "Liberation Mono", "DejaVu Sans Mono", monospace;
  font-size: 21px;
  line-height: 1;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(63, 242, 255, 0.85), 0 0 22px rgba(63, 242, 255, 0.35);
  font-variant-numeric: tabular-nums;
}

.hud-value.combo {
  color: var(--magenta);
  text-shadow: 0 0 10px rgba(255, 46, 196, 0.9), 0 0 24px rgba(255, 46, 196, 0.4);
}

.hud-value.pop {
  animation: valuePop 0.24s ease-out;
}

@keyframes valuePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 1px;
}

.hud-wave {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(63, 242, 255, 0.6);
  white-space: nowrap;
}

.hearts {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 14px;
}

.heart {
  width: 14px;
  height: 13px;
  display: block;
  background: #ff3b5c;
  clip-path: polygon(50% 100%, 6% 46%, 6% 20%, 26% 4%, 50% 20%, 74% 4%, 94% 20%, 94% 46%);
  box-shadow: 0 0 10px rgba(255, 59, 92, 0.9);
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.heart.lost {
  background: rgba(120, 130, 160, 0.28);
  box-shadow: none;
  transform: scale(0.86);
}

/* ---------------- 보스 바 ---------------- */

.boss-bar {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-t) + 112px);
  transform: translateX(-50%) translateY(-8px);
  width: min(78%, 420px);
  z-index: 4;
  padding: 5px 9px 6px;
  border-radius: 11px;
  background: rgba(8, 4, 20, 0.62);
  border: 1px solid rgba(196, 107, 255, 0.22);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.boss-bar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.boss-name {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: #f0c6ff;
  margin-bottom: 3px;
  text-shadow: 0 0 8px rgba(196, 107, 255, 0.8);
}

.boss-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(80, 30, 120, 0.5);
  border: 1px solid rgba(196, 107, 255, 0.35);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #8b3bff, #ff3ec8 60%, #ff8a3a);
  box-shadow: 0 0 12px rgba(255, 62, 200, 0.8);
  transform-origin: left center;
  transition: transform 0.22s ease-out;
}

/* ---------------- 힌트 ---------------- */

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 66px);
  transform: translateX(-50%);
  z-index: 4;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: -0.01em;
  color: #cfe9ff;
  background: rgba(8, 12, 32, 0.6);
  border: 1px solid rgba(63, 242, 255, 0.22);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.hint b {
  color: var(--cyan);
}

.hint.show {
  opacity: 1;
  animation: hintPulse 1.6s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(63, 242, 255, 0); }
  50% { box-shadow: 0 0 18px rgba(63, 242, 255, 0.3); }
}

/* ---------------- 하단 바 ---------------- */

#bottomBar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px calc(var(--safe-b) + 8px);
  pointer-events: none;
  background: linear-gradient(0deg, rgba(4, 4, 14, 0.72), rgba(4, 4, 14, 0));
}

.tension {
  flex: 1;
  min-width: 0;
}

.tension-head {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #8fa6c8;
  margin-bottom: 3px;
}

.tension-head span:last-child {
  color: var(--tension);
  font-family: ui-monospace, Menlo, "Liberation Mono", "DejaVu Sans Mono", monospace;
  letter-spacing: 0.04em;
  transition: color 0.12s linear;
}

.tension-track {
  position: relative;
  height: 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.tension-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, #1e7f9a, var(--tension) 70%, #ffffff 100%);
  box-shadow: 0 0 14px var(--tension);
  transition: transform 0.05s linear, background 0.14s linear;
}

.tension-ticks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.32) 0,
    rgba(0, 0, 0, 0.32) 1px,
    transparent 1px,
    transparent 10%
  );
  pointer-events: none;
  opacity: 0.55;
}

#bottomBar.overload .tension-track {
  border-color: var(--red);
  animation: warnFlash 0.18s steps(2, end) infinite;
}

@keyframes warnFlash {
  0% { box-shadow: 0 0 0 rgba(255, 59, 92, 0), inset 0 0 12px rgba(255, 59, 92, 0.2); }
  100% { box-shadow: 0 0 20px rgba(255, 59, 92, 0.7), inset 0 0 18px rgba(255, 59, 92, 0.5); }
}

.mute {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(63, 242, 255, 0.24);
  background: rgba(10, 14, 34, 0.72);
  color: #cfe9ff;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.mute.off {
  opacity: 0.45;
  border-color: rgba(255, 255, 255, 0.12);
}

/* ---------------- 오버레이 ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-t) + 18px) 20px calc(var(--safe-b) + 18px);
  background:
    radial-gradient(120% 80% at 50% 8%, rgba(255, 46, 196, 0.16), transparent 60%),
    radial-gradient(120% 70% at 50% 100%, rgba(63, 242, 255, 0.16), transparent 62%),
    rgba(3, 3, 12, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

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

.ov-inner {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  animation: ovIn 0.4s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

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

.ov-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: var(--cyan);
  padding: 5px 11px;
  border: 1px solid rgba(63, 242, 255, 0.34);
  border-radius: 999px;
  background: rgba(63, 242, 255, 0.07);
}

.ov-badge.danger {
  color: #ff8fa5;
  border-color: rgba(255, 59, 92, 0.45);
  background: rgba(255, 59, 92, 0.1);
}

.ov-logo {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, "Liberation Sans", Arial, system-ui,
    sans-serif;
  font-size: clamp(38px, 12.5vw, 56px);
  line-height: 0.86;
  font-weight: 900;
  letter-spacing: -0.045em;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 8%, #7ef4ff 52%, #2fb6ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(63, 242, 255, 0.55));
}

.ov-logo span {
  background: linear-gradient(180deg, #ffe9ff 0%, #ff5bd3 55%, #a13bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 46, 196, 0.5));
}

.ov-sub {
  margin: -4px 0 0;
  font-size: 13px;
  letter-spacing: 0.34em;
  color: #b9d6f2;
  opacity: 0.9;
}

.ov-steps {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  margin-top: 2px;
}

.ov-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.ov-step b {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #04040c;
  background: linear-gradient(135deg, #7ef4ff, #3ff2ff);
  box-shadow: 0 0 10px rgba(63, 242, 255, 0.6);
}

.ov-step p {
  margin: 0;
  font-size: 12.5px;
  color: #d5e8fb;
  letter-spacing: -0.01em;
}

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

.ov-btn {
  margin-top: 4px;
  width: 100%;
  padding: 15px 18px;
  border: none;
  border-radius: 15px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #04040c;
  background: linear-gradient(135deg, #9ff9ff 0%, #3ff2ff 45%, #2fd0ff 100%);
  box-shadow: 0 6px 26px rgba(63, 242, 255, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  animation: btnPulse 2.2s ease-in-out infinite;
}

.ov-btn:active {
  transform: scale(0.975);
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 6px 26px rgba(63, 242, 255, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
  50% { box-shadow: 0 6px 38px rgba(63, 242, 255, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
}

.ov-best {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #8fa6c8;
}

.ov-best span {
  color: #ffffff;
  font-family: ui-monospace, Menlo, "Liberation Mono", "DejaVu Sans Mono", monospace;
  font-weight: 700;
  margin-left: 4px;
}

.ov-over {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, "Liberation Sans", Arial, system-ui,
    sans-serif;
  font-size: clamp(34px, 11vw, 46px);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #ff8fa5 55%, #ff2e5c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 59, 92, 0.45));
}

.ov-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.ov-stats div {
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ov-stats span {
  font-size: 8px;
  letter-spacing: 0.16em;
  color: #8fa6c8;
  font-weight: 700;
}

.ov-stats b {
  font-family: ui-monospace, Menlo, "Liberation Mono", "DejaVu Sans Mono", monospace;
  font-size: 20px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.ov-record {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #8fa6c8;
}

.ov-record span {
  color: var(--cyan);
  font-weight: 700;
  margin-left: 4px;
}

.ov-record.new span {
  color: #ffd166;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.7);
}

@media (max-height: 640px) {
  .ov-steps { display: none; }
  .ov-inner { gap: 10px; }
  .hud-value { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .ov-btn, .hint.show { animation: none; }
}
