.match-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 8px 4px;
}

.match-shell {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

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

.match-controls {
  display: flex;
  gap: 6px;
}

.match-controls button,
.match-hud-toggle {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(120,160,255,0.35);
  background: linear-gradient(to bottom, rgba(40,40,40,0.9), rgba(10,10,10,0.95));
  color: #cfdfff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 3px 8px rgba(0,0,0,0.6);
  font-size: 16px;
  cursor: pointer;
}

.match-hud-toggle {
  font-size: 11px;
}

.match-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 14px;
  align-items: start;
}

.match-board-wrap {
  min-width: 0;
}

.match-panel {
  align-self: start;
}

.match-panel.minimized #bj-scoreboard {
  display: none;
}
#match-board {
  position: relative;
  width: fit-content;
  height: auto;
  max-width: 100%;
  max-height: none;
  margin: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: hidden;
}

#match-board::before {
  content: "";
  position: absolute;
  inset: -10%;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  --ripple-x: 50%;
  --ripple-y: 50%;
  background:
    radial-gradient(circle at var(--ripple-x) var(--ripple-y), rgba(170, 220, 255, 0.45) 0%, rgba(170,220,255,0.12) 18%, rgba(170,220,255,0) 38%);
  transform: scale(0.2);
}

#match-board.ripple-wave::before {
  animation: boardRipple 0.68s ease-out forwards;
}

#match-area {
  width: fit-content;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}

#match-grid {
  --size: 48px;
  display: grid;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: none;
  user-select: none;
}

.site-footer {
  display: none !important;
}

.combo-wrap {
  display: block;
  margin-top: 6px;
}

.time-wrap {
  display: block;
  margin-top: 6px;
}

.time-bar {
  margin-top: 6px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  overflow: hidden;
}

.time-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6eff8f 0%, #d8ff66 45%, #ffd166 75%, #ff7b66 100%);
  box-shadow: 0 0 14px rgba(150, 255, 170, 0.7);
  transition: width 0.1s linear;
}

.combo-bar {
  margin-top: 6px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  overflow: hidden;
}

.combo-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #58c7ff 0%, #c77dff 55%, #ffcc66 100%);
  box-shadow: 0 0 14px rgba(120, 220, 255, 0.8);
  transition: width 0.18s ease-out;
}

.match-cell {
  width: var(--size);
  height: var(--size);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  touch-action: none;
}

.match-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 200, 120, 0.8);
  box-shadow: 0 5px 12px rgba(0,0,0,0.4);
}

.match-cell.selected {
  border-color: rgba(120, 220, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(120, 220, 255, 0.35);
}

.match-cell.hint {
  border-color: rgba(120, 220, 255, 0.95);
  box-shadow:
    0 0 0 1px rgba(120, 220, 255, 0.55),
    0 0 18px rgba(120, 220, 255, 0.8);
  animation: hintPulse 0.9s ease-in-out infinite;
}

.match-cell.clearing {
  animation: clearPulse 0.18s ease-in-out 2;
}

.match-cell.explode-normal {
  animation:
    clearPulse 0.18s ease-in-out 2,
    explodeNormal 0.25s ease-out forwards;
}

.match-cell.explode-special {
  animation:
    clearPulse 0.2s ease-in-out 2,
    explodeSpecial 0.34s ease-out forwards;
}

.match-cell.explode-elemental {
  animation:
    clearPulse 0.2s ease-in-out 2,
    explodeElemental 0.42s ease-out forwards;
}

.match-cell.explode-elemental::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 11px;
  border: 2px solid rgba(170, 120, 255, 0.95);
  box-shadow:
    0 0 14px rgba(120, 220, 255, 0.85),
    0 0 28px rgba(175, 110, 255, 0.75);
  animation: elementalShockwave 0.42s ease-out forwards;
  pointer-events: none;
}

.match-cell.explode-special::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 10px;
  border: 2px solid rgba(255, 210, 110, 0.9);
  box-shadow: 0 0 20px rgba(255, 170, 70, 0.8);
  animation: specialShockwave 0.34s ease-out forwards;
  pointer-events: none;
}

.match-cell.teleport-out {
  animation: teleportOut 0.14s ease-in forwards;
}

.match-cell.teleport-in {
  animation: teleportIn 0.22s ease-out forwards;
}

.match-cell.special {
  position: relative;
  border-color: rgba(255, 210, 90, 0.95);
  box-shadow:
    0 0 0 1px rgba(255, 210, 90, 0.35),
    0 0 16px rgba(255, 190, 70, 0.65),
    inset 0 0 10px rgba(255, 220, 120, 0.22);
  animation: specialPulse 1.1s ease-in-out infinite;
}

.match-cell.special::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 1px solid rgba(255, 225, 150, 0.75);
  opacity: 0.75;
  animation: specialSpin 1.8s linear infinite;
  pointer-events: none;
}

.match-cell.special.special-power {
  border-color: rgba(120, 220, 255, 0.95);
  box-shadow:
    0 0 0 1px rgba(120, 220, 255, 0.35),
    0 0 16px rgba(90, 190, 255, 0.7),
    inset 0 0 10px rgba(140, 220, 255, 0.2);
}

.match-cell.special.special-danger {
  border-color: rgba(255, 90, 90, 0.95);
  box-shadow:
    0 0 0 1px rgba(255, 80, 80, 0.45),
    0 0 18px rgba(255, 60, 60, 0.85),
    inset 0 0 12px rgba(255, 110, 110, 0.22);
  animation: dangerPulse 0.85s ease-in-out infinite;
}

@keyframes dangerPulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.35);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes hintPulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.05);
    filter: brightness(1.25);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes boardRipple {
  0% {
    opacity: 0.75;
    transform: scale(0.2);
    filter: blur(0px);
  }
  55% {
    opacity: 0.45;
    transform: scale(1.2);
    filter: blur(1px);
  }
  100% {
    opacity: 0;
    transform: scale(2);
    filter: blur(2px);
  }
}

@keyframes clearPulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.9); opacity: 0.3; }
}

@keyframes explodeNormal {
  0% {
    transform: scale(1);
    filter: brightness(1);
    opacity: 1;
  }
  55% {
    transform: scale(1.12);
    filter: brightness(1.8);
    opacity: 1;
  }
  100% {
    transform: scale(0.75);
    filter: brightness(2.2);
    opacity: 0;
  }
}

@keyframes explodeSpecial {
  0% {
    transform: scale(1);
    filter: brightness(1);
    opacity: 1;
  }
  40% {
    transform: scale(1.18);
    filter: brightness(2.2);
    opacity: 1;
  }
  100% {
    transform: scale(0.62);
    filter: brightness(2.8);
    opacity: 0;
  }
}

@keyframes specialShockwave {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

@keyframes explodeElemental {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  45% {
    transform: scale(1.2);
    opacity: 1;
    filter: brightness(2.1) saturate(1.35);
  }
  100% {
    transform: scale(0.62);
    opacity: 0;
    filter: brightness(2.9) saturate(1.5);
  }
}

@keyframes elementalShockwave {
  0% {
    transform: scale(0.55);
    opacity: 1;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@keyframes teleportOut {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(80, 180, 255, 0);
  }
  100% {
    transform: scale(0.62);
    opacity: 0.28;
    filter: brightness(1.8);
    box-shadow: 0 0 18px rgba(80, 180, 255, 0.9);
  }
}

@keyframes teleportIn {
  0% {
    transform: scale(0.62);
    opacity: 0.22;
    filter: brightness(2);
    box-shadow: 0 0 24px rgba(80, 180, 255, 1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(80, 180, 255, 0);
  }
}

@keyframes specialPulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px rgba(255, 210, 90, 0.35),
      0 0 10px rgba(255, 190, 70, 0.45),
      inset 0 0 8px rgba(255, 220, 120, 0.16);
  }
  50% {
    transform: scale(1.04);
    box-shadow:
      0 0 0 1px rgba(255, 210, 90, 0.55),
      0 0 22px rgba(255, 190, 70, 0.9),
      inset 0 0 14px rgba(255, 220, 120, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px rgba(255, 210, 90, 0.35),
      0 0 10px rgba(255, 190, 70, 0.45),
      inset 0 0 8px rgba(255, 220, 120, 0.16);
  }
}

@keyframes specialSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.match-icon {
  width: 31px;
  height: 31px;
  image-rendering: pixelated;
  pointer-events: none;
}

#match-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.match-modal {
  min-width: 270px;
  background: #0d0f14;
  border: 1px solid rgba(255, 180, 80, 0.3);
  border-radius: 10px;
  padding: 20px 24px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.85);
}

.match-modal h2 {
  margin: 0 0 8px;
  color: #ffd27a;
  font-size: 18px;
}

.match-modal p {
  margin: 0 0 12px;
  color: #d8ddc9;
  font-size: 13px;
}

.match-difficulties button,
.match-modal button {
  margin: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255,180,80,0.35);
  background: linear-gradient(#1a1a1a, #0e0e0e);
  color: #f3f3f3;
  cursor: pointer;
}

.match-difficulties button:hover,
.match-modal button:hover {
  background: linear-gradient(#242424, #121212);
}

#bj-scoreboard {
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255, 200, 120, 0.45);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #ddd;
  backdrop-filter: blur(3px);
  box-shadow:
    0 0 10px rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(255,255,255,0.03);
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.score-row .label {
  color: #e6d8b8;
}

.score-row .value {
  color: #fff;
}

@media (max-width: 900px) {
  .match-main {
    grid-template-columns: 1fr;
  }

  .match-panel {
    justify-self: stretch;
    width: 100%;
  }
}

@media (max-width: 700px) {
  .match-shell {
    padding: 0;
  }

  .match-header {
    margin-bottom: 8px;
  }

  .match-main {
    gap: 8px;
  }

  .match-panel {
    justify-self: start;
    width: auto;
    max-width: 86vw;
  }

  .match-panel:not(.minimized) #bj-scoreboard {
    width: min(86vw, 330px);
    box-sizing: border-box;
    margin: 0;
  }

  #match-area {
    padding: 0;
  }

  #match-grid {
    --size: 34px;
    gap: 4px;
    padding: 6px;
  }

  .match-icon {
    width: 22px;
    height: 22px;
  }
}