:root {
  color-scheme: light;
  --bg: #dff6ff;
  --panel: #ffffff;
  --panel-2: #f3fbff;
  --line: #3d5a68;
  --text: #24323a;
  --muted: #607784;
  --accent: #ffbf2f;
  --red: #ff4e55;
  --green: #20d873;
  --blue: #2f72ff;
  --violet: #a24dff;
  --steel: #9fb9c2;
  --board-bg: #b8ccd1;
  --ink: #1f3139;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 191, 47, 0.55), transparent 18%),
    radial-gradient(circle at 85% 10%, rgba(32, 216, 115, 0.24), transparent 20%),
    linear-gradient(180deg, #f8fdff 0%, #dff6ff 48%, #c9efff 100%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.app-screen {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.title-screen,
.stage-select-screen {
  min-height: calc(100vh - 48px);
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 0 rgba(61, 90, 104, 0.18), 0 24px 70px rgba(47, 114, 255, 0.16);
}

.title-screen {
  display: grid;
  place-items: center;
}

.title-content {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(920px, 100%);
  padding: 32px 20px;
  text-align: center;
}

.title-kicker {
  color: var(--red);
  font-size: 13px;
  font-weight: 950;
}

.title-content h1,
.select-header h1 {
  font-size: clamp(30px, 6vw, 64px);
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 4px 0 rgba(255, 191, 47, 0.35);
}

.title-content h1 {
  white-space: nowrap;
}

.title-content .primary-button {
  width: min(280px, 100%);
}

.stage-select-screen {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 24px;
}

.select-header {
  display: grid;
  grid-template-columns: 140px 1fr minmax(180px, 260px);
  align-items: center;
  gap: 16px;
}

.select-header h1 {
  text-align: center;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.sheet-actions .ghost-button {
  min-height: 38px;
  margin-top: 0;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.sheet-applied-at {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.stage-loading-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff7c7;
}

.stage-loading-spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 4px solid rgba(61, 90, 104, 0.22);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: stage-loading-spin 760ms linear infinite;
}

.stage-loading-copy {
  display: grid;
  gap: 3px;
}

.stage-loading-copy strong {
  color: var(--ink);
  font-size: 16px;
}

.stage-loading-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stage-select-skeleton {
  position: relative;
  min-height: 128px;
  overflow: hidden;
  border: 2px solid rgba(61, 90, 104, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(#dce9ed 0 0) 16px 24px / 46% 25px no-repeat,
    linear-gradient(#e8f1f4 0 0) 16px 65px / 64% 14px no-repeat,
    linear-gradient(#e8f1f4 0 0) 16px 91px / 52% 14px no-repeat,
    #ffffff;
}

.stage-select-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.85) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: stage-loading-shimmer 1.2s ease-in-out infinite;
}

.stage-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 128px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 0 rgba(61, 90, 104, 0.22);
  text-align: left;
}

.stage-select-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(61, 90, 104, 0.22);
}

.stage-select-button.loading {
  cursor: wait;
  opacity: 0.7;
}

.stage-select-button.loading:hover {
  transform: none;
  box-shadow: 0 5px 0 rgba(61, 90, 104, 0.22);
}

.stage-card-copy {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}

.stage-select-button strong {
  font-size: 26px;
  line-height: 1.2;
  color: var(--ink);
}

.stage-objectives {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  width: min(180px, 38vw);
}

.stage-objectives .objective-sequence {
  justify-content: end;
  gap: 5px;
}

.stage-objectives .objective-icon {
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  background: #fff7c7;
  font-size: 13px;
}

.stage-objectives .objective-arrow {
  font-size: 18px;
}

.stage-select-button small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.stage-load-chip {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f1f4;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
}

@keyframes stage-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes stage-loading-shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-loading-spinner,
  .stage-select-skeleton::after {
    animation: none;
  }
}

.stage {
  position: relative;
  width: min(1240px, 100%);
  margin: 0 auto;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 0 rgba(61, 90, 104, 0.18), 0 24px 70px rgba(47, 114, 255, 0.16);
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
}

h1,
h2,
p {
  margin: 0;
}

.play-area {
  display: grid;
  grid-template-columns: 1fr;
  padding: 24px;
}

.current-objective {
  display: grid;
  place-items: center;
  width: min(760px, 100%);
  min-height: clamp(150px, 28vw, 260px);
  color: var(--text);
}

.objective-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vw, 28px);
  width: 100%;
}

.current-objective .objective-icon {
  width: clamp(150px, 28vw, 260px);
  height: clamp(150px, 28vw, 260px);
  border: 2px solid var(--accent);
  background: #20242a;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.objective-arrow {
  color: var(--accent);
  font-size: clamp(42px, 8vw, 76px);
  font-weight: 950;
}

.objective-icon {
  display: grid;
  grid-template-columns: repeat(2, 1em);
  grid-template-rows: repeat(2, 1em);
  align-content: center;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 0.12em;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  font-size: clamp(14px, 18cqw, 32px);
}

.objective-icon .objective-text {
  display: grid;
  place-items: center;
  width: 1em;
  height: 1em;
  color: var(--text);
  font-size: inherit;
  font-weight: 950;
  line-height: 1;
}

.objective-text.red {
  color: var(--red);
}

.objective-text.green {
  color: var(--green);
}

.objective-text.blue {
  color: var(--blue);
}

.objective-text.violet {
  color: var(--violet);
}

.primary-button,
.ghost-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  font-weight: 900;
  border-radius: 8px;
  box-shadow: 0 4px 0 rgba(36, 50, 58, 0.22);
}

.primary-button {
  background: var(--accent);
  color: #2c2304;
  border: 2px solid var(--ink);
}

.ghost-button {
  border: 2px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.board-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 620px);
  justify-content: center;
  align-items: start;
  align-content: start;
  gap: 20px;
  min-width: 0;
}

.game-info {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 100%;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff7c7;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.42);
}

.game-stage-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.info-label {
  color: #d63d44;
  font-size: 11px;
  font-weight: 950;
}

.game-stage-copy strong {
  font-size: 24px;
  line-height: 1.15;
}

.game-stage-copy small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.game-info .ghost-button {
  align-self: end;
  min-height: 40px;
  margin-top: 18px;
}

.game-board-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
}

.column-stocks {
  display: grid;
  gap: var(--board-gap);
  width: 100%;
  padding-inline: calc(var(--board-border) + var(--board-padding));
  grid-template-columns: var(--board-columns);
}

.column-stocks span {
  min-height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(61, 90, 104, 0.28);
  border-radius: 6px 6px 0 0;
  background: var(--board-bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.board-objective {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.board-objective .objective-card {
  max-width: 100%;
  justify-items: start;
  padding: 6px 10px;
}

.board-objective .objective-sequence {
  flex-wrap: nowrap;
  justify-content: start;
  gap: 6px;
  width: auto;
}

.board-objective .objective-arrow {
  font-size: 20px;
}

.objective-card {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  opacity: 0.58;
}

.objective-card.active {
  border-color: var(--ink);
  background: #fff7c7;
  box-shadow: 0 0 0 3px rgba(255, 191, 47, 0.38);
  opacity: 1;
}

.objective-card.done {
  opacity: 0.36;
}

.objective-card .objective-icon {
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink);
  background: #f7fdff;
  font-size: 16px;
}

.one-stroke-badge {
  justify-self: start;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--accent);
  color: #2c2304;
  font-size: 12px;
  font-weight: 950;
  animation: one-stroke-pulse 1.6s ease-in-out infinite;
}

.one-stroke-chip {
  justify-self: start;
  padding: 2px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--accent);
  color: #2c2304;
  font-size: 11px;
  font-weight: 950;
}

.board-shell.one-stroke .board {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.28),
    0 0 0 3px rgba(255, 191, 47, 0.55),
    0 0 22px rgba(255, 191, 47, 0.4);
}

@keyframes one-stroke-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 191, 47, 0.6);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(255, 191, 47, 0);
  }
}

.hidden {
  display: none !important;
}

.board-shell {
  position: relative;
  width: min(100%, 620px);
  --board-gap: 6px;
  --board-padding: 8px;
  --board-border: 2px;
  --board-columns: repeat(8, minmax(44px, 1fr));
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: var(--board-columns);
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: var(--board-gap);
  width: 100%;
  aspect-ratio: 1 / 0.86;
  padding: var(--board-padding);
  border: var(--board-border) solid rgba(61, 90, 104, 0.28);
  border-radius: 8px;
  background: var(--board-bg);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  touch-action: none;
}

.phase-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 30;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fff7c7;
  color: var(--red);
  font-size: clamp(28px, 7vw, 58px);
  font-weight: 950;
  white-space: nowrap;
  box-shadow: 0 8px 0 rgba(61, 90, 104, 0.22);
  pointer-events: none;
}

.timer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  align-items: center;
  gap: 10px;
  width: min(100%, 620px);
}

.timer-bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent), var(--red));
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 100ms linear;
}

.log {
  width: min(100%, 620px);
  min-height: 38px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.finish-button {
  min-height: 38px;
  margin-top: 0;
  font-size: 13px;
  background: #ff7043;
  color: #ffffff;
}

.finish-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(223, 246, 255, 0.78);
}

.result-panel {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 14px;
  width: min(520px, calc(100% - 40px));
  padding: 34px 24px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 0 rgba(61, 90, 104, 0.22), 0 24px 80px rgba(47, 114, 255, 0.2);
  text-align: center;
}

.result-panel span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
}

.result-panel strong {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  font-size: clamp(28px, 7vw, 48px);
  line-height: 1;
}

.result-reason {
  width: 100%;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
}

.result-panel .primary-button {
  width: min(260px, 100%);
}

.result-overlay.game-over .result-panel {
  border-color: var(--red);
}

.result-overlay.game-over .result-panel span {
  color: var(--red);
}

.result-overlay.game-over .primary-button {
  background: var(--red);
  color: #fff;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.22);
  transition: transform 140ms ease, border-color 140ms ease, opacity 220ms ease;
}

.cell.path {
  background: rgba(255, 255, 255, 0.28);
}

.cell.empty {
  border-color: rgba(61, 90, 104, 0.2);
  background:
    radial-gradient(circle at 50% 50%, rgba(32, 216, 115, 0.2), transparent 62%),
    rgba(255, 255, 255, 0.22);
}

.cell.route-open {
  border-color: var(--green);
  background: rgba(78, 184, 127, 0.26);
  box-shadow: inset 0 0 0 2px rgba(78, 184, 127, 0.55), 0 0 16px rgba(78, 184, 127, 0.3);
}

.cell.route-scan {
  border-color: var(--accent);
  background: rgba(255, 204, 77, 0.3);
  box-shadow: inset 0 0 0 2px rgba(255, 204, 77, 0.62), 0 0 18px rgba(255, 204, 77, 0.28);
}

.cell.selected {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.cell.dragging {
  border-color: var(--accent);
  transform: scale(0.98);
}

.cell.swap-hidden .piece {
  visibility: hidden;
}

.cell.match-warning {
  z-index: 3;
  border-color: var(--accent);
}

.cell.match-warning .piece {
  animation: match-ping 180ms ease-in-out 3;
}

.cell.match-warning .piece::before {
  filter: brightness(1.45);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.78), 0 0 28px rgba(255, 204, 77, 0.7);
}

.cell.explode {
  z-index: 4;
  opacity: 1;
  transform: scale(1.05);
  border-color: var(--accent);
}

.cell.explode::after {
  content: "";
  position: absolute;
  inset: -18%;
  z-index: 4;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 12%, rgba(255, 204, 77, 0.9) 13% 26%, rgba(215, 77, 77, 0.65) 27% 44%, transparent 45%),
    conic-gradient(from 10deg, transparent 0 8%, rgba(255, 255, 255, 0.9) 9% 12%, transparent 13% 24%, rgba(255, 204, 77, 0.95) 25% 29%, transparent 30% 44%, rgba(215, 77, 77, 0.8) 45% 50%, transparent 51%);
  pointer-events: none;
  animation: blast 620ms ease-out forwards;
}

.cell.explode .piece {
  animation: piece-pop 620ms ease-out forwards;
}

.cell.hostage-area {
  box-shadow: inset 0 0 0 3px rgba(215, 77, 77, 0.8);
}

.piece {
  position: relative;
  display: grid;
  place-items: center;
  width: 78%;
  aspect-ratio: 1;
  color: #fff;
  filter: drop-shadow(0 5px 0 rgba(36, 50, 58, 0.16));
  transform: translate3d(0, 0, 0);
  opacity: 1;
  transition:
    transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1.2),
    opacity 180ms ease;
  will-change: transform;
}

.piece.swapping {
  z-index: 5;
  transition-duration: 260ms;
  filter: brightness(1.22);
}

.piece.falling {
  opacity: 0.92;
  transform: translate3d(0, calc(-1 * var(--fall-distance, 1) * (100% + 6px)), 0) scale(0.98);
  transition:
    transform 680ms cubic-bezier(0.16, 0.92, 0.18, 1.08),
    opacity 260ms ease;
}

.piece.fall-spawned {
  opacity: 0;
  transform: translate3d(0, calc(-1 * var(--fall-distance, 1) * (100% + 6px)), 0) scale(0.72);
}

.swap-ghost {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  opacity: 1;
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1.2);
}

.piece::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.26), inset 0 -5px 0 rgba(36, 50, 58, 0.14);
}

.piece.circle::before {
  border-radius: 50%;
}

.piece.square::before {
  border-radius: 5px;
}

.piece.diamond::before {
  transform: rotate(45deg) scale(0.82);
}

.piece.triangle::before {
  clip-path: polygon(50% 5%, 96% 92%, 4% 92%);
}

.piece-pattern {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* 形いっぱいに模様を広げるため、ピース形状に合わせてクリップ */
.piece.circle .piece-pattern {
  border-radius: 50%;
}

.piece.square .piece-pattern {
  border-radius: 5px;
}

.piece.diamond .piece-pattern {
  /* 本体の回転・拡大後の領域に合わせ、四隅まで模様を届かせる */
  inset: -8%;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.piece.triangle .piece-pattern {
  clip-path: polygon(50% 5%, 96% 92%, 4% 92%);
}

/* 模様の塗り（ピース上では白いオーバーレイとして表示） */
.pattern-dot {
  background-image: radial-gradient(circle, #fff 32%, transparent 36%);
  background-size: 25% 25%;
  background-position: center;
}

.pattern-wave {
  /* 継ぎ目を無くすため、要素全体を連続した波線1枚のSVGで塗る */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='%23fff' stroke-width='6' stroke-linecap='round'%3E%3Cpath d='M0 8 Q6 4 12 8 T24 8 T36 8 T48 8'/%3E%3Cpath d='M0 24 Q6 20 12 24 T24 24 T36 24 T48 24'/%3E%3Cpath d='M0 40 Q6 36 12 40 T24 40 T36 40 T48 40'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}

.pattern-rain {
  background-image: linear-gradient(
    90deg,
    transparent 0 13%,
    #fff 13% 25%,
    transparent 25% 43%,
    #fff 43% 55%,
    transparent 55% 73%,
    #fff 73% 85%,
    transparent 85% 100%
  );
}

.pattern-two-tone {
  background-image: none;
}

.piece-pattern.pattern-two-tone::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.piece.triangle .pattern-two-tone::before {
  /* 45度の境界を右へ10%ずらし、三角形内でほぼ同じ面積に見せる */
  clip-path: polygon(0 0, 100% 0, 100% 10%, 10% 100%, 0 100%);
}

.piece.special {
  color: var(--steel);
}

.piece.hostage {
  color: #ffd9a0;
}

.piece.hostage::before {
  border-radius: 46% 46% 20% 20%;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), inset 0 -5px 0 rgba(36, 50, 58, 0.18);
}

.piece-face {
  position: relative;
  z-index: 1;
  color: #5b3a16;
  font-size: clamp(14px, 2.8vw, 26px);
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.piece.steel {
  color: #8fa3ad;
}

.piece.steel::before {
  border-radius: 4px;
  background:
    radial-gradient(circle at 14% 14%, rgba(255, 255, 255, 0.8) 0 6%, transparent 8%),
    radial-gradient(circle at 86% 14%, rgba(255, 255, 255, 0.8) 0 6%, transparent 8%),
    radial-gradient(circle at 14% 86%, rgba(36, 50, 58, 0.5) 0 6%, transparent 8%),
    radial-gradient(circle at 86% 86%, rgba(36, 50, 58, 0.5) 0 6%, transparent 8%),
    linear-gradient(135deg, #b9cad2 0%, #8fa3ad 55%, #758b95 100%);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(36, 50, 58, 0.3);
}

.piece.wall {
  color: #b06a3b;
}

.piece.wall::before,
.piece.heal::before {
  border-radius: 4px;
  background:
    linear-gradient(0deg, transparent 0 30%, rgba(36, 50, 58, 0.3) 30% 36%, transparent 36% 64%, rgba(36, 50, 58, 0.3) 64% 70%, transparent 70%),
    linear-gradient(90deg, transparent 0 46%, rgba(36, 50, 58, 0.3) 46% 54%, transparent 54%),
    currentColor;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.28), inset 0 -4px 0 rgba(36, 50, 58, 0.22);
}

.piece.heal {
  color: #3fae8c;
}

.piece.heal::after {
  content: "↻";
  position: absolute;
  left: 4%;
  top: 2%;
  z-index: 2;
  color: #ffffff;
  font-size: clamp(10px, 1.8vw, 15px);
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(36, 50, 58, 0.5);
}

.piece-hp {
  position: absolute;
  right: -6%;
  bottom: -6%;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 40%;
  height: 40%;
  padding: 0 8%;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(10px, 1.8vw, 15px);
  font-weight: 950;
  line-height: 1;
}

.cell.wall-hit .piece {
  animation: wall-shake 340ms ease;
}

.objective-text.pattern {
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  background-repeat: no-repeat;
}

.objective-icon.letter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
}

.objective-icon.letter.value-count-1 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.objective-icon.letter.value-count-2 {
  grid-template-rows: minmax(0, 1fr);
}

.objective-text.pattern-dot {
  background-image: radial-gradient(circle, #000 32%, transparent 36%);
  background-size: 25% 25%;
  background-position: center;
  background-repeat: repeat;
}

.objective-text.pattern-wave {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='%23000' stroke-width='6' stroke-linecap='round'%3E%3Cpath d='M0 8 Q6 4 12 8 T24 8 T36 8 T48 8'/%3E%3Cpath d='M0 24 Q6 20 12 24 T24 24 T36 24 T48 24'/%3E%3Cpath d='M0 40 Q6 36 12 40 T24 40 T36 40 T48 40'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
}

.objective-text.pattern-rain {
  background-image: linear-gradient(
    90deg,
    transparent 0 13%,
    #000 13% 25%,
    transparent 25% 43%,
    #000 43% 55%,
    transparent 55% 73%,
    #000 73% 85%,
    transparent 85% 100%
  );
}

.objective-text.pattern-two-tone {
  background-image: linear-gradient(135deg, #000 0 49%, transparent 50% 100%);
}

@keyframes wall-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-9%);
  }

  55% {
    transform: translateX(8%);
  }

  80% {
    transform: translateX(-4%);
  }
}

.red {
  color: #ff2230;
}

.green {
  color: #00e832;
}

.blue {
  color: #172eff;
}

.violet {
  color: #9b00ff;
}

@keyframes blast {
  0% {
    opacity: 0;
    transform: scale(0.25) rotate(0deg);
  }

  22% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: scale(1.65) rotate(38deg);
  }
}

@keyframes match-ping {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }

  45% {
    transform: scale(1.14);
    filter: brightness(1.75);
  }
}

@keyframes piece-pop {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  28% {
    opacity: 1;
    transform: scale(1.2) rotate(-7deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.18) rotate(24deg);
  }
}

@media (max-width: 980px) {
  .board-wrap {
    grid-template-columns: 1fr;
  }

  .board-shell {
    --board-columns: repeat(8, minmax(34px, 1fr));
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 10px;
  }

  .play-area {
    padding: 14px;
  }

  .board {
    gap: 4px;
    padding: 5px;
  }
}
