* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070d;
  font-family:
    Inter,
    Pretendard,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #f8fafc;
}

button {
  font: inherit;
}

.stage {
  position: relative;
  width: min(100vw, 177.777vh);
  height: min(56.25vw, 100vh);
  margin: auto;
  overflow: hidden;
  background-image: url("assets/images/background_figma_stage.png");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  user-select: none;
}

.stage.shake {
  animation: screenShake 0.32s linear;
}

.stage.deadline-warning .deadline-card {
  border-color: rgba(255, 51, 71, 0.95);
  box-shadow: 0 0 20px rgba(255, 51, 71, 0.35);
  color: #ff4b5f;
}

.stage.low-hp::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 45%, rgba(255, 0, 35, 0.22) 100%);
  z-index: 11;
  animation: lowHpPulse 1.2s infinite;
}

.playfield {
  position: absolute;
  left: 20.4%;
  top: 15.3%;
  width: 58.1%;
  height: 79.2%;
  overflow: hidden;
  z-index: 3;
}

.playfield::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 2px solid rgba(55, 151, 255, 0.8);
  box-shadow:
    inset 0 0 24px rgba(55, 151, 255, 0.18),
    0 0 14px rgba(55, 151, 255, 0.35);
  z-index: 20;
}

.effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

.hud {
  position: absolute;
  left: 21%;
  right: 20%;
  top: 2.2%;
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 1fr;
  gap: 0.55rem;
  z-index: 30;
}

.hud-card {
  min-height: 46px;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(125, 156, 205, 0.22);
  border-radius: 12px;
  background: rgba(8, 13, 22, 0.78);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  display: grid;
  align-content: center;
  gap: 0.28rem;
}

.hud-label {
  color: #94a3b8;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-card strong {
  color: #f8fafc;
  font-size: 0.95rem;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  transition: width 0.22s ease;
}

.hp-fill {
  background: linear-gradient(90deg, #ff375f, #ff7a90);
}

.quality-fill {
  background: linear-gradient(90deg, #60a5fa, #7c3aed);
}

.client-panel {
  position: absolute;
  right: 1.15%;
  top: 10.2%;
  width: 15.4%;
  height: 72%;
  z-index: 28;
  padding: 0.8rem;
  border: 1px solid rgba(125, 156, 205, 0.18);
  border-radius: 14px;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-title b {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: #7c3aed;
  color: white;
  font-size: 0.72rem;
}

.client-messages {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  height: calc(100% - 2rem);
  overflow: hidden;
}

.client-msg {
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.1);
  animation: messageIn 0.25s ease both;
}

.client-msg strong {
  display: block;
  font-size: 0.73rem;
  color: #ffffff;
  margin-bottom: 0.3rem;
}

.client-msg p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.72rem;
  line-height: 1.35;
}

.player {
  position: absolute;
  width: clamp(190px, 14vw, 270px);
  height: clamp(190px, 14vw, 270px);
  z-index: 12;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  pointer-events: none;
  filter:
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 10px rgba(59, 130, 246, 0.45));
}

.player img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.player.invulnerable {
  animation: invulnerableBlink 0.12s steps(2) infinite;
}

.player.hit {
  filter:
    drop-shadow(0 0 14px rgba(255, 50, 70, 0.95))
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
}

.attack {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
  will-change: transform, left, top, opacity;
  transform-origin: center;
  color: #111827;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.warning-marker {
  position: absolute;
  top: 0.45rem;
  z-index: 15;
  width: 86px;
  height: 30px;
  margin-left: -43px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  font-size: 0.8rem;
  background: rgba(239, 68, 68, 0.88);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.55);
  animation: warningPulse 0.18s alternate infinite;
}

.warning-marker::before {
  content: "WARNING";
}

/* kerning: 글자를 span으로 분리, 컨테이너는 투명 flex */
.attack-kerning {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: clamp(56px, 6.2vw, 108px);
  font-weight: 1000;
}

.kerning-char {
  display: inline-block;
  color: #fff;
  text-shadow:
    0 0 24px rgba(255, 55, 95, 0.95),
    0 0 10px rgba(255, 55, 95, 0.65),
    0 3px 0 rgba(0, 0, 0, 0.55);
}

.attack-logo {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  padding: 1rem;
  color: white;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.45), transparent 24%),
    linear-gradient(135deg, #151a31, #5b21b6 55%, #111827);
  border: 5px solid rgba(255, 255, 255, 0.86);
  box-shadow:
    0 0 28px rgba(124, 58, 237, 0.55),
    0 18px 34px rgba(0, 0, 0, 0.35);
  font-size: 1.05rem;
  line-height: 1.15;
  word-break: keep-all;
}

.attack-rainbow {
  font-size: clamp(27px, 2.95vw, 52px);
  font-weight: 1000;
  color: transparent;
  background: linear-gradient(90deg, #ff004c, #ffb700, #45ff66, #00d5ff, #7c3aed, #ff00b8, #ff004c);
  background-size: 300% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 0 16px rgba(255, 0, 184, 0.7));
  animation: rainbowFill 0.55s linear infinite;
}

.attack-deadline {
  font-size: clamp(30px, 3.2vw, 58px);
  font-weight: 1000;
  color: #ff3b30;
  text-shadow:
    0 0 28px rgba(255, 59, 48, 0.98),
    0 0 12px rgba(255, 59, 48, 0.7),
    0 3px 0 rgba(0, 0, 0, 0.6);
  animation: deadlineJitter 0.08s infinite;
}

.attack-simple {
  font-size: clamp(21px, 2.4vw, 42px);
  font-weight: 900;
  color: #f0f0f0;
  text-shadow:
    0 0 16px rgba(255, 255, 255, 0.85),
    0 0 7px rgba(200, 200, 200, 0.55),
    0 2px 0 rgba(0, 0, 0, 0.65);
}

.attack-simple.dash-mode {
  color: #fca5a5;
  text-shadow:
    0 0 24px rgba(239, 68, 68, 0.95),
    0 0 12px rgba(239, 68, 68, 0.65);
}

.attack-reference {
  font-size: clamp(20px, 2.2vw, 38px);
  font-weight: 900;
  color: #60a5fa;
  text-shadow:
    0 0 18px rgba(96, 165, 250, 0.85),
    0 0 7px rgba(96, 165, 250, 0.5);
  text-align: center;
}

.ref-tags {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.ref-tags span {
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(37, 99, 235, 0.55);
  font-size: 0.72rem;
}

.attack-copy {
  font-size: clamp(21px, 2.4vw, 42px);
  font-weight: 900;
  color: #c084fc;
  text-shadow:
    0 0 20px rgba(192, 132, 252, 0.9),
    0 0 8px rgba(192, 132, 252, 0.55);
}

.attack-copy.dash-mode {
  color: #fff;
  text-shadow:
    0 0 26px rgba(147, 51, 234, 0.98),
    0 0 14px rgba(147, 51, 234, 0.72);
}

.attack-percent {
  font-size: clamp(17px, 1.85vw, 30px);
  font-weight: 900;
  color: #f1f5f9;
  text-shadow: 0 0 14px rgba(124, 58, 237, 0.75);
  text-align: center;
}

.percent-bar {
  height: 9px;
  width: 200px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.percent-bar span {
  display: block;
  width: 98%;
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #60a5fa);
  animation: percentBlink 0.5s infinite alternate;
}

.attack-font {
  font-size: clamp(27px, 2.7vw, 48px);
  font-weight: 900;
  color: #e2e8f0;
  text-shadow:
    0 0 16px rgba(226, 232, 240, 0.75),
    0 0 6px rgba(148, 163, 184, 0.55);
  animation: weakFont 0.28s infinite alternate;
}

.attack-align {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.attack-align span {
  display: inline-block;
  color: #93c5fd;
  font-size: clamp(18px, 1.6vw, 30px);
  font-weight: 1000;
  text-shadow:
    0 0 16px rgba(96, 165, 250, 0.8),
    0 0 6px rgba(96, 165, 250, 0.45);
}

.attack-align span:nth-child(1) { transform: translateY(-10px) rotate(-5deg); }
.attack-align span:nth-child(2) { transform: translateY(6px) rotate(3deg); }
.attack-align span:nth-child(3) { transform: translateY(-3px) rotate(-9deg); }
.attack-align span:nth-child(4) { transform: translateY(13px) rotate(5deg); }
.attack-align span:nth-child(5) { transform: translateY(-8px) rotate(7deg); }
.attack-align span:nth-child(6) { transform: translateY(4px) rotate(-4deg); }

.damage-text {
  position: absolute;
  z-index: 35;
  color: #ef4444;
  font-size: 1.2rem;
  font-weight: 1000;
  text-shadow: 0 2px 0 white;
  animation: damageFloat 0.75s ease-out forwards;
  pointer-events: none;
}

.effect-flash {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(239, 68, 68, 0.22);
  animation: flashOut 0.32s ease forwards;
}

.effect-rainbow {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: linear-gradient(90deg, rgba(255,0,76,.18), rgba(255,183,0,.18), rgba(0,213,255,.18), rgba(124,58,237,.18));
  mix-blend-mode: multiply;
  animation: flashOut 0.55s ease forwards;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  font-size: clamp(80px, 12vw, 180px);
  font-weight: 1000;
  color: white;
  text-shadow: 0 0 28px rgba(96, 165, 250, 0.8);
  background: rgba(0, 0, 0, 0.18);
}

.hidden {
  display: none !important;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(124, 58, 237, 0.22), transparent 48%),
    rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(8px);
}

.start-card,
.ending-card {
  width: min(620px, 86%);
  padding: 2rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.start-character,
.ending-character {
  width: 170px;
  height: 170px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 18px rgba(96, 165, 250, 0.45));
}

.eyebrow {
  margin: 0.2rem 0 0.4rem;
  color: #a78bfa;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.start-card h1,
.ending-card h2 {
  margin: 0.3rem 0 0.5rem;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.subtitle {
  margin: 0 0 1.2rem;
  color: #cbd5e1;
}

.rules {
  display: grid;
  gap: 0.45rem;
  margin: 1rem auto 1.35rem;
  max-width: 430px;
  text-align: left;
}

.rules p {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.78);
  color: #e2e8f0;
}

.primary-btn {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 0.9rem 1.3rem;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.35);
}

.primary-btn:hover {
  filter: brightness(1.1);
}

.export-overlay {
  position: absolute;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(4px);
  text-align: center;
}

.export-overlay p {
  margin: 0 0 0.6rem;
  color: #93c5fd;
  letter-spacing: 0.28em;
  font-weight: 900;
}

.export-overlay strong {
  display: block;
  font-size: clamp(2rem, 5vw, 5rem);
  color: white;
  text-shadow: 0 0 30px rgba(96, 165, 250, 0.8);
}

.ending-card ul {
  list-style: none;
  margin: 1.25rem auto;
  padding: 0;
  max-width: 420px;
  display: grid;
  gap: 0.55rem;
  text-align: left;
}

.ending-card li {
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.8);
}

.to-be {
  color: #fca5a5;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 5px); }
  30% { transform: translate(7px, -4px); }
  45% { transform: translate(-6px, -5px); }
  60% { transform: translate(5px, 4px); }
  75% { transform: translate(-3px, 3px); }
}

@keyframes invulnerableBlink {
  from { opacity: 0.38; }
  to { opacity: 1; }
}

@keyframes lowHpPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

@keyframes warningPulse {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(4px) scale(1.05); }
}

@keyframes rainbowFill {
  from { background-position: 0% 50%; }
  to { background-position: 300% 50%; }
}

@keyframes deadlineJitter {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg); }
}

@keyframes percentBlink {
  from { filter: brightness(0.85); }
  to { filter: brightness(1.5); }
}

@keyframes weakFont {
  0% {
    font-weight: 200;
    transform: skewX(-2deg) scaleY(0.94);
  }
  100% {
    font-weight: 1000;
    transform: skewX(2deg) scaleY(1.08);
  }
}

@keyframes damageFloat {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-54px) scale(1.25);
  }
}

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

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}