:root {
  --bg: #05070b;
  --panel: #0d131c;
  --panel-2: #111a26;
  --line: rgba(158, 178, 204, 0.16);
  --text: #e9eef6;
  --muted: #7f91a8;
  --gold: #ffc857;
  --red: #e5485d;
  --red-bright: #ff5d73;
  --green: #49c58a;
  --blue: #5fa8ff;
  --font-ui: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  --cell-size: 42px;
  --cell-gap: 4px;
  --board-pad: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

[hidden],
.screen[hidden],
.modal-layer[hidden],
.dialogue-layer[hidden],
.ad-card[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
}

/* ===== Entry / fake ad ===== */

.entry-screen {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(52, 95, 128, 0.2), transparent 55%),
    #020407;
}

.entry-stage {
  position: relative;
  width: min(100vw, 156.09756vh);
  width: min(100vw, 156.09756dvh);
  aspect-ratio: 1280 / 820;
  overflow: hidden;
  background: #cfeaff;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.9);
}

.entry-camera {
  position: absolute;
  inset: 0;
  transform-origin: 77% 77%;
  transform: scale(1);
  transition: transform 2.35s cubic-bezier(0.2, 0.75, 0.18, 1);
  will-change: transform;
}

.entry-stage.is-zoomed .entry-camera {
  transform: scale(2.42);
}

.entry-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.sound-button {
  position: absolute;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #25364b;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.52);
  box-shadow:
    0 6px 18px rgba(21, 45, 70, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.35s ease;
}

.sound-button:hover {
  background: rgba(255, 255, 255, 0.72);
  transform: scale(1.06);
}

.sound-button svg {
  width: 22px;
  height: 22px;
}

.sound-button__off,
.is-muted .sound-button__on {
  display: none;
}

.is-muted .sound-button__off {
  display: block;
}

.sound-button--entry {
  top: 2.2%;
  right: 1.5%;
  width: 3.75%;
  height: auto;
  aspect-ratio: 1;
  min-width: 34px;
}

.sound-button--entry svg {
  width: 46%;
  height: 46%;
}

.entry-stage.is-zoomed .sound-button--entry {
  opacity: 0;
  pointer-events: none;
}

.ad-card {
  position: absolute;
  right: 5.2%;
  bottom: 7.4%;
  z-index: 15;
  display: grid;
  grid-template-columns: 34% 1fr;
  gap: 2.4%;
  width: 36.5%;
  padding: 1.7%;
  border: 1px solid rgba(20, 44, 69, 0.22);
  border-radius: 1.1%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 252, 238, 0.98)),
    #fff8e8;
  box-shadow:
    0 18px 60px rgba(13, 33, 52, 0.38),
    0 3px 10px rgba(13, 33, 52, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(22px) rotate(1.1deg) scale(0.97);
  transition: opacity 0.55s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ad-card.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) rotate(0.35deg) scale(1);
}

.ad-card__tag {
  position: absolute;
  top: -0.9em;
  left: 3%;
  padding: 0.25em 0.55em;
  color: #657181;
  border: 1px solid rgba(90, 108, 125, 0.24);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  font-size: clamp(7px, 0.78vw, 13px);
  letter-spacing: 0.14em;
  line-height: 1;
}

.ad-card__art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(59, 86, 113, 0.15);
  border-radius: 8%;
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 202, 92, 0.34), transparent 35%),
    linear-gradient(145deg, #27415d, #101d2c);
}

.ad-mini-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3%;
  width: 66%;
  aspect-ratio: 1;
  padding: 6%;
  border-radius: 8%;
  background: #4e6174;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.ad-mini-board i {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14%;
  background: linear-gradient(145deg, #8fa3b6, #61778d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ad-mini-board i.has-mine {
  background: radial-gradient(circle at 50% 45%, #263648 0 27%, transparent 28%), #8fa3b6;
  box-shadow: inset 0 -2px 0 rgba(48, 68, 88, 0.25), 0 0 8px rgba(229, 72, 93, 0.4);
}

.ad-mini-board i.has-flag {
  background: linear-gradient(145deg, #8fa3b6, #61778d);
}

.ad-mini-board i.has-flag::after {
  content: "";
  position: absolute;
  left: 44%;
  top: 19%;
  width: 32%;
  height: 25%;
  background: #e5485d;
  clip-path: polygon(0 0, 100% 23%, 0 100%);
}

.ad-mini-board i.has-flag::before {
  content: "";
  position: absolute;
  left: 43%;
  top: 17%;
  width: 5%;
  height: 63%;
  background: #25364b;
}

.ad-card__stamp {
  position: absolute;
  right: 4%;
  bottom: 2%;
  color: rgba(255, 255, 255, 0.2);
  font-family: var(--font-mono);
  font-size: clamp(6px, 0.75vw, 12px);
  letter-spacing: 0.24em;
  transform: rotate(-10deg);
}

.ad-card__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.ad-card__headline {
  margin: 0;
  color: #1d2c3e;
  font-size: clamp(10px, 1.32vw, 23px);
  font-weight: 780;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.ad-card__hidden {
  color: rgba(29, 44, 62, 0.055);
  font-size: 0.94em;
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
}

.ad-card__cta {
  align-self: flex-start;
  margin: 1.4% 0 0;
  padding: 0;
  color: #1d63c7;
  border: 0;
  background: transparent;
  font-size: clamp(8px, 1vw, 18px);
  font-weight: 650;
  line-height: 1.4;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.ad-card__cta:hover {
  color: #0f44a1;
}

.ad-card__note {
  margin-top: 1.2%;
  color: #8a98a7;
  font-size: clamp(6px, 0.72vw, 12px);
  letter-spacing: 0.04em;
}

.entry-stage.is-zoomed .ad-card {
  box-shadow:
    0 30px 120px rgba(13, 33, 52, 0.55),
    0 4px 16px rgba(13, 33, 52, 0.24);
}

/* ===== Game shell ===== */

.game-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 12%, rgba(50, 79, 112, 0.16), transparent 44%),
    radial-gradient(circle at 50% 110%, rgba(83, 20, 31, 0.14), transparent 50%),
    #05080d;
  transition: background 0.8s ease;
}

#gameScreen {
  --pollution: 0;
  --pollution-vignette: 0;
  --pollution-grain: 0;
  --pollution-sat: 1;
}

#gameScreen[data-pollution="1"] {
  --pollution-vignette: 0.10;
  --pollution-grain: 0.035;
  --pollution-sat: 0.96;
}

#gameScreen[data-pollution="2"] {
  --pollution-vignette: 0.16;
  --pollution-grain: 0.05;
  --pollution-sat: 0.90;
}

#gameScreen[data-pollution="3"] {
  --pollution-vignette: 0.24;
  --pollution-grain: 0.07;
  --pollution-sat: 0.84;
}

.game-screen[data-level="3"] {
  background:
    radial-gradient(circle at 50% 35%, rgba(100, 23, 34, 0.12), transparent 65%),
    #05070a;
}

.game-screen[data-level="4"] {
  background:
    radial-gradient(circle at 50% 42%, rgba(80, 18, 30, 0.18), transparent 60%),
    #040609;
}

.game-screen[data-level="5"] {
  background:
    radial-gradient(circle at 50% 20%, rgba(151, 18, 34, 0.22), transparent 48%),
    radial-gradient(circle at 50% 110%, rgba(0, 0, 0, 0.7), transparent 55%),
    #080204;
}

.game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(794px, calc(100vh - 32px));
  height: min(794px, calc(100dvh - 32px));
  overflow: hidden;
  filter: saturate(var(--pollution-sat));
  border: 1px solid rgba(164, 183, 205, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(19, 28, 41, 0.96), rgba(8, 12, 18, 0.98)),
    #0a0f16;
  box-shadow:
    0 38px 100px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.game-screen[data-level="5"] .game-stage {
  border-color: rgba(229, 72, 93, 0.28);
  box-shadow:
    0 38px 100px rgba(0, 0, 0, 0.75),
    0 0 70px rgba(128, 14, 31, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.game-screen[data-level="5"] .game-header {
  border-bottom-color: rgba(190, 44, 65, 0.2);
  background:
    linear-gradient(180deg, rgba(65, 10, 20, 0.72), rgba(22, 3, 8, 0.88));
}

.game-screen[data-level="5"] .game-brand__icon {
  color: #ffadb8;
  border-color: rgba(229, 72, 93, 0.26);
  background: linear-gradient(145deg, #4c1822, #21060c);
}

.game-screen[data-level="5"] .cell:not(.is-revealed) {
  border-color: rgba(255, 142, 158, 0.13);
  background: linear-gradient(145deg, #70404b 0%, #4c232d 54%, #2c1118 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 211, 218, 0.11),
    0 2px 3px rgba(0, 0, 0, 0.4);
}

.game-screen[data-level="5"] .cell.is-revealed {
  border-color: rgba(229, 72, 93, 0.07);
  background: linear-gradient(145deg, #1b0a0e, #090304);
}

.game-screen[data-level="5"] .cell.is-flagged {
  background: linear-gradient(145deg, #794650 0%, #4e252f 55%, #30121a 100%);
}

.game-screen[data-level="5"] .inventory-panel {
  border-color: rgba(229, 72, 93, 0.16);
  background:
    linear-gradient(180deg, rgba(40, 8, 15, 0.9), rgba(12, 2, 5, 0.94));
}

.game-screen[data-level="5"] .inventory-item {
  border-color: rgba(229, 72, 93, 0.14);
  background: linear-gradient(135deg, rgba(75, 22, 32, 0.62), rgba(23, 5, 10, 0.9));
}

.game-screen[data-level="5"] .mine-counter {
  border-color: rgba(229, 72, 93, 0.2);
  color: #ff8b9a;
}

.game-screen[data-level="5"] .game-footer,
.game-screen[data-level="5"] .board-level {
  color: #7d4a52;
}

.game-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex: none;
  min-height: 66px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(143, 165, 188, 0.12);
  background:
    linear-gradient(180deg, rgba(31, 44, 61, 0.7), rgba(13, 20, 30, 0.8));
}

.game-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.game-brand__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  color: #c5d3e2;
  border: 1px solid rgba(189, 205, 222, 0.16);
  border-radius: 8px;
  background: linear-gradient(145deg, #38495f, #1a2636);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.game-brand__icon svg {
  width: 23px;
  height: 23px;
}

.game-brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.game-brand p {
  margin: 2px 0 0;
  color: #8799ae;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.game-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.mine-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 86px;
  padding: 7px 11px;
  color: var(--gold);
  border: 1px solid rgba(255, 200, 87, 0.13);
  border-radius: 7px;
  background: #070b11;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.72),
    0 1px 0 rgba(255, 255, 255, 0.03);
}

.mine-counter svg {
  width: 15px;
  height: 15px;
  opacity: 0.75;
}

.mine-counter span {
  font-family: var(--font-mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: 0 0 13px rgba(255, 200, 87, 0.35);
}

.countdown {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid rgba(229, 72, 93, 0.24);
  border-radius: 7px;
  background: rgba(30, 4, 9, 0.72);
  box-shadow: inset 0 2px 9px rgba(0, 0, 0, 0.55);
}

.countdown__label {
  color: #9e6d76;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.countdown strong {
  color: #ff6b7c;
  font-family: var(--font-mono);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-shadow: 0 0 14px rgba(229, 72, 93, 0.5);
}

.countdown.is-urgent {
  animation: countdownPulse 1s ease-in-out infinite;
}

.abandon-button {
  padding: 8px 13px;
  color: #eaa0aa;
  border: 1px solid rgba(229, 72, 93, 0.28);
  border-radius: 7px;
  background: rgba(62, 10, 18, 0.42);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.abandon-button:hover {
  color: #ffd4d9;
  background: rgba(115, 17, 31, 0.65);
}

.sound-button--game {
  position: relative;
  top: auto;
  right: auto;
  width: 37px;
  height: 37px;
  color: #9fb0c4;
  border-color: rgba(150, 173, 196, 0.16);
  background: rgba(15, 23, 34, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.sound-button--game:hover {
  color: #eaf1f9;
  background: rgba(37, 52, 71, 0.9);
}

.sound-button--game svg {
  width: 19px;
  height: 19px;
}

.game-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 222px;
  gap: 14px;
  flex: 1;
  min-height: 0;
  padding: 14px;
}

.board-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(139, 162, 186, 0.12);
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(67, 90, 115, 0.16), transparent 55%),
    rgba(6, 10, 15, 0.72);
  box-shadow:
    inset 0 2px 18px rgba(0, 0, 0, 0.54),
    0 1px 0 rgba(255, 255, 255, 0.025);
  transition: background 0.7s ease, box-shadow 0.7s ease;
}

.game-screen[data-level="3"] .board-panel {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(100, 24, 34, 0.12), transparent 64%),
    radial-gradient(circle at 82% 88%, rgba(84, 10, 19, 0.12), transparent 22%),
    rgba(5, 8, 12, 0.82);
}

.game-screen[data-level="4"] .board-panel {
  background:
    radial-gradient(circle at 50% 52%, rgba(83, 18, 28, 0.1), transparent 60%),
    rgba(3, 5, 8, 0.86);
}

.game-screen[data-level="5"] .board-panel {
  border-color: rgba(229, 72, 93, 0.14);
  background:
    radial-gradient(circle at 50% 50%, rgba(105, 9, 24, 0.18), transparent 65%),
    rgba(7, 2, 4, 0.9);
}

.board-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(139, 162, 186, 0.075);
}

.board-status {
  color: #7f92a9;
  font-size: 10px;
  letter-spacing: 0.07em;
}

.board-status.is-lost {
  color: #e77e8c;
}

.board-status.is-won {
  color: #75c9a1;
}

.board-level {
  color: #5f7084;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.board-viewport {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #344359 transparent;
}

.board-viewport::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.board-viewport::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: #344359;
  background-clip: padding-box;
}

.board {
  --cols: 9;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  gap: var(--cell-gap);
  width: max-content;
  padding: var(--board-pad);
  user-select: none;
  -webkit-user-select: none;
}

.board.is-shaking {
  animation: boardShake 0.4s ease;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  color: #dbe5f0;
  border: 1px solid rgba(219, 232, 245, 0.13);
  border-bottom-color: rgba(0, 0, 0, 0.42);
  border-radius: calc(var(--cell-size) * 0.1);
  background: linear-gradient(145deg, #65778a 0%, #4a5b6d 52%, #374657 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 2px 2px rgba(0, 0, 0, 0.34);
  font-family: var(--font-mono);
  font-size: calc(var(--cell-size) * 0.48);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.1s ease,
    rotate 0.16s ease,
    translate 0.16s ease,
    filter 0.14s ease,
    background 0.14s ease,
    border-color 0.14s ease;
}

.cell:active {
  transform: scale(0.94);
}

.cell:focus-visible {
  z-index: 4;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.cell.is-revealed {
  color: #b7c3d1;
  border-color: rgba(143, 162, 182, 0.05);
  background: linear-gradient(145deg, #171e27, #0d131a);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.48);
  cursor: default;
}

.cell.is-revealed:active {
  transform: none;
}

.cell.is-flagged {
  background: linear-gradient(145deg, #677a8e 0%, #46586b 55%, #344354 100%);
}

.cell-icon {
  display: block;
  width: 66%;
  height: 66%;
  pointer-events: none;
}

.cell.is-flagged .cell-icon {
  color: #e5485d;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.cell.is-mine {
  color: #ffdbe0;
  border-color: rgba(229, 72, 93, 0.38);
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 109, 129, 0.45), transparent 52%),
    linear-gradient(145deg, #641d29, #2d0b12);
}

.cell.is-exploded {
  background:
    radial-gradient(circle at 50% 45%, #ff8495, #ba1930 55%, #4d0714);
  box-shadow:
    0 0 0 2px rgba(229, 72, 93, 0.35),
    0 0 26px rgba(229, 72, 93, 0.5);
  animation: mineBoom 0.4s ease;
}

.cell.is-wrong .cell-icon {
  opacity: 0.25;
}

.cell.is-wrong::after {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ff6b7c;
  font-family: var(--font-ui);
  font-size: calc(var(--cell-size) * 0.85);
  font-weight: 400;
}

.cell.is-new {
  animation: cellReveal 0.18s ease;
}

.cell[data-number="1"] { color: #74b8ff; }
.cell[data-number="2"] { color: #67d89a; }
.cell[data-number="3"] { color: #ff788b; }
.cell[data-number="4"] { color: #b6a0ff; }
.cell[data-number="5"] { color: #f0b55f; }
.cell[data-number="6"] { color: #62d6da; }
.cell[data-number="7"] { color: #e9a9dc; }
.cell[data-number="8"] { color: #c5d0db; }

.cell.is-loose {
  animation: looseTremble 2.7s ease-in-out infinite;
}

.cell.is-loose:hover {
  animation: looseHover 0.36s linear infinite;
}

.cell.has-blood::before {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background: url("assets/blood-splatter.png") center / contain no-repeat;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.85));
  opacity: 0.9;
  transform: rotate(-9deg) scale(1.04);
}

.cell.has-blood.blood-opened::before {
  opacity: 0.45;
  filter: blur(0.35px) drop-shadow(0 0 1px rgba(0, 0, 0, 0.7));
}

.cell.has-blood.is-revealed::before {
  opacity: 0.38;
}

.cell.has-spike::after {
  content: "";
  position: absolute;
  inset: 6%;
  z-index: 2;
  pointer-events: none;
  border-radius: 2px;
  background:
    linear-gradient(45deg, transparent 43%, rgba(133, 155, 177, 0.82) 44% 51%, transparent 52%) 0 0 / 33% 33%,
    linear-gradient(-45deg, transparent 43%, rgba(133, 155, 177, 0.72) 44% 51%, transparent 52%) 0 0 / 33% 33%;
  opacity: 0.58;
}

.cell.has-tentacle.is-revealed {
  border-color: rgba(75, 15, 25, 0.2);
  background:
    radial-gradient(circle at 50% 52%, #14040a 0 14%, #050206 50%, #09040a 100%);
}

.cell.has-tentacle .tentacle-art {
  position: absolute;
  inset: 8%;
  z-index: 3;
  width: 84%;
  height: 84%;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cell.has-tentacle:hover .tentacle-art {
  opacity: 0;
  transform: translateY(24%) scale(0.8);
}

.cell.has-tentacle.is-dragging-tool .tentacle-art {
  opacity: 1;
  transform: none;
}

.cell.has-tentacle.is-tentacle-cut .tentacle-art {
  display: none;
}

.cell.has-tentacle.is-revealed .cell-number {
  position: relative;
  z-index: 2;
  opacity: 0;
  color: #fff;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
  transition: opacity 0.12s ease;
}

.cell.has-tentacle:hover .cell-number,
.cell.has-tentacle.is-tentacle-cut .cell-number,
.cell.has-tentacle.is-dragging-tool .cell-number {
  opacity: 1;
}

.cell.has-tentacle.is-tentacle-cut {
  background:
    radial-gradient(circle at 50% 52%, #100208 0 13%, #040103 55%, #08030a 100%);
}

.inventory-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 13px;
  border: 1px solid rgba(139, 162, 186, 0.12);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(17, 25, 36, 0.9), rgba(8, 12, 18, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.inventory-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(139, 162, 186, 0.08);
}

.inventory-heading h2 {
  margin: 0;
  color: #9eb0c5;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.18em;
}

.inventory-heading span {
  color: #63758a;
  font-family: var(--font-mono);
  font-size: 10px;
}

.inventory-items {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 0;
}

.inventory-empty {
  display: grid;
  place-items: center;
  min-height: 100px;
  color: #44566b;
  border: 1px dashed rgba(130, 154, 179, 0.12);
  border-radius: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.inventory-item {
  --item-color: #b4c4d5;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px;
  color: #bac9d9;
  border: 1px solid rgba(139, 162, 186, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(41, 57, 75, 0.72), rgba(16, 24, 35, 0.86));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.inventory-item:hover {
  border-color: rgba(195, 212, 230, 0.24);
  background: linear-gradient(135deg, rgba(54, 74, 96, 0.78), rgba(19, 29, 42, 0.9));
  transform: translateY(-1px);
}

.inventory-item:active,
.inventory-item.is-dragging {
  cursor: grabbing;
  transform: scale(0.98);
}

.inventory-item__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--item-color);
  border: 1px solid rgba(194, 211, 229, 0.1);
  border-radius: 7px;
  background: rgba(5, 10, 16, 0.42);
}

.inventory-item__icon svg {
  width: 25px;
  height: 25px;
}

.inventory-item--cloth {
  --item-color: #d5c7ad;
}

.inventory-item--pliers {
  --item-color: #c6d1dd;
}

.inventory-item strong {
  display: block;
  color: #dfe8f2;
  font-size: 11px;
  font-weight: 650;
}

.inventory-item span {
  display: block;
  margin-top: 2px;
  color: #6e8095;
  font-size: 9px;
}

.inventory-tip {
  margin: auto 0 0;
  padding-top: 10px;
  color: #4f6175;
  border-top: 1px solid rgba(139, 162, 186, 0.06);
  font-size: 9px;
  line-height: 1.5;
}

.game-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  padding: 8px 16px 10px;
  color: #516377;
  border-top: 1px solid rgba(139, 162, 186, 0.08);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.game-footer__level {
  color: #3f4f62;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
}

/* ===== Dialogue ===== */

body.is-l5-jumpscare .dialogue-box {
  opacity: 0;
  visibility: hidden;
}

.dialogue-layer {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 9% 7%;
  background: linear-gradient(180deg, transparent 30%, rgba(1, 3, 6, 0.6) 68%, rgba(0, 0, 0, 0.88));
  cursor: pointer;
  animation: fadeIn 0.3s ease;
}

.dialogue-box {
  position: relative;
  width: min(880px, 100%);
  min-height: 152px;
  padding: 22px 28px 26px;
  border: 1px solid rgba(181, 199, 218, 0.13);
  border-left: 2px solid rgba(229, 72, 93, 0.42);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(8, 12, 17, 0.94), rgba(3, 5, 8, 0.96)),
    #05070a;
  box-shadow:
    0 20px 80px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.dialogue-speaker {
  display: inline-block;
  margin-bottom: 12px;
  color: #9aaec3;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.dialogue-text {
  min-height: 50px;
  margin: 0;
  color: #edf1f5;
  font-size: 16px;
  letter-spacing: 0.03em;
  line-height: 1.8;
  white-space: pre-wrap;
}

.dialogue-text.is-red {
  color: #ff5d73;
  text-shadow: 0 0 16px rgba(229, 72, 93, 0.4);
}

.dialogue-text.is-shake {
  animation: textShake 0.14s linear infinite;
}

.dialogue-next {
  position: absolute;
  right: 22px;
  bottom: 14px;
  color: #566a80;
  font-size: 9px;
  letter-spacing: 0.08em;
  animation: nextBlink 1.8s ease-in-out infinite;
}

.dialogue-next i {
  font-style: normal;
}

.dialogue-box.is-complete .dialogue-next {
  color: #a9b8c8;
}

/* ===== Modals ===== */

.modal-layer {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 2, 5, 0.74);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  animation: fadeIn 0.2s ease;
}

.modal {
  width: min(410px, 100%);
  padding: 28px;
  text-align: center;
  border: 1px solid rgba(174, 193, 213, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(160deg, rgba(24, 34, 47, 0.98), rgba(7, 11, 16, 0.99));
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.modal--small {
  width: min(360px, 100%);
}

.modal__icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
}

.modal__icon svg {
  width: 30px;
  height: 30px;
}

.modal__icon--bomb {
  color: #ffd0d6;
  background: radial-gradient(circle at 42% 34%, #ff8d9d, #b21d33 60%, #4f0a15);
  box-shadow: 0 0 34px rgba(229, 72, 93, 0.28);
}

.modal__icon--key {
  color: #d4c293;
  border: 1px solid rgba(255, 200, 87, 0.18);
  background: rgba(255, 200, 87, 0.06);
}

.modal__eyebrow {
  margin: 0 0 5px;
  color: #7b8ea4;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.28em;
}

.modal h2 {
  margin: 0;
  color: #f1f5f9;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.modal__text {
  margin: 12px 0 20px;
  color: #8fa1b5;
  font-size: 11.5px;
  line-height: 1.7;
}

.button {
  min-height: 40px;
  padding: 9px 18px;
  color: #dbe6f2;
  border: 1px solid rgba(159, 181, 203, 0.18);
  border-radius: 7px;
  background: rgba(50, 68, 88, 0.35);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.button:hover {
  border-color: rgba(190, 208, 226, 0.32);
  background: rgba(66, 88, 112, 0.5);
  transform: translateY(-1px);
}

.button--primary {
  color: #1d1408;
  border-color: rgba(255, 214, 128, 0.55);
  background: linear-gradient(135deg, #f3c65b, #d89b31);
  box-shadow: 0 10px 24px rgba(216, 155, 49, 0.16);
}

.button--primary:hover {
  background: linear-gradient(135deg, #ffd875, #e3a93e);
}

.button--danger {
  color: #ffd9de;
  border-color: rgba(229, 72, 93, 0.28);
  background: rgba(99, 14, 27, 0.42);
}

.button--quiet {
  color: #9fb0c4;
}

.key-cancel {
  width: 100%;
  margin-top: 10px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.pliers-pickup {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 14px;
  padding: 9px;
  color: #a9b9c9;
  text-align: left;
  border: 1px dashed rgba(182, 201, 220, 0.2);
  border-radius: 7px;
  background: rgba(139, 162, 186, 0.04);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.pliers-pickup:hover {
  border-color: rgba(206, 221, 236, 0.38);
  background: rgba(139, 162, 186, 0.08);
}

.pliers-pickup__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #cbd6e1;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 6px;
}

.pliers-pickup__icon svg {
  width: 23px;
  height: 23px;
}

.pliers-pickup span {
  font-size: 10px;
}

.pliers-pickup strong {
  color: #e3c477;
  font-size: 10px;
  white-space: nowrap;
}

.key-form {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.key-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  color: #e8eef6;
  border: 1px solid rgba(166, 188, 211, 0.18);
  border-radius: 7px;
  background: rgba(2, 6, 10, 0.68);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.key-form input::placeholder {
  color: #4f6174;
}

.key-error {
  min-height: 16px;
  margin: 10px 0 0;
  color: #ff697c;
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* ===== FX / transition ===== */

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.fx-layer__red,
.fx-layer__blood {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.fx-layer__red {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 30, 60, 0.28), rgba(84, 0, 11, 0.48));
}

.fx-layer__blood {
  background-image: url("assets/blood-splatter.png"), url("assets/blood-splatter.png");
  background-size: 54% auto, 38% auto;
  background-position: 4% 8%, 96% 80%;
  background-repeat: no-repeat;
  filter: blur(2px) drop-shadow(0 0 16px rgba(126, 0, 18, 0.35));
  -webkit-filter: blur(2px) drop-shadow(0 0 16px rgba(126, 0, 18, 0.35));
}

.fx-pollution {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
}

.fx-pollution__vignette {
  position: absolute;
  inset: 0;
  opacity: var(--pollution-vignette);
  background: radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(70, 0, 10, 1) 100%);
  transition: opacity 0.8s ease;
}

.game-screen[data-level="5"] .fx-pollution__vignette {
  background: radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(40, 0, 16, 1) 100%);
}

.fx-pollution__grain {
  position: absolute;
  inset: -12%;
  opacity: var(--pollution-grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: soft-light;
  transition: opacity 0.8s ease;
  animation: pollutionGrain 1.1s steps(2) infinite;
}

.fx-pollution__stains {
  position: absolute;
  inset: 0;
}

.fx-pollution__stain {
  position: absolute;
  left: var(--stain-x);
  top: var(--stain-y);
  width: var(--stain-size);
  height: var(--stain-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, rgba(76, 0, 10, 0.52) 0 16%, rgba(76, 0, 10, 0.24) 34%, transparent 70%),
    radial-gradient(circle at 64% 68%, rgba(58, 0, 8, 0.24) 0 20%, transparent 56%);
  opacity: 0;
  transform: rotate(var(--stain-rot, 0deg));
  mix-blend-mode: multiply;
  pointer-events: none;
  animation: pollutionStainIn 0.9s ease forwards;
}

.fx-pollution__stain.is-strong {
  animation-duration: 1.2s;
  animation-name: pollutionStainInStrong;
}

@keyframes pollutionGrain {
  0% { background-position: 0 0; }
  50% { background-position: 80px 40px; }
  100% { background-position: -60px 70px; }
}

@keyframes pollutionStainIn {
  0% { opacity: 0; }
  32% { opacity: 0.28; }
  100% { opacity: 0.10; }
}

@keyframes pollutionStainInStrong {
  0% { opacity: 0; }
  35% { opacity: 0.34; }
  100% { opacity: 0.12; }
}

.fx-layer__prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(700px, 80%);
  color: #ff5d73;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-align: center;
  text-shadow: 0 0 24px rgba(229, 72, 93, 0.5);
  opacity: 0;
  transform: translate(-50%, -50%);
}

.game-screen.is-blurred .game-stage {
  filter: saturate(var(--pollution-sat)) blur(1.4px) saturate(1.25) contrast(1.05);
}

.game-screen.is-blurred-strong .game-stage {
  filter: saturate(var(--pollution-sat)) blur(2.2px) saturate(1.3) contrast(1.06);
}

.game-screen.is-flashing .fx-layer__red {
  animation: redFlash 0.52s ease;
}

.game-screen.is-bloodied .fx-layer__blood {
  animation: bloodFade 2.8s ease forwards;
}

.game-screen.is-prompting .fx-layer__prompt {
  animation: promptFade 2.6s ease forwards;
}

.transition-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  background: #000;
  transition: opacity 0.7s ease;
}

.transition-layer.is-active {
  pointer-events: auto;
  opacity: 1;
}

.transition-layer.is-white {
  background: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  padding: 9px 14px;
  pointer-events: none;
  opacity: 0;
  color: #f1dca6;
  border: 1px solid rgba(255, 200, 87, 0.2);
  border-radius: 7px;
  background: rgba(8, 12, 18, 0.94);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ending-screen {
  z-index: 30;
  overflow: auto;
  background: #000;
}

.ending-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 8vh 8vw;
}

.ending-line {
  margin: 0 0 1.35em;
  color: #e9eef6;
  font-size: clamp(16px, 1.55vw, 22px);
  letter-spacing: 0.04em;
  line-height: 1.9;
  white-space: pre-wrap;
}

.ending-line.is-red {
  color: #ff5d73;
  text-shadow: 0 0 18px rgba(229, 72, 93, 0.35);
}

.ending-line.is-muted {
  color: #7d8998;
}

.ending-line.is-terminal {
  color: #8ba08e;
  font-family: var(--font-mono);
  font-size: clamp(12px, 1.1vw, 16px);
  letter-spacing: 0.04em;
}

.ending-title {
  margin: 1.4em 0;
  color: #f4f6f9;
  font-size: clamp(28px, 3.2vw, 46px);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.ending-actions {
  display: flex;
  gap: 12px;
  margin-top: 2em;
}

/* ===== Animations ===== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cellReveal {
  from { opacity: 0.4; transform: scale(0.78); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes mineBoom {
  0% { transform: scale(0.7); }
  45% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-6px); }
  36% { transform: translateX(5px); }
  54% { transform: translateX(-3px); }
  72% { transform: translateX(2px); }
}

@keyframes looseTremble {
  0%, 100% { transform: rotate(0) translate(0, 0); }
  35% { transform: rotate(-0.45deg) translate(-0.3px, 0.4px); }
  70% { transform: rotate(0.55deg) translate(0.4px, -0.2px); }
}

@keyframes looseHover {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-1.2px, 0.9px) rotate(-1.4deg); }
  50% { transform: translate(1px, -1.2px) rotate(1.1deg); }
  75% { transform: translate(-0.7px, 1.1px) rotate(-0.6deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

@keyframes textShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-1px, 1px); }
  40% { transform: translate(1px, -0.5px); }
  60% { transform: translate(-0.7px, -1px); }
  80% { transform: translate(0.7px, 0.7px); }
}

@keyframes nextBlink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes countdownPulse {
  0%, 100% { box-shadow: inset 0 2px 9px rgba(0, 0, 0, 0.55); }
  50% { box-shadow: inset 0 2px 9px rgba(0, 0, 0, 0.55), 0 0 18px rgba(229, 72, 93, 0.2); }
}

@keyframes redFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  38% { opacity: 0.2; }
  55% { opacity: 0.9; }
  100% { opacity: 0; }
}

@keyframes bloodFade {
  0% { opacity: 0; }
  12% { opacity: 0.95; }
  62% { opacity: 0.82; }
  100% { opacity: 0; }
}

@keyframes promptFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  67% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 980px) {
  .game-stage {
    width: 100%;
  }

  .game-play {
    grid-template-columns: minmax(0, 1fr) 198px;
    gap: 10px;
    padding: 10px;
  }

  .inventory-panel {
    padding: 10px;
  }
}

@media (max-height: 700px) {
  .game-screen {
    padding: 8px;
  }

  .game-stage {
    height: calc(100dvh - 16px);
  }

  .game-header {
    min-height: 56px;
    padding: 7px 12px;
  }

  .game-play {
    padding: 9px;
  }

  .dialogue-layer {
    padding-bottom: 4%;
  }

  .dialogue-box {
    min-height: 126px;
    padding: 18px 22px 22px;
  }

  .dialogue-text {
    font-size: 14px;
  }
}

.cell-number {
  position: relative;
  z-index: 2;
  color: #fff;
  font-family: var(--font-mono);
  font-size: calc(var(--cell-size) * 0.45);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.45);
}

.tool-ghost {
  position: fixed;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  pointer-events: none;
  color: #dce7f2;
  border: 1px solid rgba(178, 198, 218, 0.24);
  border-radius: 7px;
  background: rgba(10, 16, 24, 0.9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  font-size: 10px;
  transform: translate3d(-999px, -999px, 0);
  transition: opacity 0.12s ease;
}

.tool-ghost svg {
  width: 20px;
  height: 20px;
}

.tool-ghost.is-visible {
  opacity: 1;
}

.inventory-item.is-dragging {
  opacity: 0.42;
}

html.is-tool-dragging,
html.is-tool-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

.cell.is-drop-target {
  z-index: 5;
  outline: 2px solid #ffc857;
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(255, 200, 87, 0.32);
}

.abandon-button.is-drop-target {
  outline: 2px solid #ffc857;
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(255, 200, 87, 0.3);
}

.game-screen.is-prompting .fx-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.65);
  animation: promptDim 2.6s ease forwards;
}

.game-screen.is-prompting .fx-layer__prompt {
  z-index: 2;
}

.game-screen.is-prompting .fx-layer__prompt {
  animation: promptFade 2.6s ease forwards;
}

.ending-content {
  position: relative;
  z-index: 2;
}

.ending-line {
  opacity: 0;
  animation: endingLineIn 0.65s ease forwards;
}

.ending-line.is-typed {
  opacity: 1;
  animation: none;
}

.ending-line.is-quote {
  color: #d8d2c6;
  font-style: italic;
}

.ending-line.is-hint {
  margin-top: 2.4em;
  color: #6d7a88;
  font-size: 0.68em;
  letter-spacing: 0.04em;
}

.ending-line.is-thanks {
  color: #e8d7ae;
  font-size: clamp(18px, 2vw, 26px);
}

.ending-line.is-shake {
  animation: endingLineIn 0.65s ease forwards, textShake 0.14s linear infinite;
}

.ending-title {
  opacity: 0;
  animation: endingTitleIn 1.2s ease forwards;
}

.ending-actions {
  opacity: 0;
  animation: endingLineIn 0.7s ease forwards;
}

.handprints {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.18);
  animation: handprintFlash 1.8s ease forwards;
}

.handprints-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(1.28) saturate(1.12) drop-shadow(0 0 16px rgba(126, 0, 18, 0.42));
  animation: handSlam 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.handprint {
  width: min(21vw, 220px);
  color: #a20f25;
  filter: drop-shadow(0 0 26px rgba(126, 0, 18, 0.42));
  transform: rotate(-9deg) scale(0.9);
  animation: handSlam 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.handprint:nth-child(2) {
  transform: rotate(11deg) scale(0.82);
  animation-delay: 0.1s;
}

.handprint svg {
  display: block;
  width: 100%;
  height: auto;
}

.is-jumpscare .ending-screen,
.is-jumpscare .ending-content {
  animation: screenJolt 0.45s ease;
}

@keyframes endingLineIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes endingTitleIn {
  from { opacity: 0; letter-spacing: 0.24em; }
  to { opacity: 1; letter-spacing: 0.12em; }
}

@keyframes promptDim {
  0% { opacity: 0; }
  15% { opacity: 1; }
  28% { opacity: 0.45; }
  38% { opacity: 1; }
  76% { opacity: 0.85; }
  100% { opacity: 0; }
}

@keyframes handprintFlash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes handSlam {
  from { transform: scale(1.6); opacity: 0; }
  to { opacity: 0.9; }
}

@keyframes screenJolt {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(-6px, 2px); }
  38% { transform: translate(5px, -3px); }
  58% { transform: translate(-3px, 2px); }
  78% { transform: translate(2px, -1px); }
}

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

/* ===== Classic Minesweeper visual theme ===== */

.game-screen[data-level] {
  --desktop: #f2efe6;
  --chrome: #d4d0c8;
  --chrome-light: #ffffff;
  --chrome-dark: #7b7b7b;
  --chrome-mid: #a9a49c;
  --board: #bfbfbf;
  --cell: #c0c0c0;
  --revealed: #bdbdbd;
  --item-bg: #c9c5bd;
  --input-bg: #ffffff;
  --modal-bg: #d4d0c8;
  --modal-ink: #111111;
  --ink: #111111;
  --muted-ink: #4a4540;
  --led: #ff1f1f;
  --led-bg: #070707;
  --mine: #111111;
  --flag: #d40000;
  --n1: #0000ff;
  --n2: #008000;
  --n3: #ff0000;
  --n4: #000080;
  --n5: #800000;
  --n6: #008080;
  --n7: #000000;
  --n8: #808080;
  font-family: "Tahoma", "Verdana", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.5), transparent 52%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.018) 0 2px, transparent 2px 9px),
    var(--desktop);
}

.game-screen[data-level="2"] {
  --desktop: #e4e0d7;
  --chrome: #c9c4bb;
  --chrome-light: #f5f2eb;
  --chrome-dark: #706b64;
  --chrome-mid: #9e988f;
  --board: #b8b3aa;
  --cell: #bcb7ae;
  --revealed: #b0aba3;
  --item-bg: #c1bbb2;
  --modal-bg: #c9c4bb;
  --ink: #151515;
  --muted-ink: #4a4540;
  --mine: #111111;
}

.game-screen[data-level="3"] {
  --desktop: #c9c0b4;
  --chrome: #aaa39a;
  --chrome-light: #e1dbd1;
  --chrome-dark: #5f5a53;
  --chrome-mid: #858078;
  --board: #9b948b;
  --cell: #a39c93;
  --revealed: #948d85;
  --item-bg: #9d968d;
  --modal-bg: #aaa39a;
  --ink: #1a1111;
  --muted-ink: #4e3a38;
  --mine: #111111;
  --led: #ff2929;
}

.game-screen[data-level="4"] {
  --desktop: #3d3a37;
  --chrome: #6d6862;
  --chrome-light: #99938b;
  --chrome-dark: #2c2926;
  --chrome-mid: #514d49;
  --board: #5d5954;
  --cell: #6a655f;
  --revealed: #4f4b47;
  --item-bg: #5b5651;
  --input-bg: #34312e;
  --modal-bg: #6d6862;
  --modal-ink: #f2ece4;
  --ink: #f2ece4;
  --muted-ink: #c5bdb4;
  --led: #ff3a3a;
  --led-bg: #050505;
  --mine: #e9e2d8;
  --flag: #ff4f62;
  --n1: #74b8ff;
  --n2: #69e0a0;
  --n3: #ff7b8e;
  --n4: #b6a0ff;
  --n5: #f0b55f;
  --n6: #62d6da;
  --n7: #e9a9dc;
  --n8: #d3dce5;
}

.game-screen[data-level="5"] {
  --desktop: #0c0507;
  --chrome: #3c1c22;
  --chrome-light: #6b3a42;
  --chrome-dark: #170609;
  --chrome-mid: #2b1117;
  --board: #2b1117;
  --cell: #4a2028;
  --revealed: #2b1016;
  --item-bg: #3c171e;
  --input-bg: #1c080d;
  --modal-bg: #2a0d13;
  --modal-ink: #f5dadd;
  --ink: #f5dadd;
  --muted-ink: #bd8f95;
  --led: #ff2141;
  --led-bg: #040002;
  --mine: #f5dadd;
  --flag: #ff3d58;
  --n1: #74b8ff;
  --n2: #69e0a0;
  --n3: #ff7b8e;
  --n4: #b6a0ff;
  --n5: #f0b55f;
  --n6: #62d6da;
  --n7: #e9a9dc;
  --n8: #d3dce5;
}

.game-screen[data-level] .game-stage {
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 3px;
  background: var(--chrome);
  box-shadow:
    4px 4px 0 rgba(0, 0, 0, 0.2),
    inset 1px 1px 0 var(--chrome-light),
    inset -1px -1px 0 var(--chrome-dark);
  color: var(--ink);
}

.game-screen[data-level] .game-header {
  position: relative;
  min-height: 62px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--chrome-dark);
  background: var(--chrome);
  box-shadow:
    inset 1px 1px 0 var(--chrome-light),
    inset -1px 0 0 var(--chrome-dark);
}

.game-screen[data-level] .game-brand {
  gap: 9px;
}

.game-screen[data-level] .game-brand__icon {
  width: 34px;
  height: 34px;
  color: var(--mine);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: none;
}

.game-screen[data-level] .game-brand__icon svg {
  width: 22px;
  height: 22px;
}

.game-screen[data-level] .game-brand h1 {
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 1px 1px 0 var(--chrome-light);
}

.game-screen[data-level] .game-hud {
  gap: 8px;
}

.game-screen[data-level] .mine-counter,
.game-screen[data-level] .countdown {
  min-width: 78px;
  padding: 5px 9px;
  color: var(--led);
  border: 2px solid;
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  border-radius: 0;
  background: var(--led-bg);
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.85);
}

.game-screen[data-level] .mine-counter svg {
  width: 15px;
  height: 15px;
  color: var(--led);
  opacity: 0.85;
}

.game-screen[data-level] .mine-counter span,
.game-screen[data-level] .countdown strong {
  color: var(--led);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 20px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 9px rgba(255, 32, 32, 0.32);
}

.game-screen[data-level] .countdown__label {
  color: #d08a8a;
  font-size: 8px;
}

.game-screen[data-level] .abandon-button {
  padding: 7px 11px;
  color: var(--ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-light), inset -1px -1px 0 var(--chrome-dark);
  font-size: 11px;
  font-weight: 700;
}

.game-screen[data-level] .abandon-button:hover {
  background: var(--chrome-mid);
  color: var(--ink);
}

.game-screen[data-level] .sound-button--game {
  width: 35px;
  height: 35px;
  color: var(--ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-light), inset -1px -1px 0 var(--chrome-dark);
}

.game-screen[data-level] .sound-button--game:hover {
  background: var(--chrome-mid);
}

.game-screen[data-level] .game-play {
  gap: 10px;
  padding: 9px;
  background: var(--chrome);
}

.game-screen[data-level] .board-panel {
  border: 2px solid;
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-dark), inset -1px -1px 0 var(--chrome-light);
}

.game-screen[data-level] .board-status-row {
  padding: 6px 8px;
  border-bottom: 1px solid var(--chrome-dark);
  background: var(--chrome);
}

.game-screen[data-level] .board-status {
  color: var(--muted-ink);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.game-screen[data-level] .board-status.is-lost {
  color: #8c0000;
}

.game-screen[data-level] .board-status.is-won {
  color: #075c27;
}

.game-screen[data-level="4"] .board-status.is-lost,
.game-screen[data-level="5"] .board-status.is-lost {
  color: #ff7b8e;
}

.game-screen[data-level="4"] .board-status.is-won,
.game-screen[data-level="5"] .board-status.is-won {
  color: #75c9a1;
}

.game-screen[data-level] .board-level {
  color: var(--muted-ink);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 9px;
}

.game-screen[data-level] .board-viewport {
  background: var(--chrome);
}

.game-screen[data-level] .board {
  gap: var(--cell-gap, 2px);
  padding: var(--board-pad, 8px);
  border: 2px solid;
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  background: var(--board);
}

.game-screen[data-level] .cell {
  color: var(--ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--cell);
  box-shadow: none;
  font-family: "Tahoma", "Verdana", "Segoe UI", sans-serif;
  font-size: calc(var(--cell-size) * 0.48);
  font-weight: 800;
  text-shadow: none;
  overflow: visible;
}

.game-screen[data-level] .cell:not(.is-revealed) {
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  background: var(--cell);
  box-shadow: none;
}

.game-screen[data-level] .cell:active {
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  background: var(--revealed);
  filter: none;
  transform: none;
}

.game-screen[data-level] .cell:focus-visible {
  outline: 2px solid #d04a00;
  outline-offset: 1px;
}

.game-screen[data-level] .cell.is-revealed {
  color: var(--ink);
  border: 1px solid var(--chrome-dark);
  border-bottom-color: var(--chrome-light);
  border-right-color: var(--chrome-light);
  background: var(--revealed);
  box-shadow: none;
}

.game-screen[data-level] .cell.is-flagged {
  background: var(--cell);
}

.game-screen[data-level] .cell.is-flagged .cell-icon {
  color: var(--flag);
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.3));
}

.game-screen[data-level] .cell.is-mine {
  color: var(--mine);
  border: 1px solid var(--chrome-dark);
  border-bottom-color: var(--chrome-light);
  border-right-color: var(--chrome-light);
  background: var(--revealed);
}

.game-screen[data-level] .cell.is-exploded {
  color: #fff;
  border: 1px solid #7e0000;
  background: #cc222b;
  box-shadow: none;
  animation: mineBoom 0.4s ease;
}

.game-screen[data-level] .cell.is-wrong::after {
  color: #b90016;
  text-shadow: 1px 1px 0 #fff;
}

.game-screen[data-level] .cell[data-number="1"] { color: var(--n1); }
.game-screen[data-level] .cell[data-number="2"] { color: var(--n2); }
.game-screen[data-level] .cell[data-number="3"] { color: var(--n3); }
.game-screen[data-level] .cell[data-number="4"] { color: var(--n4); }
.game-screen[data-level] .cell[data-number="5"] { color: var(--n5); }
.game-screen[data-level] .cell[data-number="6"] { color: var(--n6); }
.game-screen[data-level] .cell[data-number="7"] { color: var(--n7); }
.game-screen[data-level] .cell[data-number="8"] { color: var(--n8); }

@media (hover: hover) and (pointer: fine) {
  .game-screen[data-level] .cell:not(.is-revealed):not(.is-flagged):not(.has-tentacle):hover {
    filter: brightness(1.04);
    transform: none;
    border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
    box-shadow: none;
  }
}

.game-screen[data-level] .cell.is-loose {
  animation: looseIdle 1.9s ease-in-out infinite;
  box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.18);
}

.game-screen[data-level] .cell.is-loose:hover {
  z-index: 6;
  animation: looseHoverHard 0.22s linear infinite;
}

.game-screen[data-level] .cell.has-spike {
  position: relative;
}

.game-screen[data-level] .cell.has-spike::after {
  content: none;
  display: none;
}

.game-screen[data-level] .spike-art {
  position: absolute;
  inset: 4%;
  z-index: 2;
  width: 92%;
  height: 92%;
  pointer-events: none;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.5));
  animation: spikeBreathe 2.6s ease-in-out infinite;
}

.game-screen[data-level] .cell.has-tentacle-peek {
  z-index: 14;
  overflow: visible;
  box-shadow: inset 0 0 8px rgba(78, 0, 16, 0.5);
}

.game-screen[data-level] .tentacle-peek {
  position: absolute;
  left: -16%;
  top: -16%;
  z-index: 5;
  width: 132%;
  height: 132%;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(145, 18, 42, 0.5)) drop-shadow(1px 3px 2px rgba(0, 0, 0, 0.62));
  animation: peekSway 3.2s ease-in-out infinite;
}

.game-screen[data-level] .peek-strand {
  transform-box: fill-box;
  transform-origin: 50% 90%;
}

.game-screen[data-level] .peek-1 { animation: peekSway 2.9s ease-in-out infinite; }
.game-screen[data-level] .peek-2 { animation: peekSway 3.4s ease-in-out infinite reverse; }
.game-screen[data-level] .peek-3 { animation: peekSway 3.1s ease-in-out infinite -1.2s; }
.game-screen[data-level] .peek-4 { animation: peekSway 2.8s ease-in-out infinite -0.7s reverse; }

.game-screen[data-level] .cell.has-tentacle-peek:hover .tentacle-peek {
  animation-duration: 0.45s;
}

.game-screen[data-level] .cell.has-tentacle {
  z-index: 50;
  overflow: visible;
  isolation: isolate;
  -webkit-clip-path: polygon(-38% -88%, 138% -88%, 100% 0%, 100% 100%, 0 100%, 0 0%);
  clip-path: polygon(-38% -88%, 138% -88%, 100% 0%, 100% 100%, 0 100%, 0 0%);
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  background: #070207;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.95);
}

.game-screen[data-level] .cell.has-tentacle::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
}

.game-screen[data-level] .cell.has-tentacle::after {
  content: none;
}

.game-screen[data-level] .tentacle-cluster {
  position: absolute;
  left: -30%;
  top: -38%;
  z-index: 2;
  width: 160%;
  height: 172%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(2px 8px 5px rgba(0, 0, 0, 0.62));
  transform-origin: 50% 78%;
  transition: opacity 0.18s ease, transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.game-screen[data-level] .tentacle-strand {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: tentacleSway 3.4s ease-in-out infinite;
}

.game-screen[data-level] .strand-2 { animation-delay: -0.6s; }
.game-screen[data-level] .strand-3 { animation-delay: -1.1s; }
.game-screen[data-level] .strand-4 { animation-delay: -1.7s; }
.game-screen[data-level] .strand-5 { animation-delay: -2.2s; }

.game-screen[data-level] .cell.has-tentacle:hover .tentacle-cluster {
  opacity: 0;
  transform: translateY(28%) scale(0.62);
}

.game-screen[data-level] .cell.has-tentacle.is-dragging-tool .tentacle-cluster {
  opacity: 1;
  transform: none;
}

.game-screen[data-level] .cell.has-tentacle.is-tentacle-cut .tentacle-cluster {
  display: none;
}

.game-screen[data-level] .cell.has-tentacle .cell-number {
  position: relative;
  z-index: 3;
  color: #fff;
  opacity: 0;
  font-family: "Tahoma", "Verdana", sans-serif;
  font-weight: 800;
  text-shadow: 0 0 7px rgba(0, 0, 0, 0.85);
  transition: opacity 0.12s ease;
}

.game-screen[data-level] .cell.has-tentacle:hover .cell-number,
.game-screen[data-level] .cell.has-tentacle.is-dragging-tool .cell-number,
.game-screen[data-level] .cell.has-tentacle.is-tentacle-cut .cell-number {
  opacity: 1;
}

.game-screen[data-level] .inventory-panel {
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-light), inset -1px -1px 0 var(--chrome-dark);
  color: var(--ink);
}

.game-screen[data-level] .inventory-heading {
  border-bottom: 1px solid var(--chrome-dark);
}

.game-screen[data-level] .inventory-heading h2 {
  color: var(--ink);
}

.game-screen[data-level] .inventory-heading span {
  color: var(--muted-ink);
}

.game-screen[data-level] .inventory-empty {
  color: var(--muted-ink);
  border: 1px dashed var(--chrome-dark);
}

.game-screen[data-level] .inventory-item {
  color: var(--ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--item-bg);
  box-shadow: none;
}

.game-screen[data-level] .inventory-item:hover {
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  background: var(--chrome-mid);
  transform: none;
}

.game-screen[data-level] .inventory-item__icon {
  color: var(--ink);
  border: 1px solid var(--chrome-dark);
  border-radius: 0;
  background: var(--chrome);
}

.game-screen[data-level] .inventory-item strong {
  color: var(--ink);
}

.game-screen[data-level] .inventory-item span {
  color: var(--muted-ink);
}

.game-screen[data-level] .inventory-tip {
  color: var(--muted-ink);
  border-top: 1px solid var(--chrome-dark);
}

.game-screen[data-level] .game-footer {
  color: var(--muted-ink);
  border-top: 2px solid var(--chrome-dark);
  background: var(--chrome);
  box-shadow: inset 0 1px 0 var(--chrome-light);
}

.game-screen[data-level] .game-footer__level {
  color: var(--muted-ink);
}

.game-screen[data-level] .inventory-panel {
  display: flex;
}

.game-screen:not(.has-inventory) .inventory-panel {
  display: none;
}

.game-screen:not(.has-inventory) .game-play {
  grid-template-columns: minmax(0, 1fr);
}

.game-screen:not(.has-inventory) .game-stage {
  width: min(820px, 100%);
  height: min(720px, calc(100dvh - 32px));
}

/* Centered developer dialogue */

.dialogue-layer {
  align-items: center !important;
  justify-content: center !important;
  padding: 0 8% !important;
  background: rgba(0, 0, 0, 0.5) !important;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.dialogue-box {
  width: min(850px, 100%);
  min-height: 185px;
  border-radius: 0;
  border-left-width: 2px;
  background:
    linear-gradient(135deg, rgba(5, 8, 11, 0.96), rgba(0, 0, 0, 0.97));
}

.dialogue-text {
  font-size: 19px;
  line-height: 1.9;
}

.dialogue-speaker {
  font-size: 11px;
}

/* Classic dialogs and failure pliers */

.modal {
  color: var(--modal-ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--modal-bg);
  box-shadow:
    4px 4px 0 rgba(0, 0, 0, 0.28),
    inset 1px 1px 0 var(--chrome-light),
    inset -1px -1px 0 var(--chrome-dark);
}

.modal h2 {
  color: var(--modal-ink);
}

.modal__eyebrow {
  color: var(--muted-ink);
}

.modal__text {
  color: var(--muted-ink);
}

.failure-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 2px;
}

.failure-title-row h2 {
  margin: 0;
}

.hidden-pliers {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: #5a0b17;
  border: 0;
  border-radius: 50%;
  background: transparent;
  opacity: 0.9;
  cursor: pointer;
  transform: translateY(2px) rotate(-14deg);
  transition: transform 0.16s ease, color 0.16s ease;
}

.hidden-pliers:hover {
  color: #b00020;
  transform: translateY(1px) rotate(-6deg) scale(1.12);
}

.hidden-pliers:focus-visible {
  outline: 2px solid #7d0018;
}

.hidden-pliers svg {
  width: 23px;
  height: 23px;
  filter: drop-shadow(1px 1px 0 rgba(255, 255, 255, 0.15));
}

.game-screen[data-level="4"] .hidden-pliers,
.game-screen[data-level="5"] .hidden-pliers {
  color: #e6a0a8;
}

.modal .button {
  color: var(--modal-ink);
  border: 2px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 0;
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-light), inset -1px -1px 0 var(--chrome-dark);
  font-weight: 700;
}

.modal .button:hover {
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  background: var(--chrome-mid);
  transform: none;
}

.modal .button--primary {
  color: var(--modal-ink);
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  background: var(--chrome);
  box-shadow: inset 1px 1px 0 var(--chrome-light), inset -1px -1px 0 var(--chrome-dark);
}

.modal .button--danger {
  color: #4d0000;
  background: #c7b1ad;
}

.modal .button--quiet {
  color: var(--modal-ink);
}

.key-form input {
  color: var(--modal-ink);
  border: 2px solid;
  border-color: var(--chrome-dark) var(--chrome-light) var(--chrome-light) var(--chrome-dark);
  border-radius: 0;
  background: var(--input-bg);
}

.key-error {
  color: #9c0015;
}

/* Full-screen ending pages */

.ending-screen {
  overflow: hidden !important;
  background: #000 !important;
}

.ending-content {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.ending-page {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  padding: 7vh 9vw;
  box-sizing: border-box;
}

.ending-page__inner {
  width: min(940px, 100%);
  margin: 0 auto;
}

.ending-page--narrative .ending-page__inner {
  max-width: 850px;
}

.ending-page--narrative .ending-line {
  margin: 0 0 0.95em;
  color: #e9eef6;
  font-size: clamp(18px, 1.6vw, 24px);
  line-height: 1.85;
  letter-spacing: 0.035em;
}

.ending-page--terminal .ending-page__inner {
  max-width: 800px;
  padding-left: 24px;
  border-left: 2px solid rgba(94, 129, 104, 0.45);
}

.ending-page--terminal .ending-line {
  margin: 0 0 0.72em;
  color: #9fb7a4;
  font-family: var(--font-mono);
  font-size: clamp(13px, 1.15vw, 17px);
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.ending-page--terminal .ending-line.is-red {
  color: #ff5d73;
}

.ending-page--title {
  text-align: center;
}

.ending-page--title .ending-page__inner {
  max-width: 900px;
}

.ending-page--title .ending-title {
  margin: 0 0 0.45em;
  font-size: clamp(34px, 4.2vw, 62px);
  letter-spacing: 0.1em;
}

.ending-page--title .ending-line.is-hint {
  margin: 2.2em auto 0;
  max-width: 680px;
  color: #737f8c;
  font-size: clamp(12px, 1vw, 15px);
  line-height: 1.8;
}

.ending-page--title .ending-line.is-thanks {
  margin: 0.8em 0 0;
  color: #e8d7ae;
  font-size: clamp(19px, 1.8vw, 26px);
}

.ending-page--title .ending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 2.2em;
}

.ending-screen.is-blackout .ending-content {
  display: none;
}

/* New tentacle and spike animations */

@keyframes looseIdle {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  14% { transform: translate(-1.4px, 0.7px) rotate(-2deg); }
  28% { transform: translate(1.5px, -0.9px) rotate(2.2deg); }
  43% { transform: translate(-1px, 1.1px) rotate(-1.2deg); }
  57% { transform: translate(0.9px, -0.6px) rotate(1.1deg); }
  72% { transform: translate(-0.4px, 0.5px) rotate(-0.5deg); }
  86% { transform: translate(0.2px, 0px) rotate(0.2deg); }
}

@keyframes looseHoverHard {
  0% { transform: translate(0, 0) rotate(0deg); }
  16% { transform: translate(-2.2px, 1.8px) rotate(-3.4deg); }
  33% { transform: translate(2.1px, -1.9px) rotate(3.2deg); }
  50% { transform: translate(-1.8px, -1.2px) rotate(-2.8deg); }
  66% { transform: translate(1.7px, 1.6px) rotate(2.5deg); }
  83% { transform: translate(-1px, -0.8px) rotate(-1.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes tentacleSway {
  0%, 100% { transform: rotate(-1.7deg) translateY(0); }
  25% { transform: rotate(1.2deg) translateY(-1px); }
  50% { transform: rotate(-0.8deg) translateY(0.5px); }
  75% { transform: rotate(1.8deg) translateY(-0.5px); }
}

@keyframes spikeBreathe {
  0%, 100% { transform: scale(0.96) rotate(0deg); opacity: 0.88; }
  50% { transform: scale(1.04) rotate(1deg); opacity: 1; }
}

@media (max-width: 820px) {
  .game-screen[data-level] .game-header {
    min-height: 54px;
    padding: 6px 8px;
  }

  .game-screen[data-level] .game-brand h1 {
    font-size: 19px;
  }

  .game-screen[data-level] .mine-counter,
  .game-screen[data-level] .countdown {
    min-width: 68px;
    padding: 4px 6px;
  }

  .dialogue-box {
    min-height: 160px;
    padding: 18px 22px 23px;
  }

  .dialogue-text {
    font-size: 16px;
  }

  .ending-page {
    padding: 6vh 7vw;
  }
}

/* ===== Level 4 eerie backdrop ===== */

.game-screen[data-level="4"] {
  background:
    linear-gradient(180deg, rgba(5, 1, 3, 0.28), rgba(2, 0, 1, 0.78)),
    url("assets/level4-backdrop.jpg") center / cover no-repeat,
    var(--desktop);
}

.game-screen[data-level="4"] .board {
  padding-top: calc(var(--board-pad, 8px) + 22px);
}

.game-screen[data-level="4"] .game-stage {
  width: min(1120px, 100%);
  box-shadow:
    0 0 60px rgba(116, 4, 22, 0.26),
    4px 4px 0 rgba(0, 0, 0, 0.3),
    inset 1px 1px 0 var(--chrome-light),
    inset -1px -1px 0 var(--chrome-dark);
}

/* ===== Ending memory backdrops ===== */

.ending-screen[data-ending="bad"] { --ending-bg: url("assets/ending-bad.jpg"); }
.ending-screen[data-ending="good"] { --ending-bg: url("assets/ending-good.jpg"); }
.ending-screen[data-ending="normal"] { --ending-bg: url("assets/ending-normal.jpg"); }
.ending-screen[data-ending="hidden"] { --ending-bg: url("assets/ending-hidden.jpg"); }

.ending-page--narrative {
  position: relative;
  overflow: hidden;
  background: #000;
}

.ending-page--narrative::before {
  content: "";
  position: absolute;
  inset: -5%;
  z-index: 0;
  background-image: var(--ending-bg, none);
  background-position: center;
  background-size: cover;
  filter: blur(5px) brightness(1.06) saturate(1.03);
  opacity: 1;
  transform: scale(1.04);
  animation: endingBackdropIn 1.6s ease-out both;
}

.ending-page--narrative::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.16) 86%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.2) 48%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.16) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.3));
}

.ending-page--narrative .ending-page__inner {
  position: relative;
  z-index: 1;
}

.ending-page--narrative .ending-line {
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.88), 0 0 1px #000;
}

/* ===== Level 3 shake and trembling text box ===== */

.game-screen.is-level3-shake .game-stage {
  animation: level3Shake 0.62s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.dialogue-box.is-trembling {
  animation: dialogueTremble 1.55s ease-in-out infinite;
}

/* ===== Level 5 alarm flash and blocked notice ===== */

.level-flash {
  position: absolute;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  opacity: 0;
  background: #fff;
}

.level-flash.is-active {
  animation: levelFlash 0.58s ease-out;
}

.spike-notice {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 85;
  padding: 14px 22px;
  pointer-events: none;
  color: #f2dadd;
  border: 1px solid rgba(186, 36, 58, 0.58);
  background: rgba(7, 2, 4, 0.92);
  box-shadow: 0 0 35px rgba(130, 0, 22, 0.28);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.spike-notice.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.dialogue-text.is-emphasis {
  color: #ff3d58;
  text-shadow: 0 0 26px rgba(255, 30, 68, 0.8);
}

.is-god-blur {
  display: inline-block;
  opacity: 0.9;
  filter: blur(1.8px);
  text-shadow: 0 0 12px rgba(255, 30, 68, 0.75);
}

.l5-text-jumpscare {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.l5-jumpscare-hand {
  position: absolute;
  width: min(80vmin, 960px);
  height: auto;
  opacity: 0;
  transform: scale(0.5) rotate(-5deg);
  filter: drop-shadow(0 0 50px rgba(126, 0, 18, 0.65));
  transform-origin: center;
}

.l5-jumpscare-word {
  position: relative;
  z-index: 2;
  color: #ff2d4a;
  font-size: min(30vh, 14vw);
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 0 48px rgba(255, 20, 54, 0.9), 0 0 10px rgba(255, 210, 218, 0.4);
  opacity: 0;
  transform: scale(0.3);
  filter: blur(6px);
}

.l5-text-jumpscare.is-active .l5-jumpscare-hand {
  animation: l5HandSlam 1.05s cubic-bezier(0.15, 0.9, 0.2, 1) forwards;
}

.l5-text-jumpscare.is-active .l5-jumpscare-word {
  animation: l5WordSlam 1.05s cubic-bezier(0.15, 0.9, 0.2, 1) forwards;
}

@keyframes l5HandSlam {
  0% { opacity: 0; transform: scale(0.5) rotate(-5deg); }
  12% { opacity: 0.82; }
  58% { opacity: 0.9; transform: scale(1.02) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.08) rotate(0deg); }
}

@keyframes l5WordSlam {
  0% { opacity: 0; transform: scale(0.3); filter: blur(6px); }
  12% { opacity: 1; filter: blur(0); }
  58% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); filter: blur(0); }
}

.dialogue-box.is-alarm {
  animation: dialogueAlarm 0.86s ease-out;
}

/* ===== New animation keyframes ===== */

@keyframes level3Shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  8% { transform: translate(-7px, 3px) rotate(-0.35deg); }
  18% { transform: translate(7px, -4px) rotate(0.4deg); }
  28% { transform: translate(-5px, -3px) rotate(-0.28deg); }
  38% { transform: translate(6px, 4px) rotate(0.32deg); }
  50% { transform: translate(-4px, 2px) rotate(-0.2deg); }
  64% { transform: translate(3px, -2px) rotate(0.16deg); }
  78% { transform: translate(-2px, 1px) rotate(-0.1deg); }
}

@keyframes dialogueTremble {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-0.7px, 0.3px) rotate(-0.12deg); }
  42% { transform: translate(0.6px, -0.4px) rotate(0.1deg); }
  61% { transform: translate(-0.4px, -0.2px) rotate(-0.08deg); }
  81% { transform: translate(0.5px, 0.3px) rotate(0.06deg); }
}

@keyframes dialogueEmphasis {
  0% { transform: scale(1); }
  18% { transform: scale(1.92); }
  38% { transform: scale(1.6); }
  62% { transform: scale(1.78); }
  100% { transform: scale(1); }
}

@keyframes dialogueAlarm {
  0% { box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8); }
  25% { box-shadow: 0 0 70px rgba(255, 20, 54, 0.5); }
  100% { box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8); }
}

@keyframes levelFlash {
  0% { opacity: 0; }
  10% { opacity: 0.92; }
  30% { opacity: 0.55; }
  100% { opacity: 0; }
}

@keyframes peekSway {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  30% { transform: rotate(2.6deg) translateY(-1px); }
  58% { transform: rotate(-1.4deg) translateY(0.6px); }
  82% { transform: rotate(1.8deg) translateY(-0.4px); }
}

@keyframes endingBackdropIn {
  0% { opacity: 0; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1.04); }
}

#gameScreen[data-pollution="2"] .cell[data-number] {
  text-shadow: 0 0 6px rgba(180, 12, 32, 0.22);
}

#gameScreen[data-pollution="3"] .cell[data-number] {
  text-shadow:
    0 0 9px rgba(180, 12, 32, 0.34),
    1px 0 rgba(255, 0, 0, 0.12),
    -1px 0 rgba(0, 255, 255, 0.10);
}

@media (prefers-reduced-motion: no-preference) {
  #gameScreen[data-pollution="2"] .cell:not(.is-revealed):not(.is-flagged):not(.is-loose):not(.has-tentacle-peek):not(.is-new):not(.has-spike) {
    animation: pollutionBreathe 18s ease-in-out infinite;
  }

  #gameScreen[data-pollution="3"] .cell:not(.is-revealed):not(.is-flagged):not(.is-loose):not(.has-tentacle-peek):not(.is-new):not(.has-spike) {
    animation: pollutionBreathe 12s ease-in-out infinite;
  }

  .cell.is-twitch {
    rotate: 0.6deg;
    translate: 0 0.5px;
  }
}

@keyframes pollutionBreathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.004; }
}

@media (max-width: 720px) {
  #gameScreen[data-pollution="2"] .cell:not(.is-revealed):not(.is-flagged):not(.is-loose):not(.has-tentacle-peek):not(.is-new):not(.has-spike),
  #gameScreen[data-pollution="3"] .cell:not(.is-revealed):not(.is-flagged):not(.is-loose):not(.has-tentacle-peek):not(.is-new):not(.has-spike) {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-pollution__grain {
    animation: none;
  }

  .fx-pollution__stain {
    animation: none;
    opacity: 0.10;
  }

  .fx-pollution__stain.is-strong {
    opacity: 0.12;
  }
}

.collection-button {
  padding: 8px 13px;
  color: #c8d5e4;
  border: 1px solid rgba(150, 173, 196, 0.24);
  border-radius: 7px;
  background: rgba(18, 29, 43, 0.72);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.collection-button:hover {
  color: #ffe6ae;
  border-color: rgba(243, 198, 91, 0.42);
  background: rgba(58, 45, 21, 0.56);
}

.collection-layer {
  z-index: 65;
  padding: 18px;
}

.collection-panel {
  position: relative;
  box-sizing: border-box;
  width: min(1040px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: clamp(18px, 2.4vw, 32px);
  border: 1px solid rgba(184, 202, 222, 0.2);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(22, 31, 44, 0.98), rgba(8, 12, 18, 0.99)),
    #080c13;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.collection-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.collection-head h2 {
  margin: 0.18em 0 0;
  color: #f0f4f8;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0.1em;
}

.collection-close {
  flex: 0 0 auto;
}

.collection-count {
  margin: 0.7em 0 1.1em;
  color: #9eafc2;
  font-size: 13px;
  letter-spacing: 0.08em;
}

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

.collection-card {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid rgba(157, 180, 204, 0.18);
  border-radius: 10px;
  background: rgba(10, 16, 24, 0.86);
}

.collection-card.is-collected {
  box-shadow: 0 0 0 1px rgba(243, 198, 91, 0.12), 0 12px 30px rgba(0, 0, 0, 0.28);
}

.collection-card__image {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: cover;
  opacity: 0.82;
  filter: saturate(0.9) contrast(1.03);
}

.collection-card__body {
  padding: 13px 15px 15px;
}

.collection-card__title {
  margin: 0;
  color: #e9eff6;
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 650;
  letter-spacing: 0.04em;
}

.collection-card__status {
  margin: 0.55em 0 0;
  color: #8fa2b7;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.collection-card.is-locked {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 38%, rgba(88, 104, 122, 0.16), transparent 58%),
    linear-gradient(145deg, rgba(20, 28, 40, 0.9), rgba(8, 12, 18, 0.96));
}

.collection-card.is-locked::before {
  content: "?";
  display: block;
  margin-bottom: 12px;
  color: rgba(168, 188, 210, 0.38);
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 0 24px rgba(126, 157, 190, 0.18);
}

.collection-card.is-locked .collection-card__body {
  padding: 0;
  text-align: center;
}

.collection-card.is-locked .collection-card__title {
  color: #aab8c8;
}

.collection-card.is-locked .collection-card__status {
  color: #718296;
}

.collection-complete {
  position: relative;
  z-index: 3;
  width: 100%;
  margin: 20px 0 4px;
  color: #fff1c4;
  font-size: clamp(24px, 3.4vw, 44px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 0 30px rgba(255, 210, 110, 0.6), 0 0 3px #fff;
  pointer-events: none;
  animation: collectionThanksIn 0.8s ease-out both;
}

.collection-fireworks {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.firework-burst {
  position: absolute;
  width: 0;
  height: 0;
}

.firework-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fw-color);
  box-shadow: 0 0 10px var(--fw-color);
  opacity: 0;
  animation: collectionFirework 1.5s ease-out var(--fw-delay) forwards;
}

@keyframes collectionFirework {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  14% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--fw-x), var(--fw-y)) scale(1); }
}

@keyframes collectionThanksIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .collection-grid {
    grid-template-columns: 1fr;
  }

  .collection-panel {
    max-height: 92vh;
  }

  .collection-card__image {
    height: 130px;
  }
}

.fx-corruption {
  position: absolute;
  inset: 0;
  z-index: 32;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.game-screen[data-level="4"] .fx-corruption,
.game-screen[data-level="5"] .fx-corruption {
  display: block;
}

.fx-corruption__edge {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3.2px);
  backdrop-filter: blur(3.2px);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.55) 70%, #000 100%);
  mask-image: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.55) 70%, #000 100%);
}

.game-screen[data-level="5"] .fx-corruption__edge {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.fx-corruption__noise {
  position: absolute;
  inset: -8%;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.72'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: soft-light;
  animation: corruptionNoise 0.9s steps(2) infinite;
}

.game-screen[data-level="5"] .fx-corruption__noise {
  opacity: 0.07;
}

.fx-ui-blood {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  pointer-events: none;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 12px rgba(90, 0, 12, 0.28));
}

.game-screen[data-level="4"] .fx-ui-blood,
.game-screen[data-level="5"] .fx-ui-blood {
  display: block;
}

.fx-ui-blood--header {
  opacity: 0.58;
  background-image:
    url("assets/blood-stain.png"),
    url("assets/blood-stain.png");
  background-size: 14% auto, 6% auto;
  background-position: 2% 58%, 87% 4%;
}

.fx-ui-blood--inventory {
  opacity: 0.62;
  background-image:
    url("assets/blood-stain.png"),
    url("assets/blood-stain.png");
  background-size: 82% auto, 38% auto;
  background-position: -16% 5%, 70% 83%;
}

.fx-ui-blood--footer {
  opacity: 0.48;
  background-image: url("assets/blood-stain.png");
  background-size: 9% auto;
  background-position: 6% 38%;
}

.game-screen[data-level="5"] .fx-ui-blood--header,
.game-screen[data-level="5"] .fx-ui-blood--inventory {
  opacity: 0.66;
}

@keyframes corruptionNoise {
  0% { background-position: 0 0; }
  50% { background-position: 70px 36px; }
  100% { background-position: -50px 62px; }
}

@media (max-width: 720px) {
  .fx-corruption__edge {
    -webkit-backdrop-filter: blur(2.4px);
    backdrop-filter: blur(2.4px);
  }

  .fx-corruption__noise {
    animation: none;
  }
}

.loose-dust {
  position: fixed;
  z-index: 34;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #a68b74;
  box-shadow: 0 0 4px rgba(120, 96, 76, 0.7);
  pointer-events: none;
  animation: looseDustFall 0.82s ease-out var(--dust-delay, 0s) forwards;
}

.loose-drop-clone {
  position: fixed;
  z-index: 35;
  margin: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
  animation: looseCellDrop 2s cubic-bezier(0.42, 0, 0.72, 0.48) forwards;
}

.cell.is-loose-dropping {
  opacity: 0;
}

@keyframes looseDustFall {
  0% { opacity: 0.9; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dust-x, 0), 54px) scale(0.25); }
}

@keyframes looseCellDrop {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  18% { transform: translateY(9px) rotate(2.2deg); }
  100% { opacity: 0; transform: translateY(var(--drop-distance, 80vh)) rotate(13deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loose-dust,
  .loose-drop-clone {
    animation-duration: 0.01s;
  }
}

.is-glitch-code {
  display: inline-block;
  min-width: 6.5ch;
  color: #ff4d63;
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.04em;
  animation: codeJitter 0.16s steps(2) infinite;
}

@keyframes codeJitter {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(0.5px, -0.5px); }
}

@media (prefers-reduced-motion: reduce) {
  .is-glitch-code {
    animation: none;
  }
}
