:root {
  color: #f8fafc;
  background: #141019;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 12%, rgba(251, 191, 36, .18), transparent 26%),
    radial-gradient(circle at 82% 20%, rgba(56, 189, 248, .14), transparent 24%),
    linear-gradient(145deg, #18111f 0%, #10212a 54%, #25172b 100%);
}

button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  color: #f8fafc;
  background: linear-gradient(180deg, #39445f, #20283e);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:disabled { opacity: .46; cursor: not-allowed; }
button:focus-visible { outline: 3px solid #facc15; outline-offset: 3px; }

.game-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.arena-panel, .control-panel {
  border: 1px solid rgba(226, 232, 240, .16);
  border-radius: 8px;
  background: rgba(15, 23, 42, .76);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .28);
}

.arena-panel { padding: clamp(16px, 3vw, 28px); display: grid; grid-template-rows: auto 1fr auto; gap: 18px; }
.control-panel { padding: 18px; display: grid; gap: 14px; align-content: start; }
.hud { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.eyebrow { margin: 0 0 7px; color: #9fd3ff; font-size: 12px; font-weight: 950; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(32px, 6vw, 64px); line-height: 1; }
.stage-chip { padding: 9px 12px; border-radius: 999px; background: #f8fafc; color: #111827; font-weight: 950; white-space: nowrap; }

.boss-stage {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .14);
  background:
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(22, 28, 48, .88), rgba(17, 24, 39, .72));
  background-size: 44px 44px, 44px 44px, auto;
}

.warning-lane {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .18);
  font-size: clamp(34px, 7vw, 90px);
  font-weight: 950;
  letter-spacing: .08em;
  pointer-events: none;
}
.warning-lane.left { left: 0; }
.warning-lane.right { right: 0; }

.boss-stage[data-pattern="left"] .warning-lane.left,
.boss-stage[data-pattern="right"] .warning-lane.right {
  color: rgba(248, 113, 113, .42);
  animation: lanePulse .7s ease-in-out infinite alternate;
}
.boss-stage[data-pattern="center"] .boss-head {
  animation: headStrike .64s ease-in-out infinite alternate;
  box-shadow: 0 0 0 9px rgba(250, 204, 21, .14), 0 26px 55px rgba(0, 0, 0, .35);
}

.boss-part, .boss-head {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: visible;
}
.boss-part {
  width: clamp(105px, 18vw, 185px);
  height: clamp(130px, 22vw, 230px);
  bottom: 64px;
  border-radius: 42% 42% 36% 36%;
  background: linear-gradient(180deg, #d89a5f, #8f4c2c);
}
.boss-part.left { left: 10%; transform: rotate(-12deg); }
.boss-part.right { right: 10%; transform: rotate(12deg); }
.boss-head {
  width: clamp(190px, 31vw, 330px);
  height: clamp(180px, 29vw, 310px);
  left: 50%;
  top: 36px;
  transform: translateX(-50%);
  border-radius: 48% 48% 44% 44%;
  background: linear-gradient(180deg, #f2bb76, #b86b40);
}
.boss-head.hit, .boss-part.hit { animation: hitShake .22s linear; }
.boss-head.bitten { animation: biteImpact .42s ease-out; }
.boss-part.destroyed { filter: grayscale(.8); opacity: .58; transform: translateY(20px) rotate(var(--fall, 0deg)); pointer-events: none; }
.boss-part.left.destroyed { --fall: -26deg; }
.boss-part.right.destroyed { --fall: 26deg; }

.ear { position: absolute; top: -22px; width: 70px; height: 70px; background: #bb6d43; clip-path: polygon(50% 0, 0 100%, 100% 100%); }
.ear.l { left: 34px; transform: rotate(-16deg); }
.ear.r { right: 34px; transform: rotate(16deg); }
.face { position: relative; width: 76%; height: 66%; border-radius: 46%; background: rgba(255, 255, 255, .12); }
.eye { position: absolute; top: 32%; width: 22px; height: 30px; border-radius: 999px; background: #111827; }
.eye.l { left: 28%; }
.eye.r { right: 28%; }
.muzzle { position: absolute; left: 50%; top: 54%; width: 68px; height: 44px; transform: translateX(-50%); border-radius: 50%; background: rgba(255, 241, 218, .82); }
.muzzle::after { content: ""; position: absolute; left: 50%; top: 11px; width: 14px; height: 10px; transform: translateX(-50%); border-radius: 50%; background: #351c1d; }

.part-label {
  position: absolute;
  left: 50%;
  bottom: -36px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-weight: 950;
}
.hp {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -15px;
  height: 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  overflow: hidden;
}
.hp i { display: block; width: var(--hp, 100%); height: 100%; background: linear-gradient(90deg, #22c55e, #facc15, #ef4444); }

.action-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.primary-action { background: linear-gradient(180deg, #334155, #1e293b); }
.bite-action { background: linear-gradient(180deg, #f59e0b, #b45309); color: #111827; }
.bite-action:not(:disabled) { animation: biteReady .82s ease-in-out infinite alternate; }
.next-stage { background: linear-gradient(180deg, #22c55e, #15803d); }
.secondary-action { background: #111827; }

.pattern-card, .metrics {
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  background: rgba(2, 6, 23, .32);
  padding: 14px;
}
.pattern-card p:last-child { margin-bottom: 0; color: #cbd5e1; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metrics div { min-height: 78px; display: grid; gap: 4px; align-content: center; padding: 10px; border-radius: 8px; background: rgba(148, 163, 184, .10); }
.metrics span { color: #a8bdd8; font-size: 12px; font-weight: 850; }
.metrics strong { font-size: 24px; }
.battle-log { margin: 0; padding-left: 21px; color: #dbeafe; line-height: 1.45; }

@keyframes lanePulse { from { opacity: .55; } to { opacity: 1; } }
@keyframes headStrike { from { transform: translateX(-50%) translateY(0) scale(1); } to { transform: translateX(-50%) translateY(12px) scale(1.035); } }
@keyframes hitShake { 0%, 100% { translate: 0 0; } 30% { translate: -9px 0; } 70% { translate: 9px 0; } }
@keyframes biteImpact { 0% { transform: translateX(-50%) scale(1); } 45% { transform: translateX(-50%) scale(.9); } 100% { transform: translateX(-50%) scale(1.02); } }
@keyframes biteReady { from { box-shadow: 0 0 0 0 rgba(250, 204, 21, .28); } to { box-shadow: 0 0 0 9px rgba(250, 204, 21, .08); } }

@media (max-width: 860px) {
  .game-shell { grid-template-columns: 1fr; }
  .control-panel { order: -1; }
  .boss-stage { min-height: 430px; }
  .action-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .hud { align-items: flex-start; flex-direction: column; }
  .boss-stage { min-height: 380px; }
  .boss-part.left { left: 4%; }
  .boss-part.right { right: 4%; }
}
