:root {
  color-scheme: dark;
  --bg-top: #09111f;
  --bg-bottom: #04070f;
  --panel: rgba(12, 20, 37, 0.84);
  --panel-border: rgba(150, 186, 255, 0.18);
  --text-main: #ecf3ff;
  --text-soft: #98a9c8;
  --accent: #7ce5ff;
  --accent-strong: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(72, 141, 255, 0.18), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(255, 209, 102, 0.18), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(124, 229, 255, 0.16) 0 1px, transparent 1px);
  background-position: 0 0, 24px 18px;
  background-size: 34px 34px, 52px 52px;
  opacity: 0.28;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
}

.hero,
.layout,
.panel,
.stat-card,
.tile {
  backdrop-filter: blur(14px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.hero-copy {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.subtitle {
  max-width: 28rem;
  color: var(--text-soft);
  line-height: 1.35;
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.main-panel {
  display: grid;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.combat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.player-card,
.monster-card {
  display: grid;
  align-content: start;
}

.stat-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(23, 36, 64, 0.95), rgba(13, 22, 39, 0.88));
  border: 1px solid rgba(159, 201, 255, 0.12);
}

.stat-card span {
  display: block;
  font-size: 0.84rem;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.4rem;
  line-height: 1;
}

.tip-title {
  font-size: 1rem;
}

.tip-text {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}

.tip-card {
  min-height: 0;
}

.side-action {
  width: 100%;
}

.player-card,
.monster-card {
  position: relative;
  padding: 12px 14px;
  overflow: hidden;
}

.player-card {
  background:
    radial-gradient(circle at top left, rgba(124, 229, 255, 0.2), transparent 32%),
    linear-gradient(180deg, rgba(17, 31, 54, 0.96), rgba(14, 21, 39, 0.92));
}

.monster-card {
  background:
    radial-gradient(circle at top right, rgba(255, 107, 107, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(35, 18, 37, 0.96), rgba(18, 18, 34, 0.92));
}

.player-card.hit,
.monster-card.hit {
  animation: panel-hit 320ms ease;
}

.player-header,
.monster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.player-header span,
.player-meta span,
.monster-header span,
.monster-meta span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.player-header strong,
.player-meta strong,
.monster-header strong,
.monster-meta strong {
  font-size: 1rem;
}

.player-avatar,
.monster-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 1.35rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.player-health,
.monster-health {
  margin-top: 8px;
}

.search-timer {
  margin-top: 8px;
}

.search-timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.search-timer-header span {
  color: var(--text-soft);
  font-size: 0.76rem;
}

.search-timer-header strong {
  font-size: 0.86rem;
}

.search-timer-bar {
  height: 10px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.search-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ef5bf, #ffd166, #ff7b7b);
  transform-origin: left center;
  transition: width 90ms linear, background 160ms ease;
}

.search-timer-fill.danger {
  background: linear-gradient(90deg, #ffd166, #ff7b7b, #d64747);
}

.player-health-bar,
.monster-health-bar {
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.player-health-fill,
.monster-health-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 220ms ease;
}

.player-health-fill {
  background: linear-gradient(90deg, #7ce5ff, #7ef5bf);
}

.monster-health-fill {
  background: linear-gradient(90deg, #ff7b7b, #ffd166);
}

.monster-health-fill.hp-high,
.floating-enemy-fill.hp-high {
  background: linear-gradient(90deg, #5ce06e, #b8ff93);
}

.monster-health-fill.hp-mid,
.floating-enemy-fill.hp-mid {
  background: linear-gradient(90deg, #ffd84a, #ffe99d);
}

.monster-health-fill.hp-low,
.floating-enemy-fill.hp-low {
  background: linear-gradient(90deg, #ff6767, #ffb36b);
}

.player-health p,
.monster-health p {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.player-meta,
.monster-meta {
  margin-top: 8px;
}

.damage-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.damage-number {
  position: absolute;
  right: 18px;
  top: 22px;
  font-weight: 900;
  font-size: 1.5rem;
  color: #ffd166;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.45);
  animation: damage-rise 820ms cubic-bezier(0.22, 0.8, 0.24, 1) forwards;
}

.damage-number.player {
  color: #7ce5ff;
  text-shadow: 0 0 12px rgba(124, 229, 255, 0.45);
}

.action-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  color: #08111f;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 14px 24px rgba(124, 229, 255, 0.22);
}

.action-button:hover {
  transform: translateY(-1px);
}

.action-button:active {
  transform: translateY(1px);
}

.action-button.secondary {
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(71, 95, 146, 0.92), rgba(21, 28, 49, 0.92));
  box-shadow: none;
}

.board-panel {
  padding: 12px;
}

.board-panel.hit {
  animation: board-shake 300ms ease;
}

.board-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.board-header p {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.board {
  --cell-size: min(68px, calc((100vw - 360px) / 8), calc((100dvh - 240px) / 8));
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: 8px;
  justify-content: center;
  padding: 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(6, 11, 22, 0.92), rgba(7, 13, 23, 0.7)),
    radial-gradient(circle at top, rgba(105, 161, 255, 0.16), transparent 48%);
  touch-action: manipulation;
}

.board-frame {
  position: relative;
  width: fit-content;
  margin: 0 auto;
}

.effects-layer {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  overflow: visible;
}

.floating-enemy-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(180px, 42vw);
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(10, 18, 33, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

.floating-enemy-bar.show {
  animation: floating-bar-pop 1500ms cubic-bezier(0.2, 0.8, 0.24, 1) forwards;
}

.floating-enemy-bar.hit {
  animation:
    floating-bar-pop 1500ms cubic-bezier(0.2, 0.8, 0.24, 1) forwards,
    floating-bar-hit 280ms ease;
}

.floating-enemy-label {
  font-size: 0.74rem;
  color: var(--text-soft);
  letter-spacing: 0.08em;
}

.floating-enemy-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.floating-enemy-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.floating-enemy-track {
  height: 10px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.floating-enemy-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 320ms ease;
}

.celebration-text {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.18em;
  pointer-events: none;
  opacity: 0;
  z-index: 8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff6cf;
  white-space: nowrap;
  flex-wrap: nowrap;
  text-shadow:
    0 0 10px rgba(255, 216, 74, 0.8),
    0 0 28px rgba(255, 90, 79, 0.45),
    0 10px 30px rgba(0, 0, 0, 0.35);
}

.celebration-text .overkill-value {
  display: inline-block;
  white-space: nowrap;
  color: #57d957;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.board-damage-text {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.18em;
  pointer-events: none;
  opacity: 0;
  z-index: 7;
  width: max-content;
  transform: translate(-50%, -50%);
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 900;
  color: #fff6cf;
  white-space: nowrap;
  flex-wrap: nowrap;
  text-shadow:
    0 0 10px rgba(255, 246, 207, 0.85),
    0 0 24px rgba(255, 90, 79, 0.28),
    0 8px 24px rgba(0, 0, 0, 0.32);
}

.board-damage-text.show {
  animation: board-damage-pop 1350ms cubic-bezier(0.2, 0.8, 0.24, 1) forwards;
}

.board-damage-text .damage-value {
  display: inline-block;
  white-space: nowrap;
  color: #8dff8a;
  text-shadow:
    0 0 12px rgba(141, 255, 138, 0.95),
    0 0 28px rgba(65, 214, 97, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.32);
}

.celebration-text.show {
  animation: celebration-pop 1200ms cubic-bezier(0.18, 0.72, 0.24, 1) forwards;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 18px;
  color: white;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  cursor: pointer;
  user-select: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -8px 18px rgba(0, 0, 0, 0.16),
    0 10px 18px rgba(0, 0, 0, 0.22);
  transition: transform 140ms ease, outline-color 140ms ease, opacity 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 55%);
  pointer-events: none;
}

.tile:hover {
  transform: translateY(-2px) scale(1.02);
}

.tile.selected {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}

.tile.matching {
  animation: pulse 360ms ease-in-out infinite alternate;
}

.tile.removing {
  opacity: 0;
  transform: scale(0.72);
}

.tile.wind {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.88), transparent 22%),
    linear-gradient(180deg, #c9ffae, #72e06a 58%, #267b31);
}

.tile.fire {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 228, 182, 0.9), transparent 22%),
    linear-gradient(180deg, #ffba9e, #ff5a4f 58%, #9c1f1f);
}

.tile.rain {
  background:
    radial-gradient(circle at 32% 28%, rgba(229, 248, 255, 0.84), transparent 20%),
    linear-gradient(180deg, #b9e4ff, #4da6ff 58%, #1d4fbf);
}

.tile.thunder {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 250, 205, 0.92), transparent 18%),
    linear-gradient(180deg, #fff0a6, #ffd84a 56%, #b88d08);
}

.burst,
.burst-particle,
.burst-ring,
.burst-core {
  position: absolute;
  pointer-events: none;
}

.burst {
  width: 0;
  height: 0;
  z-index: 5;
}

.burst-particle {
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), currentColor 55%, transparent 72%);
  box-shadow: 0 0 14px currentColor;
  animation: explode-particle 520ms cubic-bezier(0.18, 0.72, 0.3, 1) forwards;
}

.burst-ring {
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 999px;
  border: 3px solid currentColor;
  box-shadow: 0 0 20px currentColor;
  animation: explode-ring 460ms ease-out forwards;
}

.burst-core {
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.15) 68%, transparent 74%);
  animation: explode-core 280ms ease-out forwards;
}

.burst.wind .burst-ring,
.burst.wind .burst-core {
  filter: drop-shadow(0 0 16px rgba(114, 224, 106, 0.72));
}

.burst.fire .burst-ring,
.burst.fire .burst-core {
  filter: drop-shadow(0 0 18px rgba(255, 90, 79, 0.85));
}

.burst.rain .burst-ring,
.burst.rain .burst-core {
  filter: drop-shadow(0 0 16px rgba(77, 166, 255, 0.78));
}

.burst.thunder .burst-ring,
.burst.thunder .burst-core {
  filter: drop-shadow(0 0 18px rgba(255, 216, 74, 0.92));
}

.wind-particle,
.wind-arc,
.fire-particle,
.fire-flare,
.rain-drop,
.rain-splash,
.thunder-bolt,
.thunder-spark {
  position: absolute;
  pointer-events: none;
}

.wind-particle {
  width: 18px;
  height: 7px;
  margin-left: -9px;
  margin-top: -3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), currentColor, rgba(255, 255, 255, 0.05));
  opacity: 0;
  animation: wind-burst 620ms cubic-bezier(0.18, 0.72, 0.3, 1) forwards;
}

.wind-arc {
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border-radius: 50%;
  border-top: 3px solid currentColor;
  border-right: 2px solid transparent;
  opacity: 0;
  animation: wind-arc-spin 700ms ease-out forwards;
}

.fire-particle {
  width: 12px;
  height: 18px;
  margin-left: -6px;
  margin-top: -14px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(180deg, rgba(255, 248, 213, 0.95), currentColor 55%, rgba(127, 11, 0, 0.3));
  transform-origin: center bottom;
  opacity: 0;
  filter: blur(0.4px);
  animation: fire-burst 640ms cubic-bezier(0.18, 0.72, 0.3, 1) forwards;
}

.fire-flare {
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 233, 188, 0.9), rgba(255, 90, 79, 0.52) 55%, transparent 74%);
  opacity: 0;
  animation: fire-flare-pop 380ms ease-out forwards;
}

.rain-drop {
  width: 5px;
  height: 24px;
  margin-left: -2px;
  margin-top: -12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), currentColor 38%, rgba(255, 255, 255, 0));
  opacity: 0;
  animation: rain-fall 620ms linear forwards;
}

.rain-splash {
  width: 16px;
  height: 8px;
  margin-left: -8px;
  margin-top: -4px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 16px 16px;
  opacity: 0;
  animation: rain-splash-pop 520ms ease-out forwards;
}

.thunder-bolt {
  width: 14px;
  height: 32px;
  margin-left: -7px;
  margin-top: -18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), currentColor 55%, rgba(184, 141, 8, 0.18));
  clip-path: polygon(42% 0, 100% 0, 58% 42%, 82% 42%, 16% 100%, 38% 56%, 14% 56%);
  opacity: 0;
  filter: drop-shadow(0 0 10px currentColor);
  animation: thunder-strike 420ms ease-out forwards;
}

.thunder-spark {
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), currentColor 52%, transparent 75%);
  opacity: 0;
  animation: thunder-spark-pop 500ms ease-out forwards;
}

@keyframes pulse {
  from {
    transform: scale(1);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.28),
      0 12px 22px rgba(255, 209, 102, 0.18);
  }

  to {
    transform: scale(1.06);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.32),
      0 18px 28px rgba(124, 229, 255, 0.32);
  }
}

@keyframes explode-particle {
  0% {
    transform: rotate(var(--angle)) translateX(0) scale(0.3);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(1.25);
    opacity: 0;
  }
}

@keyframes explode-ring {
  0% {
    transform: scale(0.2);
    opacity: 0.85;
  }

  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

@keyframes explode-core {
  0% {
    transform: scale(0.45);
    opacity: 1;
  }

  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes wind-burst {
  0% {
    transform: rotate(var(--angle)) translateX(0) translateY(0) scale(0.3);
    opacity: 0;
  }

  15% {
    opacity: 0.95;
  }

  100% {
    transform: rotate(var(--angle)) translateX(var(--distance)) translateY(calc(var(--drift) * -1)) scale(1.2);
    opacity: 0;
  }
}

@keyframes wind-arc-spin {
  0% {
    transform: rotate(var(--angle)) scale(0.2);
    opacity: 0;
  }

  30% {
    opacity: 0.85;
  }

  100% {
    transform: rotate(calc(var(--angle) + 110deg)) translateX(calc(var(--distance) * 0.2)) scale(1.3);
    opacity: 0;
  }
}

@keyframes fire-burst {
  0% {
    transform: rotate(var(--angle)) translateY(0) scale(0.4);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  100% {
    transform: rotate(var(--angle)) translateY(calc(var(--drift) * -1)) translateX(calc(var(--distance) * 0.25)) scale(1.3);
    opacity: 0;
  }
}

@keyframes fire-flare-pop {
  0% {
    transform: scale(0.15);
    opacity: 0;
  }

  30% {
    opacity: 0.95;
  }

  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

@keyframes rain-fall {
  0% {
    transform: rotate(var(--angle)) translateY(calc(var(--distance) * -0.35)) scaleY(0.4);
    opacity: 0;
  }

  15% {
    opacity: 0.95;
  }

  100% {
    transform: rotate(var(--angle)) translateY(var(--drift)) scaleY(1.2);
    opacity: 0;
  }
}

@keyframes rain-splash-pop {
  0% {
    transform: rotate(var(--angle)) translateX(0) scale(0.4);
    opacity: 0;
  }

  25% {
    opacity: 0.9;
  }

  100% {
    transform: rotate(var(--angle)) translateX(var(--distance)) translateY(calc(var(--drift) * -0.3)) scale(1.15);
    opacity: 0;
  }
}

@keyframes thunder-strike {
  0% {
    transform: rotate(var(--angle)) translateY(calc(var(--distance) * -0.4)) scale(0.3);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  55% {
    opacity: 0.95;
  }

  100% {
    transform: rotate(var(--angle)) translateY(var(--drift)) scale(1.15);
    opacity: 0;
  }
}

@keyframes thunder-spark-pop {
  0% {
    transform: rotate(var(--angle)) translateX(0) scale(0.25);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: rotate(var(--angle)) translateX(var(--distance)) translateY(calc(var(--drift) * -0.35)) scale(1.25);
    opacity: 0;
  }
}

@keyframes damage-rise {
  0% {
    transform: translateY(12px) scale(0.8);
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  100% {
    transform: translateY(-28px) scale(1.12);
    opacity: 0;
  }
}

@keyframes panel-hit {
  0% {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  25% {
    transform: translateX(-4px);
    box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.45), 0 24px 70px rgba(0, 0, 0, 0.42);
  }

  50% {
    transform: translateX(5px);
  }

  100% {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
}

@keyframes board-shake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  20% {
    transform: translate3d(-7px, 1px, 0);
  }

  40% {
    transform: translate3d(6px, -2px, 0);
  }

  60% {
    transform: translate3d(-5px, 2px, 0);
  }

  80% {
    transform: translate3d(3px, -1px, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes celebration-pop {
  0% {
    transform: scale(0.58) translateY(18px);
    opacity: 0;
  }

  16% {
    opacity: 1;
  }

  38% {
    transform: scale(1.08) translateY(-4px);
    opacity: 1;
  }

  100% {
    transform: scale(1.24) translateY(-20px);
    opacity: 0;
  }
}

@keyframes board-damage-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.72) translateY(16px);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  34% {
    transform: translate(-50%, -50%) scale(1.06) translateY(-2px);
    opacity: 1;
  }

  72% {
    transform: translate(-50%, -50%) scale(1.08) translateY(-10px);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.1) translateY(-18px);
    opacity: 0;
  }
}

@keyframes floating-bar-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.88) translateY(10px);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  74% {
    transform: translate(-50%, -50%) scale(1) translateY(-6px);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1) translateY(-10px);
    opacity: 0;
  }
}

@keyframes floating-bar-hit {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  }

  25% {
    transform: translate(-50%, -50%) translateX(-6px) scale(1.02);
    box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.32), 0 14px 28px rgba(0, 0, 0, 0.28);
  }

  50% {
    transform: translate(-50%, -50%) translateX(5px) scale(1.02);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 900px) {
  .layout,
  .hero,
  .hero-actions,
  .stats-grid,
  .combat-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: 2;
  }

  .main-panel {
    order: 1;
  }

  .board {
    --cell-size: min(10vw, 62px);
    gap: 8px;
    padding: 12px;
  }

  .hero,
  .board-header {
    align-items: start;
    flex-direction: column;
  }

  .action-button {
    width: 100%;
    justify-self: stretch;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 16px, 680px);
  }

  .hero {
    margin-bottom: 10px;
    gap: 10px;
  }

  .hero-copy {
    gap: 6px;
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    margin-bottom: 4px;
  }

  h1 {
    font-size: clamp(1.45rem, 8vw, 2rem);
  }

  .subtitle {
    max-width: none;
    font-size: 0.84rem;
  }

  .layout {
    gap: 10px;
  }

  .combat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .player-card,
  .monster-card,
  .stat-card {
    padding: 10px 11px;
    border-radius: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card strong {
    font-size: 1.15rem;
  }

  .tip-card {
    grid-column: 1 / -1;
  }

  .player-header,
  .monster-header {
    gap: 8px;
  }

  .player-avatar,
  .monster-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 1.05rem;
  }

  .player-header strong,
  .player-meta strong,
  .monster-header strong,
  .monster-meta strong {
    font-size: 0.9rem;
  }

  .player-header span,
  .player-meta span,
  .monster-header span,
  .monster-meta span,
  .search-timer-header span,
  .search-timer-header strong,
  .player-health p,
  .monster-health p,
  .tip-text,
  .board-header p {
    font-size: 0.74rem;
  }

  .player-health,
  .monster-health,
  .search-timer,
  .player-meta,
  .monster-meta {
    margin-top: 6px;
  }

  .board-panel {
    padding: 8px;
    border-radius: 18px;
  }

  .board-header {
    margin-bottom: 8px;
    gap: 6px;
  }

  .board-header h2 {
    font-size: 1rem;
  }

  .board {
    --cell-size: min(calc((100vw - 46px) / 8), calc((100dvh - 360px) / 8), 11vw);
    gap: 4px;
    padding: 6px;
    border-radius: 14px;
  }

  .effects-layer,
  .board-damage-text,
  .celebration-text {
    inset: 6px;
  }

  .tile {
    border-radius: 12px;
    font-size: clamp(1.05rem, 5vw, 1.35rem);
  }

  .tile::after {
    inset: 3px;
    border-radius: 10px;
  }

  .celebration-text {
    font-size: clamp(1.8rem, 9vw, 2.7rem);
  }

  .board-damage-text {
    font-size: clamp(1.35rem, 7vw, 2.1rem);
  }
}
