/* ============================================================
   LASSO BLACKHOLE — 올가미 블랙홀
   mobile first / 100dvh / neon singularity arcade
   ============================================================ */

:root {
  --cyan: #5ff4ff;
  --cyan-dim: #1fb8e8;
  --magenta: #ff7bf0;
  --violet: #b98cff;
  --gold: #ffe66b;
  --red: #ff3b5c;
  --ink: #e8f7ff;
  --dim: #8ea6c8;
  --panel: rgba(8, 16, 34, 0.62);
  --line: rgba(95, 244, 255, 0.16);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans CJK KR", "Helvetica Neue", system-ui, "Segoe UI", sans-serif;
}

* {
  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: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: #05060f;
}

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

/* 코너 비네트 (GPU 합성) */
#app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 46%, rgba(0, 0, 0, 0.18) 72%, rgba(0, 0, 0, 0.62) 100%);
}

/* 스캔라인 그레인 */
#app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.012) 0px,
    rgba(255, 255, 255, 0.012) 1px,
    rgba(0, 0, 0, 0.035) 1px,
    rgba(0, 0, 0, 0.035) 3px
  );
  opacity: 0.55;
}

/* ============================================================
   HUD
   ============================================================ */
#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

#hud.show {
  opacity: 1;
}

/* 게임오버는 배경을 더 눌러 결과에 집중시킨다 */
#overScreen {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60, 10, 24, 0.35), rgba(3, 4, 12, 0.95) 58%, rgba(2, 2, 8, 0.98)),
    linear-gradient(180deg, rgba(4, 6, 16, 0.96) 0%, rgba(3, 4, 12, 0.94) 50%, rgba(6, 2, 10, 0.96) 100%);
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 0;
}

.hud-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-block.left {
  align-items: flex-start;
}

.hud-block.center {
  align-items: center;
  flex: 1;
}

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

.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: rgba(142, 166, 200, 0.9);
  text-shadow: 0 0 10px rgba(95, 244, 255, 0.25);
  white-space: nowrap;
}

.hud-value {
  font-size: 27px;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: #f2feff;
  text-shadow: 0 0 12px rgba(95, 244, 255, 0.75), 0 0 30px rgba(95, 244, 255, 0.35);
}

.hud-value.small {
  font-size: 15px;
  text-shadow: 0 0 10px rgba(95, 244, 255, 0.5);
}

.hud-value.bump {
  animation: scoreBump 0.24s ease-out;
}

@keyframes scoreBump {
  0% { transform: scale(1.18); color: #ffffff; }
  100% { transform: scale(1); }
}

.lives {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  height: 10px;
  align-items: center;
}

.lives i {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border: 1px solid rgba(95, 244, 255, 0.35);
  background: rgba(30, 60, 90, 0.25);
  border-radius: 1.5px;
  transition: all 0.2s ease;
}

.lives i.on {
  background: linear-gradient(135deg, #d9feff, var(--cyan));
  border-color: rgba(220, 255, 255, 0.9);
  box-shadow: 0 0 10px var(--cyan), 0 0 20px rgba(95, 244, 255, 0.45);
}

.lives i.on.danger {
  background: linear-gradient(135deg, #ffd0d9, var(--red));
  border-color: #ffd0d9;
  box-shadow: 0 0 12px var(--red);
  animation: pipPulse 0.9s ease-in-out infinite;
}

@keyframes pipPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 음소거 */
.mute {
  pointer-events: auto;
  margin-top: 4px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--ink);
  background: rgba(10, 24, 44, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease;
}

.mute:active {
  transform: scale(0.9);
}

.mute.off {
  opacity: 0.55;
  border-color: rgba(255, 59, 92, 0.4);
}

/* 보스 바 */
.boss-bar {
  position: absolute;
  top: calc(72px + var(--safe-t));
  left: 50%;
  width: min(342px, 86%);
  transform: translate(-50%, -8px);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.boss-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #e2aaff;
  text-shadow: 0 0 12px rgba(196, 107, 255, 0.7);
}

.boss-top span:last-child {
  font-size: 9px;
  color: rgba(226, 170, 255, 0.8);
  letter-spacing: 0.08em;
}

.boss-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(40, 8, 60, 0.8);
  border: 1px solid rgba(196, 107, 255, 0.35);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7a2bd8, #c46bff 40%, #ff5f9e);
  box-shadow: 0 0 14px rgba(196, 107, 255, 0.8);
  transition: width 0.14s linear;
}

/* 하단 게이지 */
#bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(12px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ink,
.od {
  background: rgba(5, 12, 24, 0.42);
  border-radius: 12px;
  padding: 7px 10px 9px;
  border: 1px solid rgba(95, 244, 255, 0.1);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(2px);
}

.ink-head,
.od-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: rgba(142, 166, 200, 0.95);
}

.ink-head span:last-child {
  color: var(--cyan);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.ink-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(8, 26, 44, 0.9);
  border: 1px solid rgba(95, 244, 255, 0.22);
  overflow: hidden;
}

.ink-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d7ea8, #48e8ff 55%, #c9feff);
  box-shadow: 0 0 12px rgba(95, 244, 255, 0.75);
  transition: width 0.08s linear, background 0.2s ease;
}

.ink-fill.low {
  background: linear-gradient(90deg, #7a0d22, #ff3b5c 60%, #ffb0be);
  box-shadow: 0 0 14px rgba(255, 59, 92, 0.8);
  animation: lowPulse 0.55s ease-in-out infinite;
}

.ink-fill.od {
  background: linear-gradient(90deg, #a87400, #ffe66b 55%, #fffbe0);
  box-shadow: 0 0 16px rgba(255, 230, 107, 0.9);
}

@keyframes lowPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ink-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.28) 48%, transparent 70%);
  transform: translateX(-100%);
  animation: sheen 3.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 62% { transform: translateX(-110%); }
  100% { transform: translateX(110%); }
}

.od {
  border-color: rgba(255, 230, 107, 0.22);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.od.on {
  max-height: 60px;
  padding-top: 7px;
  padding-bottom: 9px;
  opacity: 1;
}

.od-head span {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 230, 107, 0.6);
}

.od-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(60, 44, 6, 0.8);
  overflow: hidden;
}

.od-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffb03a, var(--gold), #fffbe0);
  box-shadow: 0 0 14px rgba(255, 230, 107, 0.9);
  transition: width 0.1s linear;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(104px + var(--safe-b));
  transform: translate(-50%, 6px);
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(196, 220, 240, 0.8);
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

/* ============================================================
   오버레이
   ============================================================ */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-t)) 22px calc(16px + var(--safe-b));
  background:
    linear-gradient(180deg,
      rgba(4, 6, 16, 0.95) 0%,
      rgba(4, 8, 20, 0.9) 30%,
      rgba(5, 10, 24, 0.8) 50%,
      rgba(4, 8, 20, 0.62) 64%,
      rgba(3, 6, 16, 0.18) 78%,
      rgba(2, 4, 12, 0.42) 100%);
  /* 텍스트 가독성은 그라디언트가 담당 — 배경 연출을 살리기 위해 블러 없음 */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
  overflow: hidden;
}

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

.ov-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
  transform: translateY(14px) scale(0.99);
  transition: transform 0.42s cubic-bezier(0.22, 1.2, 0.4, 1);
}

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

.ov-badge {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid rgba(95, 244, 255, 0.35);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: #b9f8ff;
  background: rgba(12, 44, 66, 0.45);
  box-shadow: inset 0 0 22px rgba(95, 244, 255, 0.12), 0 0 18px rgba(95, 244, 255, 0.12);
}

.ov-badge.danger {
  border-color: rgba(255, 59, 92, 0.5);
  color: #ffc7d1;
  background: rgba(60, 8, 20, 0.5);
  box-shadow: inset 0 0 22px rgba(255, 59, 92, 0.14), 0 0 20px rgba(255, 59, 92, 0.16);
}

/* 로고 */
.logo {
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.88;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  transform: skewX(-5deg);
  filter: drop-shadow(0 0 26px rgba(95, 244, 255, 0.35));
}

.logo .l1 {
  font-size: clamp(46px, 14.6vw, 64px);
  background: linear-gradient(178deg, #ffffff 6%, #b9f8ff 34%, #4fe6ff 62%, #0b7ba8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.logo .l2 {
  font-size: clamp(33px, 10.4vw, 47px);
  letter-spacing: 0.015em;
  background: linear-gradient(178deg, #ffffff 4%, #ffd6fb 28%, #ff7bf0 62%, #7b2bd8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: logoGlow 3.4s ease-in-out infinite;
}

@keyframes logoGlow {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 0 rgba(255, 123, 240, 0)); }
  50% { filter: brightness(1.18) drop-shadow(0 0 18px rgba(255, 123, 240, 0.45)); }
}

.ov-kr {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: #ffe9a8;
  text-shadow: 0 0 18px rgba(255, 230, 107, 0.35);
}

.ov-sub {
  margin: 9px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(160, 190, 220, 0.9);
}

.ov-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 22px 0 20px;
}

.step {
  padding: 10px 6px 11px;
  border: 1px solid rgba(95, 244, 255, 0.13);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(14, 30, 56, 0.62), rgba(6, 12, 26, 0.5));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.step b {
  display: block;
  margin-bottom: 5px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(95, 244, 255, 0.6);
}

.step p {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.36;
  color: #c6dcee;
  word-break: keep-all;
}

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

/* 버튼 */
.btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: 1px solid rgba(95, 244, 255, 0.5);
  border-radius: 999px;
  background: linear-gradient(96deg, rgba(20, 170, 220, 0.32), rgba(255, 100, 240, 0.26));
  color: #f2feff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 26px rgba(95, 244, 255, 0.22), inset 0 0 24px rgba(95, 244, 255, 0.1);
  transition: transform 0.14s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: btnShine 3.6s ease-in-out infinite;
}

@keyframes btnShine {
  0%, 55% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.btn:active {
  transform: scale(0.97);
  box-shadow: 0 0 36px rgba(95, 244, 255, 0.35), inset 0 0 30px rgba(95, 244, 255, 0.2);
}

.ov-best {
  margin: 14px 0 0;
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: rgba(142, 166, 200, 0.85);
}

.ov-best span {
  margin-left: 6px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 230, 107, 0.55);
  font-variant-numeric: tabular-nums;
}

.ov-tip {
  margin: 10px 0 0;
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9);
  font-size: 9.5px;
  line-height: 1.5;
  color: rgba(130, 158, 188, 0.72);
  word-break: keep-all;
}

/* 게임오버 */
.over-title {
  margin: 16px 0 0;
  font-size: clamp(34px, 11vw, 44px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #ffffff 10%, #ffc3d0 40%, #ff3b5c 78%, #7a0b25 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 59, 92, 0.35));
}

.over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0 10px;
}

.over-stats > div {
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 20, 38, 0.55);
}

.over-stats span {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.over-stats b {
  display: block;
  margin-top: 3px;
  font-size: 19px;
  font-weight: 900;
  color: #f0feff;
  text-shadow: 0 0 14px rgba(95, 244, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

.over-tier {
  margin: 4px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.over-tier b {
  margin-left: 6px;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.ov-record {
  margin: 12px 0 16px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(160, 190, 220, 0.9);
}

.ov-record.record {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 230, 107, 0.6);
  animation: recordPulse 1.2s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* 아주 작은 화면 보정 */
@media (max-height: 700px) {
  .ov-steps { margin: 14px 0 14px; }
  .logo { margin-top: 12px; }
  .ov-tip { display: none; }
  .step { padding: 8px 5px 9px; }
  .btn { padding: 13px 18px; }
  .over-stats { margin: 12px 0 8px; }
  .over-stats b { font-size: 16px; }
}

@media (min-width: 540px) {
  .ov-inner { max-width: 400px; }
}
