@font-face {
  font-family: Equilibrist;
  src: url('/fonts/Equilibrist-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
  --brand-font: Equilibrist, Georgia, "Times New Roman", serif;
  --app-bg: #181818;
  --panel: #202020;
  --panel-elevated: #2b2b2b;
  --board: #141414;
  --empty-cell: #292929;
  --text: #e0e0e0;
  --muted: #aaa;
  --dim: #777;
  --border: #444;
  --border-strong: #555;
  --border-bevel: rgba(255,255,255,0.08);
  --button-bg: linear-gradient(to bottom, #353535 0%, #202020 100%);
  --button-active: linear-gradient(to bottom, #202020 0%, #353535 100%);
  --surface: linear-gradient(to bottom, #2b2b2b 0%, #1a1a1a 100%);
  --accent: #d0d0d0;
  --brand-accent: #b34838;
  --scrim: rgba(0,0,0,0.78);
  --grid-size: 8;
  --cell-gap: 3px;
  --board-size: min(calc(100vw - 26px), 552px, calc(100dvh - 235px));
  --cell-radius: 4px;
  --texture-1: none;
  --texture-2: none;
  --texture-3: none;
  --texture-4: none;
  --texture-5: none;
  --texture-6: none;
  --texture-7: none;
  --color-1: #b44949;
  --color-2: #a66f48;
  --color-3: #a99455;
  --color-4: #5f826a;
  --color-5: #557b85;
  --color-6: #626b8c;
  --color-7: #806181;
}

[data-theme="light"] {
  --app-bg: #e8e8e8;
  --panel: #f7f7f7;
  --panel-elevated: #fafafa;
  --board: #d2d2d2;
  --empty-cell: #ededed;
  --text: #222;
  --muted: #555;
  --dim: #888;
  --border: #b0b0b0;
  --border-strong: #999;
  --border-bevel: #fff;
  --button-bg: linear-gradient(to bottom, #fff 0%, #e8e8e8 100%);
  --button-active: linear-gradient(to bottom, #e8e8e8 0%, #fff 100%);
  --surface: linear-gradient(to bottom, #fff 0%, #e6e6e6 100%);
  --accent: #333;
  --brand-accent: #963525;
  --scrim: rgba(20,20,20,0.62);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-width: 300px;
  min-height: 520px;
  height: 100%;
  overflow: hidden;
}

body {
  color: var(--text);
  background:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px),
    var(--app-bg);
  background-size: 24px 24px;
  font-family: var(--font);
  overscroll-behavior: none;
  user-select: none;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

textarea,
select,
input {
  user-select: text;
}

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

.hidden {
  display: none !important;
}

.game-background {
  position: fixed;
  inset: -20px;
  z-index: 0;
  opacity: 0;
  background-position: center;
  background-size: cover;
  filter: blur(9px) saturate(0.85);
  transition: opacity 250ms ease;
}

.game-background::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--scrim);
}

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.game-app {
  position: relative;
  z-index: 2;
  width: min(100%, 590px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top-bar {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-brand-name {
  font-family: var(--brand-font);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.top-actions {
  display: flex;
  gap: 9px;
}

.language-select {
  min-width: 49px;
}

.board-size-select {
  height: 39px;
  min-width: 58px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: 3px;
  outline: 0;
  color: var(--text);
  background: var(--button-bg);
  box-shadow: inset 0 1px 0 var(--border-bevel);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.board-size-select:focus-visible {
  border-color: var(--accent);
}

.round-button {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text);
  background: var(--button-bg);
  box-shadow: inset 0 1px 0 var(--border-bevel), 0 1px 2px rgba(0,0,0,0.18);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease;
}

.round-button:hover,
.round-button:focus-visible {
  outline: none;
  border-color: var(--border-strong);
  background: var(--panel-elevated);
  transform: translateY(-1px);
}

.round-button:active {
  transform: scale(0.94);
}

.score-area {
  position: relative;
  width: var(--board-size);
  flex: 0 0 auto;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.best-score {
  position: absolute;
  left: 0;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 54px;
  min-height: 28px;
  padding: 5px 8px;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: 3px;
  background: var(--button-bg);
  box-shadow: inset 0 1px 0 var(--border-bevel), 0 1px 2px rgba(0,0,0,0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  transform: translateY(-50%);
}

.crown {
  color: var(--brand-accent);
  font-size: 0.78rem;
}

#score {
  color: var(--text);
  font-size: clamp(3rem, 11vw, 4.35rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
}

#score.bump {
  animation: score-bump 220ms ease-out;
}

@keyframes score-bump {
  50% { transform: scale(1.16); color: var(--accent); }
}

.combo-label {
  position: absolute;
  right: -2px;
  bottom: 3px;
  padding: 4px 9px;
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--brand-accent), black 25%);
  border-radius: 3px;
  background: var(--brand-accent);
  font-size: 0.7rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--brand-accent), transparent 62%);
  animation: combo-pop 260ms ease-out;
}

@keyframes combo-pop {
  from { opacity: 0; transform: scale(0.7); }
}

.board-shell {
  flex: 0 0 auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.35),
    inset 0 1px 0 var(--border-bevel);
}

.board-shell.celebrating {
  animation: board-celebrate 320ms ease-out;
}

@keyframes board-celebrate {
  45% {
    border-color: color-mix(in srgb, var(--brand-accent), white 34%);
    box-shadow:
      0 0 24px color-mix(in srgb, var(--brand-accent), transparent 46%),
      inset 0 0 18px color-mix(in srgb, var(--brand-accent), transparent 62%);
  }
}

.game-board {
  display: grid;
  width: var(--board-size);
  height: var(--board-size);
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-size), minmax(0, 1fr));
  gap: var(--cell-gap);
  touch-action: none;
}

.board-cell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--cell-radius);
  background: var(--empty-cell);
  border: 1px solid color-mix(in srgb, var(--border), transparent 28%);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.24);
  overflow: hidden;
}

.board-cell.occupied,
.board-cell.preview-valid,
.piece-block {
  background-color: var(--block-color);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(0,0,0,0.08)),
    var(--block-texture),
    linear-gradient(145deg, color-mix(in srgb, var(--block-color), white 12%), var(--block-color));
  background-position: center;
  background-size: cover;
  border: 1px solid rgba(255,255,255,0.28);
  box-shadow:
    inset 1px 1px 2px rgba(255,255,255,0.3),
    inset -2px -3px 4px rgba(0,0,0,0.16),
    0 2px 3px rgba(4, 8, 20, 0.26);
}

.board-cell.occupied::after,
.board-cell.preview-valid::after,
.piece-block::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: calc(var(--cell-radius) - 3px);
  pointer-events: none;
}

.block-1 { --block-color: var(--color-1); --block-texture: var(--texture-1); }
.block-2 { --block-color: var(--color-2); --block-texture: var(--texture-2); }
.block-3 { --block-color: var(--color-3); --block-texture: var(--texture-3); }
.block-4 { --block-color: var(--color-4); --block-texture: var(--texture-4); }
.block-5 { --block-color: var(--color-5); --block-texture: var(--texture-5); }
.block-6 { --block-color: var(--color-6); --block-texture: var(--texture-6); }
.block-7 { --block-color: var(--color-7); --block-texture: var(--texture-7); }

.board-cell.preview-valid {
  z-index: 2;
  opacity: 0.78;
  transform: scale(0.94);
  filter: saturate(0.82) brightness(1.08);
  transition: transform 55ms ease-out, opacity 55ms ease-out;
}

.board-cell.invalid-target {
  box-shadow: inset 0 0 0 2px rgba(255, 99, 120, 0.46);
}

.board-cell.invalid-target:not(.occupied) {
  background: rgba(255, 91, 112, 0.18);
}

.board-cell.will-clear {
  z-index: 3;
  filter: brightness(1.52) saturate(1.1);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45), 0 0 11px rgba(255,224,115,0.38);
}

.board-cell.just-placed {
  animation: place-cell 180ms cubic-bezier(.2, .9, .3, 1.35);
}

@keyframes place-cell {
  from { transform: scale(0.76); filter: brightness(1.6); }
  to { transform: scale(1); }
}

.board-cell.clearing {
  z-index: 2;
  animation: clear-cell 310ms ease-out forwards;
}

@keyframes clear-cell {
  45% { transform: scale(1.13); filter: brightness(2.2); }
  to { transform: scale(0.1); opacity: 0; }
}

.tray-shell {
  width: 100%;
  flex: 1 1 auto;
  min-height: 90px;
  display: flex;
  align-items: center;
}

.piece-tray {
  width: 100%;
  min-height: 100px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
}

.piece-slot {
  height: 100px;
  min-width: 0;
  display: grid;
  place-items: center;
}

.game-piece {
  display: grid;
  gap: 3px;
  cursor: grab;
  touch-action: none;
  transform-origin: center;
  transition: transform 130ms ease, opacity 130ms ease;
}

.game-piece.picked-up {
  opacity: 0.08;
  transform: scale(0.82);
}

.game-piece:hover {
  transform: scale(1.07);
}

.piece-block {
  position: relative;
  width: clamp(27px, 8vw, 38px);
  height: clamp(27px, 8vw, 38px);
  border-radius: 6px;
}

.piece-block.empty {
  visibility: hidden;
}

.game-piece.disabled {
  opacity: 0.2;
  filter: grayscale(1);
  pointer-events: none;
}

.game-piece.dragging {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
  gap: var(--cell-gap);
  opacity: 0.96;
  filter: drop-shadow(0 16px 18px rgba(0,0,0,0.4));
  transition: none;
  will-change: transform;
}

.game-piece.dragging .piece-block {
  border-radius: var(--cell-radius);
}

@media (max-width: 480px) {
  .top-actions { gap: 5px; }
  .round-button { width: 35px; height: 35px; }
  .board-size-select { min-width: 50px; height: 35px; padding-inline: 4px; }
  .language-select { min-width: 44px; }
}

.game-piece.dragging.over-valid {
  opacity: 0.72;
}

.game-piece.dragging.returning {
  transition: transform 150ms ease-in, opacity 150ms ease-in;
}

body.is-dragging-piece {
  cursor: grabbing;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1200;
  max-width: min(90vw, 420px);
  padding: 11px 15px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0,0,0,0.38), inset 0 1px 0 var(--border-bevel);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
}

.image-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(7px);
  cursor: zoom-out;
}

.image-viewer-frame {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(94vw, 1500px);
  height: min(92vh, 1000px);
  height: min(92dvh, 1000px);
  margin: 0;
  pointer-events: none;
}

.image-viewer-frame::before {
  content: '';
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  opacity: 0;
  animation: viewer-spin 700ms linear infinite;
  transition: opacity 120ms ease;
}

.image-viewer-frame.is-loading::before {
  opacity: 1;
}

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

.image-viewer-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  object-fit: contain;
  opacity: 1;
  box-shadow: 0 22px 70px rgba(0,0,0,0.65);
  transition: opacity 140ms ease;
  pointer-events: auto;
  user-select: none;
}

.image-viewer-frame.is-loading .image-viewer-image {
  opacity: 0;
}

.image-viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.32);
  border-radius: 4px;
  color: #fff;
  background: rgba(12,12,12,0.82);
  box-shadow: 0 3px 14px rgba(0,0,0,0.45);
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
  pointer-events: auto;
}

.image-viewer-close:hover,
.image-viewer-close:focus-visible {
  border-color: #fff;
  outline: none;
  background: var(--brand-accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(4px);
}

.settings-card,
.game-over-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  max-height: min(92vh, 760px);
  max-height: min(92dvh, 760px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0,0,0,0.5), inset 0 1px 0 var(--border-bevel);
}

.settings-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.settings-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--brand-accent);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 1.6px;
}

.settings-header h2 {
  font-size: 1.25rem;
}

.close-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  background: var(--button-bg);
  cursor: pointer;
  font-size: 1.3rem;
}

.settings-body {
  padding: 4px 20px 22px;
}

.image-settings-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  transition: opacity 160ms ease, filter 160ms ease;
}

.image-settings-group.is-disabled {
  opacity: 0.32;
  filter: grayscale(1);
}

.image-settings-group.is-disabled * {
  cursor: not-allowed;
}

.mode-toggle {
  margin: 8px 0 5px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--app-bg);
}

.settings-description {
  margin-bottom: 17px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 800;
}

.field-control {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  outline: 0;
  color: var(--text);
  background: var(--app-bg);
}

select.field-control {
  height: 42px;
  padding: 0 11px;
}

textarea.field-control {
  resize: vertical;
  min-height: 76px;
  padding: 10px 11px;
  line-height: 1.4;
}

.field-control:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--text), transparent 82%);
}

.field-help,
.safe-toggle small {
  display: block;
  margin-top: 5px;
  color: var(--dim);
  font-size: 0.68rem;
}

.tag-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 11px 0 15px;
}

.tag-chip {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: 3px;
  color: var(--muted);
  background: var(--button-bg);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
}

.tag-chip:hover,
.tag-chip.active {
  color: var(--text);
  border-color: var(--brand-accent);
  background: var(--panel-elevated);
}

.safe-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
}

.safe-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--app-bg);
  transition: background 160ms ease;
}

.toggle-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 2px;
  background: var(--muted);
  transition: transform 160ms ease;
}

.safe-toggle input:checked + .toggle-ui {
  background: color-mix(in srgb, var(--brand-accent), var(--panel) 45%);
}

.safe-toggle input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.safe-toggle strong {
  font-size: 0.76rem;
}

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

.settings-actions .primary {
  grid-column: 1 / -1;
}

.action-button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text);
  background: var(--button-bg);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.action-button.primary {
  color: #fff;
  border-color: color-mix(in srgb, var(--brand-accent), black 20%);
  border-bottom-color: color-mix(in srgb, var(--brand-accent), black 42%);
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-accent), white 10%), color-mix(in srgb, var(--brand-accent), black 22%));
}

.action-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.background-options {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--app-bg);
}

.background-options summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.compact-toggle {
  padding-bottom: 2px;
}

.background-options input[type="range"] {
  width: 100%;
  accent-color: var(--brand-accent);
}

.texture-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: var(--app-bg);
  font-size: 0.7rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dim);
}

.texture-status.loading .status-dot {
  background: var(--accent);
  animation: pulse 750ms ease-in-out infinite alternate;
}

.texture-status.success .status-dot {
  background: #66a776;
}

.texture-status.error .status-dot {
  background: #c7505d;
}

@keyframes pulse {
  to { transform: scale(1.6); opacity: 0.6; }
}

.game-over-card {
  max-width: 340px;
  padding: 28px 24px 24px;
  overflow: visible;
  text-align: center;
}

.game-over-icon {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 2rem;
}

.game-over-card h2 {
  margin-bottom: 17px;
  font-size: 1.45rem;
}

.game-over-card p {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.game-over-card #final-score {
  display: block;
  margin: 3px 0 22px;
  font-size: 3.2rem;
}

.game-over-card .action-button {
  width: 100%;
}

.floating-score {
  position: fixed;
  z-index: 100;
  color: var(--accent);
  font-size: 1.55rem;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 2px 7px rgba(0,0,0,0.45);
  animation: float-up 800ms ease-out forwards;
}

.blast-celebration {
  position: fixed;
  z-index: 130;
  padding: 9px 15px;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.52);
  border-radius: 4px;
  background: color-mix(in srgb, var(--brand-accent), #151515 24%);
  box-shadow: 0 8px 28px rgba(0,0,0,0.48), inset 0 1px 0 rgba(255,255,255,0.25);
  font-size: clamp(1rem, 5vw, 1.45rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: blast-celebration 900ms cubic-bezier(.2,.85,.25,1) forwards;
}

.blast-celebration.perfect {
  color: #241b06;
  border-color: #fff3b0;
  background: #f0c94d;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.blast-celebration.saved {
  background: #287b61;
}

.game-app.textures-unlocked .board-shell {
  animation: texture-unlock-board 950ms cubic-bezier(.2,.8,.25,1);
}

.game-app.textures-unlocked .piece-tray {
  animation: texture-unlock-tray 850ms 80ms cubic-bezier(.2,.8,.25,1);
}

@keyframes texture-unlock-board {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  34% { transform: scale(1.012); filter: brightness(1.28) saturate(1.2); }
}

@keyframes texture-unlock-tray {
  0%, 100% { transform: translateY(0); filter: brightness(1); }
  38% { transform: translateY(-5px); filter: brightness(1.32) saturate(1.2); }
}

@keyframes blast-celebration {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55) rotate(-2deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(1deg); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.92); }
}

@keyframes float-up {
  from { opacity: 0; transform: translate(-50%, 8px) scale(0.75); }
  25% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -55px) scale(1.06); }
}

@media (max-height: 640px) {
  .game-app {
    padding-top: 6px;
  }

  .top-bar {
    min-height: 38px;
  }

  .round-button {
    width: 34px;
    height: 34px;
  }

  .score-area {
    min-height: 52px;
  }

  #score {
    font-size: 2.8rem;
  }

  .piece-tray,
  .piece-slot {
    min-height: 78px;
    height: 78px;
  }
}

@media (max-width: 360px) {
  .game-app {
    padding-inline: 8px;
  }

  .top-actions {
    gap: 4px;
  }
}

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