/* =========================
   Reset And Base
   ========================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, #000000 0%, #3b2c55 42%, #000000 100%);
  color: #e2e8f0;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", sans-serif;
}

h1 {
  margin: 0 0 16px;
  text-align: center;
}

.page {
  width: min(100%, 1360px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: stretch;
}

/* =========================
   Main Layout
   ========================= */

.game-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.hud-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.board-column {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}

.board-container {
  position: relative;
  display: flex;
  align-items: flex-start;
  width: min(100%, 960px);
  margin-left: auto;
  padding-left: 70px;
}

/* =========================
   HUD Cards And Status
   ========================= */

.hud-card {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.92),
    rgba(30, 41, 59, 0.9)
  );
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.28);
}

#status,
#score,
#timer,
#moveTimer {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#status {
  margin-bottom: 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

#score {
  padding: 10px 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #f1f5f9;
  font-weight: 600;
  font-size: 1rem;
}

#timer {
  padding: 10px 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 1rem;
}

#moveTimer {
  padding: 6px 10px;
  border-radius: 8px;
  background: #b72357;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.95rem;
}

.hud-column #status,
.hud-column #score,
.hud-column #timer,
.hud-column #moveTimer {
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
}

/* =========================
   Buttons And Controls
   ========================= */

button {
  padding: 10px 14px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #1e293b;
  color: #f8fafc;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  min-width: 200px;
  max-width: 100%;
}

button:hover {
  border-color: #64748b;
}

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

.controls-row button {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(
    180deg,
    rgba(37, 99, 235, 0.95),
    rgba(29, 78, 216, 0.95)
  );
  color: #f8fafc;
  font-weight: 800;
  letter-spacing: 0.03em;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.controls-row button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.controls-row button:active {
  transform: translateY(0);
}

#pauseBtn {
  background: #1d4ed8;
  border-color: #000000;
}

#pauseBtn[aria-pressed="true"] {
  background: #dc2626;
  border-color: #991b1b;
}

#restartBtn {
  background: #334155;
}

#pauseBtn,
#restartBtn {
  display: block;
  width: min(100%, 320px);
  margin-inline: auto;
}

/* =========================
   Powerup Catalog
   ========================= */

.powerup-catalog {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.catalog-header h3 {
  margin: 0 0 6px 0;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.catalog-header p {
  margin: 0;
  color: #9fb0c6;
  font-size: 0.92rem;
  line-height: 1.45;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.catalog-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.55);
}

.catalog-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.22));
}

.catalog-item h4 {
  margin: 0 0 4px 0;
  font-size: 0.98rem;
  color: #f8fafc;
}

.catalog-item p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* =========================
   Board And Cells
   ========================= */

#board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 960px;
}

#board.paused {
  opacity: 0.85;
}

#board.paused .cell:hover {
  cursor: not-allowed;
  background: #111827;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid #475569;
  border-radius: 20%;
  background: #111827;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.9rem;
}

.cell:hover {
  background: #1f2937;
  cursor: pointer;
}

.pieces-wrap {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 1;
}

.cell-label {
  font-size: 0.72rem;
  line-height: 1;
  position: relative;
  z-index: 2;
}

.piece {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 10px rgba(255, 255, 255, 0.14);
}

.piece.player-1 {
  background: #3b82f6;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(59, 130, 246, 0.6);
}

.piece.player-2 {
  background: #ec4899;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(236, 72, 153, 0.6);
}

.piece.player-3 {
  background: #22c55e;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(34, 197, 94, 0.6);
}

.piece.player-4 {
  background: #eab308;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(234, 179, 8, 0.6);
}

.piece.player-5 {
  background: #a855f7;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(168, 85, 247, 0.6);
}

.piece.player-6 {
  background: #f97316;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.55),
    0 0 14px rgba(249, 115, 22, 0.6);
}

/* =========================
   Teleport Cells
   ========================= */

.cell.teleport-a,
.cell.teleport-b,
.cell.teleport-c,
.cell.teleport-d,
.cell.teleport-e {
  border-width: 4px;
  border-style: solid;
  background-image: radial-gradient(
    circle at 30% 25%,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.05) 24%,
    rgba(17, 24, 39, 0.92) 78%
  );
  box-shadow:
    inset 0 8px 12px rgba(255, 255, 255, 0.08),
    inset 0 -14px 18px rgba(0, 0, 0, 0.38);
}

.cell.teleport-a {
  border-color: #22d3ee;
  background-color: rgba(34, 211, 238, 0.28);
}

.cell.teleport-b {
  border-color: #ff00c8;
  background-color: rgba(255, 0, 200, 0.28);
}

.cell.teleport-c {
  border-color: #f59e0b;
  background-color: rgba(245, 158, 11, 0.28);
}

.cell.teleport-d {
  border-color: #f43f5e;
  background-color: rgba(244, 63, 94, 0.28);
}

.cell.teleport-e {
  border-color: #a78bfa;
  background-color: rgba(167, 139, 250, 0.28);
}

.cell.teleport-a:hover,
.cell.teleport-b:hover,
.cell.teleport-c:hover,
.cell.teleport-d:hover,
.cell.teleport-e:hover {
  filter: brightness(1.05);
}

.cell.teleport-pulse {
  animation: teleport-cell-pulse 1.2s ease-out;
}

@keyframes teleport-cell-pulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(34, 211, 238, 0.8),
      inset 0 0 15px rgba(34, 211, 238, 0.5);
    background-color: rgba(34, 211, 238, 0.15);
  }
  40% {
    box-shadow:
      0 0 0 10px rgba(34, 211, 238, 0.2),
      inset 0 0 25px rgba(34, 211, 238, 0.3);
    background-color: rgba(34, 211, 238, 0.2);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(34, 211, 238, 0),
      inset 0 0 0 rgba(34, 211, 238, 0);
    background-color: rgba(34, 211, 238, 0);
  }
}

/* =========================
   Fortress Cell Powerup
   ========================= */

.cell.fortress-cell {
  border-width: 3px;
  border-style: dashed;
  border-color: #39ff14;
  background: linear-gradient(
    135deg,
    rgba(57, 255, 20, 0.08) 0%,
    rgba(57, 255, 20, 0.02) 100%
  );
  box-shadow:
    0 0 12px rgba(57, 255, 20, 0.5),
    inset 0 0 8px rgba(57, 255, 20, 0.15);
  animation: fortress-pulse-glow 2s ease-in-out infinite;
}

.cell.fortress-cell:hover {
  border-color: #76ff03;
  box-shadow:
    0 0 20px rgba(57, 255, 20, 0.8),
    inset 0 0 12px rgba(57, 255, 20, 0.25);
}

@keyframes fortress-pulse-glow {
  0%,
  100% {
    box-shadow:
      0 0 12px rgba(57, 255, 20, 0.5),
      inset 0 0 8px rgba(57, 255, 20, 0.15);
  }
  50% {
    box-shadow:
      0 0 20px rgba(57, 255, 20, 0.8),
      inset 0 0 15px rgba(57, 255, 20, 0.3);
  }
}

.cell.fortress-pulse {
  animation: fortress-cell-activate 1.2s ease-out;
}

@keyframes fortress-cell-activate {
  0% {
    box-shadow:
      0 0 0 0 rgba(57, 255, 20, 0.9),
      inset 0 0 20px rgba(57, 255, 20, 0.4);
    background-color: rgba(57, 255, 20, 0.15);
  }
  50% {
    box-shadow:
      0 0 0 12px rgba(57, 255, 20, 0),
      inset 0 0 30px rgba(57, 255, 20, 0.3);
    background-color: rgba(57, 255, 20, 0.2);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(57, 255, 20, 0),
      inset 0 0 0 rgba(57, 255, 20, 0);
    background-color: rgba(57, 255, 20, 0);
  }
}

#fortressCellIndicator {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 2px solid #39ff14;
  border-radius: 12px;
  background: rgba(57, 255, 20, 0.12);
  box-shadow:
    0 0 24px rgba(57, 255, 20, 0.6),
    inset 0 0 12px rgba(57, 255, 20, 0.2);
  z-index: 10;
  animation: fortress-appear 0.6s ease-out;
  pointer-events: none;
}

.fortress-cell-icon {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 8px rgba(57, 255, 20, 0.9));
  animation: fortress-icon-glow 1.2s ease-in-out infinite;
}

.fortress-cell-text {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #39ff14;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.7);
}

.fortress-cell-player {
  font-size: 0.75rem;
  font-weight: 600;
  color: #76ff03;
  text-shadow: 0 0 4px rgba(57, 255, 20, 0.5);
}

@keyframes fortress-appear {
  0% {
    opacity: 0;
    transform: scale(0.8) translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

@keyframes fortress-icon-glow {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(57, 255, 20, 0.9));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 14px rgba(57, 255, 20, 1));
  }
}

/* =========================
   Row Ripper Powerup
   ========================= */

.row-ripper-indicator {
  position: absolute;
  left: 6px;
  width: 56px;
  height: 56px;
  background-image: url("./powerUpIcons/rowRipper.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: 2px solid #fbbf24;
  border-radius: 10px;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.75);
  transition: top 0.3s ease-out;
  pointer-events: none;
  z-index: 10;
}

.row-ripper-active {
  animation: row-ripper-flash 0.5s ease-out;
  box-shadow:
    inset 0 0 30px rgba(251, 191, 36, 1),
    0 0 40px rgba(251, 191, 36, 0.9) !important;
  background-color: rgba(251, 191, 36, 0.4) !important;
}

.cell.row-ripper-pulse {
  animation: row-ripper-cell-pulse 0.45s ease-out;
}

@keyframes row-ripper-flash {
  0% {
    background-color: rgba(251, 191, 36, 0.5);
    box-shadow:
      inset 0 0 30px rgba(251, 191, 36, 1),
      0 0 40px rgba(251, 191, 36, 0.9),
      0 0 60px rgba(251, 191, 36, 0.7);
    transform: scale(1);
  }
  30% {
    background-color: rgba(251, 191, 36, 0.6);
    box-shadow:
      inset 0 0 40px rgba(251, 191, 36, 1),
      0 0 60px rgba(251, 191, 36, 1),
      0 0 80px rgba(251, 191, 36, 0.8);
  }
  60% {
    background-color: rgba(251, 191, 36, 0.4);
    box-shadow:
      inset 0 0 25px rgba(251, 191, 36, 0.8),
      0 0 40px rgba(251, 191, 36, 0.6);
  }
  100% {
    background-color: transparent;
    box-shadow: inset 0 0 0 rgba(251, 191, 36, 0);
  }
}

@keyframes row-ripper-cell-pulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(251, 191, 36, 0.9),
      inset 0 0 20px rgba(251, 191, 36, 0.5);
    background-color: rgba(251, 191, 36, 0.2);
  }
  50% {
    box-shadow:
      0 0 0 14px rgba(251, 191, 36, 0),
      inset 0 0 35px rgba(251, 191, 36, 0.4);
    background-color: rgba(251, 191, 36, 0.25);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(251, 191, 36, 0),
      inset 0 0 0 rgba(251, 191, 36, 0);
    background-color: rgba(251, 191, 36, 0);
  }
}

/* =========================
   Transition Banner
   ========================= */

#transitionFx {
  width: min(100%, 960px);
  min-height: 58px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.95),
    rgba(30, 41, 59, 0.95)
  );
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) scale(1);
  overflow: hidden;
  isolation: isolate;
  z-index: 99999;
}

#transitionFx.active {
  animation: transition-banner-in 1100ms ease forwards;
}

#transitionFx .rocket-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  background: radial-gradient(circle, #fb7185 0%, #f97316 70%);
  color: #111827;
  position: relative;
  z-index: 2;
}

#transitionFx .transition-label {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#transitionFx .rocket-trail {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(251, 113, 133, 0.95) 0%,
    rgba(251, 191, 36, 0.85) 45%,
    rgba(56, 189, 248, 0) 100%
  );
  transform-origin: left center;
  z-index: 2;
}

#transitionFx::before,
#transitionFx::after,
#transitionFx .rocket-mark::before,
#transitionFx .rocket-mark::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

#transitionFx::before {
  width: 250px;
  height: 250px;
  left: -46px;
  top: 50%;
  transform: translateY(-50%) scale(0.2);
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.55) 0%,
    rgba(56, 189, 248, 0.1) 45%,
    rgba(56, 189, 248, 0) 70%
  );
  z-index: 0;
}

#transitionFx::after {
  width: 220px;
  height: 220px;
  right: 20%;
  top: 50%;
  transform: translateY(-50%) scale(0.2);
  background: radial-gradient(
    circle,
    rgba(236, 72, 153, 0.5) 0%,
    rgba(236, 72, 153, 0.12) 46%,
    rgba(236, 72, 153, 0) 72%
  );
  z-index: 0;
}

#transitionFx .rocket-mark::before {
  width: 20px;
  height: 20px;
  left: -24px;
  top: 50%;
  transform: translateY(-50%) scale(0.2);
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 24px #22d3ee;
}

#transitionFx .rocket-mark::after {
  width: 16px;
  height: 16px;
  right: -22px;
  top: 50%;
  transform: translateY(-50%) scale(0.2);
  border-radius: 50%;
  background: #facc15;
  box-shadow: 0 0 22px #facc15;
}

#transitionFx.active .rocket-mark {
  animation: rocket-pulse 450ms ease-in-out 2;
  box-shadow:
    0 0 14px rgba(251, 113, 133, 0.9),
    0 0 28px rgba(249, 115, 22, 0.7);
}

#transitionFx.active .rocket-trail {
  animation: trail-stretch 900ms ease-out;
}

#transitionFx.active::before {
  animation: neon-blast-cyan 900ms ease-out;
}

#transitionFx.active::after {
  animation: neon-blast-pink 900ms ease-out 120ms;
}

#transitionFx.active .rocket-mark::before {
  animation: neon-spark-cyan 700ms ease-out;
}

#transitionFx.active .rocket-mark::after {
  animation: neon-spark-gold 700ms ease-out 80ms;
}

@keyframes transition-banner-in {
  0% {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  75% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
  }
}

@keyframes rocket-pulse {
  0% {
    transform: translateX(0) scale(1);
  }
  50% {
    transform: translateX(6px) scale(1.06);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

@keyframes trail-stretch {
  0% {
    transform: scaleX(0.2);
    opacity: 0.2;
  }
  45% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(0.55);
    opacity: 0.35;
  }
}

@keyframes neon-blast-cyan {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.2);
    filter: blur(2px);
  }
  25% {
    opacity: 0.95;
    transform: translateY(-50%) scale(1);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) scale(1.45);
    filter: blur(3px);
  }
}

@keyframes neon-blast-pink {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.2);
  }
  30% {
    opacity: 0.9;
    transform: translateY(-50%) scale(0.95);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) scale(1.35);
  }
}

@keyframes neon-spark-cyan {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.1);
  }
  35% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-26px, -50%) scale(0.2);
  }
}

@keyframes neon-spark-gold {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.1);
  }
  35% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(22px, -50%) scale(0.2);
  }
}

/* =========================
   Powerup HUD And Indicators
   ========================= */

.powerup-panel {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  color: #dbeafe;
  font-weight: 700;
  min-height: 48px;
}

.hud-column .powerup-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  min-height: 56px;
}

.powerup-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.12);
}

.hud-column .powerup-entry {
  width: 100%;
  justify-content: flex-start;
}

.powerup-entry img {
  width: 28px;
  height: 28px;
}

.powerup-entry .ptext {
  font-size: 0.9rem;
  color: #e6eef8;
}

.powerup-indicator {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  z-index: 120000;
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
}

.powerup-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.powerup-text {
  font-weight: 800;
  color: #ffffff;
  font-size: 0.9rem;
}

/* =========================
   Move History
   ========================= */

.move-history-box {
  padding: 12px 14px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  color: #e6eef8;
  max-height: 220px;
  overflow: auto;
}

.move-history-title {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.move-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.move-item {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  color: #cfe7ff;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.move-item.latest {
  background: linear-gradient(
    90deg,
    rgba(99, 102, 241, 0.12),
    rgba(14, 165, 233, 0.08)
  );
  border-color: rgba(99, 102, 241, 0.28);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

.move-time {
  font-size: 0.75rem;
  color: #9fbbe6;
  margin-left: 8px;
  opacity: 0.9;
}

/* =========================
   Modal System
   ========================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.15), transparent 34%),
    rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  animation: fade-in 0.25s ease-out;
}

.modal-content {
  width: min(100%, 920px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 32px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.98),
    rgba(30, 41, 59, 0.96)
  );
  color: #e2e8f0;
  box-shadow: 0 30px 90px rgba(2, 6, 23, 0.52);
  text-align: center;
  animation: slide-up 0.35s ease-out;
}

.modal-content h2 {
  margin: 0 0 16px 0;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-content .modal-subtitle {
  margin: 0 0 24px 0;
  font-size: 1rem;
  color: #94a3b8;
  font-weight: 500;
}

#rulesModal .modal-content {
  text-align: left;
}

#rulesModal h1 {
  margin: 0 0 12px 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rules-display {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rules {
  margin: 0;
  line-height: 1.7;
  color: #cbd5e1;
  white-space: pre-line;
}

.play-btn {
  align-self: flex-end;
  padding: 14px 20px;
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: 14px;
  background: linear-gradient(135deg, #f97316 0%, #fb7185 100%);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.play-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 30px rgba(249, 115, 22, 0.24);
}

.play-btn:active {
  transform: translateY(0);
}

.player-selector {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.player-btn {
  min-width: 132px;
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
  border: 1px solid rgba(34, 197, 94, 0.36);
  color: #ffffff;
  padding: 16px 22px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.player-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.22);
}

.player-btn:active {
  transform: translateY(0);
}

.player-btn-number {
  font-size: 1.5rem;
  font-weight: 900;
}

.player-btn-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================
   Game Over Modal
   ========================= */

.game-over-overlay {
  z-index: 200000;
  background:
    radial-gradient(circle at top, rgba(244, 114, 182, 0.26), transparent 28%),
    radial-gradient(
      circle at center,
      rgba(56, 189, 248, 0.18),
      transparent 48%
    ),
    rgba(2, 6, 23, 0.9);
}

.game-over-card {
  position: relative;
  width: min(100%, 560px);
  padding: 38px 30px 32px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  background:
    radial-gradient(circle at top, rgba(251, 191, 36, 0.2), transparent 36%),
    radial-gradient(
      circle at bottom,
      rgba(56, 189, 248, 0.14),
      transparent 42%
    ),
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(12, 18, 32, 0.98));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 32px 90px rgba(2, 6, 23, 0.7),
    0 0 80px rgba(251, 191, 36, 0.12);
  overflow: hidden;
  animation: game-over-pop 0.42s ease-out;
}

.game-over-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: linear-gradient(
    135deg,
    rgba(251, 191, 36, 0.24),
    transparent 22%,
    transparent 78%,
    rgba(56, 189, 248, 0.24)
  );
  opacity: 0.85;
  pointer-events: none;
}

.game-over-card > * {
  position: relative;
  z-index: 1;
}

.game-over-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.34);
  background: rgba(251, 191, 36, 0.14);
  color: #fde68a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.game-over-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.18);
}

.game-over-message {
  margin-bottom: 22px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #dbeafe;
}

.game-over-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 26px;
}

.game-over-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.62);
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 700;
}

.game-over-btn {
  align-self: center;
  min-width: 180px;
  box-shadow: 0 18px 30px rgba(249, 115, 22, 0.24);
}

/* =========================
   Animation Utilities
   ========================= */

.piece.pop {
  transform: scale(1.25);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.25, 1);
}

.fly-piece {
  position: fixed;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  z-index: 200000;
  pointer-events: none;
  transform: translate(0, 0) scale(1);
  transition:
    transform 420ms ease-out,
    opacity 420ms ease-out;
}

.cell.cell-explode {
  animation: explode-flash 420ms ease-out;
}

.confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  z-index: 200000;
  pointer-events: none;
  animation: confetti-fall 3s linear forwards;
}

@keyframes explode-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.12);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.14);
    transform: scale(1.03);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    transform: scale(1);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes game-over-pop {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.9);
  }
  70% {
    transform: translateY(-4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================
   Responsive Design
   ========================= */

@media (max-width: 1100px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .board-column {
    justify-content: center;
  }

  .board-container {
    margin-left: 0;
    padding-left: 65px;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .piece {
    width: 25px;
    height: 25px;
  }
}

@media (max-width: 768px) {
  .piece {
    width: 20px;
    height: 20px;
    border-width: 1.5px;
  }
}

@media (max-width: 480px) {
  .piece {
    width: 10px;
    height: 10px;
    border-width: 0.5px;
  }
}

@media (max-width: 360px) {
  .piece {
    width: 10px;
    height: 10px;
  }
}

/* =========================
   Animations - hacker ++
   ========================= */

/* PLACING PIECE ANIMATION */

.piece-pop {
  animation: elasticPop 0.46s cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: center;
}

.pieces-wrap.count-4 {
  animation: spinOrbit 1.4s linear infinite;
}

.cell.place-animate {
  animation: place-cell-pulse 0.46s ease-out;
}

.cell.explosion-animate {
  animation: explosion-cell-burst 0.16s cubic-bezier(0.1, 0.8, 0.25, 1);
}

.cell.bond-animate {
  animation: bond-cell-surge 0.22s ease-out;
}

.explosion-shard {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 3;
}

@keyframes elasticPop {
  0% {
    transform: scale(0.35);
    opacity: 0;
    filter: brightness(1.3);
  }
  55% {
    transform: scale(1.32); /* Overtravel scale for structural weight */
    opacity: 1;
    filter: brightness(1.55);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes place-cell-pulse {
  0% {
    transform: scale(0.88);
    box-shadow:
      0 0 0 0 rgba(96, 165, 250, 0.34),
      inset 0 0 0 0 rgba(255, 255, 255, 0);
    filter: brightness(1);
  }
  45% {
    transform: scale(1.1);
    box-shadow:
      0 0 0 14px rgba(96, 165, 250, 0.14),
      inset 0 0 20px rgba(255, 255, 255, 0.18);
    filter: brightness(1.18);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(96, 165, 250, 0),
      inset 0 0 0 0 rgba(255, 255, 255, 0);
    filter: brightness(1);
  }
}

@keyframes explosion-cell-burst {
  0% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  45% {
    transform: scale(1.14);
    filter: brightness(1.5);
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.45);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

@keyframes bond-cell-surge {
  0% {
    transform: scale(0.96);
    filter: saturate(1);
  }
  45% {
    transform: scale(1.03);
    filter: saturate(1.2) brightness(1.1);
  }
  100% {
    transform: scale(1);
    filter: saturate(1);
  }
}

/* ANIMATING BONDING  */

/* ORBITAL LAYOUTS */

/* When 2 Atoms are there : Balanced horizontal spin */
.pieces-wrap.count-2 {
  animation: spinOrbit 3s linear infinite;
}
.pieces-wrap.count-2 .piece:nth-child(1) {
  transform: translateX(-10px);
}
.pieces-wrap.count-2 .piece:nth-child(2) {
  transform: translateX(10px);
}

/* When 3 Atoms are there : Rapid delta triangle  */
.pieces-wrap.count-3 {
  display: block;
  width: 68px;
  height: 68px;
  flex-wrap: nowrap;
  animation:
    triOrbit 2.8s linear infinite,
    triClusterPulse 1.8s ease-in-out infinite;
  transform-origin: center;
}
.pieces-wrap.count-3 .piece {
  position: absolute;
  animation: triDotGlow 1.8s ease-in-out infinite;
}
.pieces-wrap.count-3 .piece:nth-child(1) {
  top: 14px;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: 0s;
}
.pieces-wrap.count-3 .piece:nth-child(2) {
  top: 48px;
  left: 18px;
  transform: translate(-50%, -50%);
  animation-delay: 0.2s;
}
.pieces-wrap.count-3 .piece:nth-child(3) {
  top: 48px;
  left: 50px;
  transform: translate(-50%, -50%);
  animation-delay: 0.4s;
}

@keyframes spinOrbit {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes triOrbit {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.04);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes triClusterPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.16));
  }
}

@keyframes triDotGlow {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(15, 23, 42, 0.55),
      0 0 10px rgba(255, 255, 255, 0.12);
    opacity: 0.9;
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(15, 23, 42, 0.55),
      0 0 18px rgba(255, 255, 255, 0.32);
    opacity: 1;
  }
}

/* Animating Exploding */

@media (prefers-reduced-motion: reduce) {
  .piece-pop,
  .cell.place-animate,
  .cell.explosion-animate,
  .cell.bond-animate,
  .pieces-wrap.count-2,
  .pieces-wrap.count-3,
  .pieces-wrap.count-4,
  .cell.teleport-pulse,
  .cell.fortress-cell,
  .cell.fortress-pulse,
  .cell.row-ripper-pulse,
  #transitionFx.active {
    animation: none !important;
    transition: none !important;
  }
}
