body[data-game] {
  position: relative;
  background-color: var(--bg, #080907);
}

body[data-game]::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(8, 9, 7, 0.94), rgba(8, 9, 7, 0.76) 44%, rgba(8, 9, 7, 0.92)),
    linear-gradient(180deg, rgba(8, 9, 7, 0.18), var(--bg, #080907) 82%),
    var(--game-cover) center / cover no-repeat;
  opacity: 0.42;
  filter: saturate(1.08) contrast(1.08);
}

body[data-game="slop-swap"] { --game-cover: url("/covers/slop-swap.webp"); }
body[data-game="slop-sweeper"] { --game-cover: url("/covers/slop-sweeper.webp"); }
body[data-game="slopdoku"] { --game-cover: url("/covers/slopdoku.webp"); }
body[data-game="slop-flap"] { --game-cover: url("/covers/slop-flap.webp"); }
body[data-game="slop-invaders"] { --game-cover: url("/covers/slop-invaders.webp"); }
body[data-game="slop-run"] { --game-cover: url("/covers/slop-run.webp"); }
body[data-game="slop-stones"] { --game-cover: url("/covers/slop-studios.webp"); }
body[data-game="sloppy-birds"] { --game-cover: url("/covers/sloppy-birds.webp"); }
body[data-game="context-collapse"] { --game-cover: url("/covers/context-collapse.webp"); }
body[data-game="temple-trace"] { --game-cover: url("/covers/temple-trace.webp"); }
body[data-game="slop-crostic"] { --game-cover: url("/covers/slop-crostic.svg"); }

.topbar,
.side-panel,
.board-shell,
.board,
.stage,
.hint-strip,
.brief-panel,
.threat-panel,
.slop-status,
.action-strip button,
.actions button,
.stats div,
.mode-group,
.difficulty-group,
.tool-group,
.toggle {
  border-radius: 8px;
}

.topbar {
  padding: 12px;
  border: 1px solid rgba(246, 241, 228, 0.08);
  background: rgba(8, 9, 7, 0.64);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
}

.studio-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.studio-link::before {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: url("/icon.svg") center / contain no-repeat;
  content: "";
  overflow: hidden;
}

.game-title h1 {
  text-shadow: 0 10px 48px rgba(0, 0, 0, 0.42);
}

.top-actions button,
.actions button,
.action-strip button,
.touch-controls button,
.number-pad button {
  border-radius: 8px;
  transition:
    border-color 150ms ease,
    filter 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.top-actions button:hover,
.actions button:hover,
.action-strip button:hover,
.touch-controls button:hover,
.number-pad button:hover {
  box-shadow: 0 12px 30px rgba(182, 244, 79, 0.12);
  transform: translateY(-1px);
}

.side-panel {
  box-shadow:
    0 24px 72px rgba(0, 0, 0, 0.28),
    inset 0 1px rgba(246, 241, 228, 0.05);
}

.stats div {
  position: relative;
  overflow: hidden;
}

.stats div::after {
  position: absolute;
  inset: auto 8px 8px auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(246, 241, 228, 0.06);
  border-radius: 50%;
  content: "";
  opacity: 0.8;
}

.board,
.board-shell,
.stage {
  box-shadow:
    0 28px 78px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(182, 244, 79, 0.1);
}

.tile,
.cell {
  border-radius: 6px;
}

.tile[data-kind] {
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.36),
    inset 0 -10px rgba(0, 0, 0, 0.12),
    0 8px 16px rgba(0, 0, 0, 0.14);
}

.tile[data-kind]:not(.special)::before {
  position: absolute;
  inset: 9px auto auto 9px;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(8, 9, 7, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  content: "";
  pointer-events: none;
}

.tile[data-kind="model"]:not(.special)::before,
.tile[data-kind="cache"]:not(.special)::before {
  border-radius: 3px;
  transform: rotate(45deg);
}

.tile[data-kind="spam"]:not(.special)::before {
  border-radius: 2px;
}

.tile[data-kind="bug"]:not(.special)::before {
  width: 14px;
  height: 10px;
  border-radius: 50% 50% 42% 42%;
}

.cell {
  box-shadow: inset 0 1px rgba(246, 241, 228, 0.03);
}

.cell.given {
  background:
    linear-gradient(135deg, rgba(126, 199, 216, 0.12), transparent 48%),
    var(--cell-alt, #171f12);
}

.cell.selected {
  box-shadow:
    inset 0 0 0 2px rgba(182, 244, 79, 0.52),
    0 0 18px rgba(182, 244, 79, 0.18);
}

.tile.closed {
  background:
    linear-gradient(135deg, rgba(246, 241, 228, 0.08), transparent 45%),
    repeating-linear-gradient(45deg, rgba(182, 244, 79, 0.05) 0 7px, transparent 7px 14px),
    var(--cell, #11170f);
}

.tile.flagged::after,
.tile.cleaned::after {
  position: absolute;
  inset: 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  content: "";
  opacity: 0.48;
}

.stage {
  background: #080907;
  display: block;
}

@supports (-moz-appearance: none) {
  body[data-game]::after {
    opacity: 0.24;
    filter: none;
  }

  .topbar {
    background: rgba(8, 9, 7, 0.88);
    backdrop-filter: none;
  }

  .board,
  .board-shell,
  .stage,
  .side-panel,
  .topbar {
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  }

  .top-actions button:hover,
  .actions button:hover,
  .action-strip button:hover,
  .touch-controls button:hover,
  .number-pad button:hover {
    box-shadow: none;
  }

  .tile[data-kind] {
    box-shadow:
      inset 0 1px rgba(255, 255, 255, 0.28),
      inset 0 -8px rgba(0, 0, 0, 0.1);
  }

  .cell.selected {
    box-shadow: inset 0 0 0 2px rgba(182, 244, 79, 0.52);
  }
}

@supports (-webkit-touch-callout: none) {
  body[data-game]::after {
    opacity: 0.2;
    filter: none;
  }

  .topbar {
    background: rgba(8, 9, 7, 0.9);
    backdrop-filter: none;
  }

  .board,
  .board-shell,
  .stage,
  .side-panel,
  .topbar {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
  }
}

@media (hover: none), (pointer: coarse) {
  body[data-game]::after {
    opacity: 0.18;
    filter: none;
  }

  .topbar {
    backdrop-filter: none;
  }

  .top-actions button:hover,
  .actions button:hover,
  .action-strip button:hover,
  .touch-controls button:hover,
  .number-pad button:hover {
    box-shadow: none;
    transform: none;
  }

  .tile[data-kind] {
    box-shadow:
      inset 0 1px rgba(255, 255, 255, 0.28),
      inset 0 -8px rgba(0, 0, 0, 0.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

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

  .studio-link::before {
    width: 22px;
    height: 22px;
  }
}
