.gnome-board {
  touch-action: none;
  user-select: none;
  width: min(calc(100% - 24px), 500px, calc(66svh - 24px));
  height: auto !important;
  aspect-ratio: 1;
  max-width: 520px;
  margin: auto;
  inset: 0 !important;
  gap: 10px !important;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  background: linear-gradient(135deg, #1a3c3be6, #09292bee);
  padding: 14px !important;
  border: 1px solid #d9bd7029;
  border-radius: 12px;
  box-shadow: 0 15px 70px #0005;
}
@media (max-width: 600px), (max-width: 1000px) and (max-height: 600px) {
  #arcade[data-game="ski"] {
    height: 100svh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 10px max(6px, env(safe-area-inset-bottom));
  }
  #arcade[data-game="ski"] .game-header {
    height: 54px;
    flex-shrink: 0;
  }
  #arcade[data-game="ski"] .game-instructions {
    margin: 8px 0 0;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
    flex-shrink: 0;
  }
  #arcade[data-game="ski"] .hud {
    padding: 8px 4px;
    flex-shrink: 0;
  }
  #arcade[data-game="ski"] #playfield {
    flex: 1;
    height: auto;
    min-height: 120px;
  }
  #arcade[data-game="ski"] .game-controls {
    flex-shrink: 0;
    margin: 8px 0 0;
    min-height: 52px;
  }
  #arcade[data-game="ski"] .save-note {
    display: none;
  }
}
.gnome-piece {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.gnome-piece > * {
  pointer-events: none;
}
.gnome-tile.queued {
  outline: 3px solid #a4e8c6;
  outline-offset: -3px;
  box-shadow: inset 0 0 25px #a4e8c655;
}
.gnome-tile {
  font: inherit;
  color: var(--cream);
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.gnome-tile.selected {
  outline: 3px solid #ffda85;
  outline-offset: -3px;
  box-shadow:
    inset 0 0 25px #ffdb7940,
    0 0 12px #ffdb7960;
}
.gnome-tile.drag-source {
  outline: 3px solid #ffda85;
  outline-offset: -3px;
}
.gnome-tile.drag-target {
  outline: 3px solid #a4e8c6;
  outline-offset: -3px;
  box-shadow: inset 0 0 30px #a4e8c655;
}
.gnome-board.dragging-pair,
.gnome-board.dragging-pair .gnome-tile {
  cursor: grabbing;
}
.gnome-tile:disabled {
  cursor: default;
}
.gnome-tile:focus-visible {
  outline: 3px solid #ffda85;
  outline-offset: -3px;
}
#arcade[data-game="gnomes"] {
  max-width: none;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px max(4px, env(safe-area-inset-bottom));
  overflow: hidden;
}
#arcade[data-game="gnomes"] .game-header {
  height: 64px;
  flex-shrink: 0;
}
#arcade[data-game="gnomes"] .hud {
  padding: 8px;
  flex-shrink: 0;
}
#arcade[data-game="gnomes"] #playfield {
  flex: 1;
  height: auto !important;
  min-height: 0 !important;
  border-radius: 10px;
}
#arcade[data-game="gnomes"] .gnome-board {
  width: 100%;
  height: 100% !important;
  max-width: none;
  aspect-ratio: auto;
  margin: 0;
  padding: 10px !important;
  gap: 10px !important;
  overflow: hidden;
}
#arcade[data-game="gnomes"] .gnome-tile {
  overflow: visible;
  min-width: 0;
}
#arcade[data-game="gnomes"] .gnome-tile canvas {
  height: calc(100% - 22px);
  max-width: 100%;
  object-fit: contain;
  transform: none;
}
#arcade[data-game="gnomes"] .gnome-tile span {
  font-size: 12px;
  bottom: 5px;
}
#arcade[data-game="gnomes"] .gnome-tile b {
  font-size: 12px;
}
#arcade[data-game="gnomes"] .game-controls {
  flex-shrink: 0;
  margin: 6px 0 0;
  min-height: 0;
  padding: 4px 0;
}
#arcade[data-game="gnomes"] .game-controls span {
  max-width: 650px;
  font-size: 14px;
}
#arcade[data-game="gnomes"] .save-note {
  display: none;
}
@media (max-width: 600px) {
  #arcade[data-game="gnomes"] {
    padding-left: 6px;
    padding-right: 6px;
  }
  #arcade[data-game="gnomes"] .gnome-board {
    padding: 6px !important;
    gap: 6px !important;
  }
  #arcade[data-game="gnomes"] .game-header h2 {
    font-size: 16px;
  }
  #arcade[data-game="gnomes"] .gnome-tile span {
    font-size: 10px;
  }
  #arcade[data-game="gnomes"] .game-controls span {
    font-size: 12px;
  }
}
.gnome-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  border-radius: 9px;
  background: #ffffff09;
  box-shadow: inset 0 1px 9px #0003;
  border: 1px solid #ffffff08;
}
.gnome-tile canvas {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px #0005);
  transform: translateY(-4%);
}
.gnome-tile span {
  position: absolute;
  bottom: 5px;
  font-size: 9px;
  left: 2px;
  right: 2px;
  text-align: center;
  color: #f6ebca;
  text-shadow: 0 1px 3px #000;
}
.gnome-tile b {
  position: absolute;
  right: 6px;
  top: 4px;
  font-size: 10px;
  color: #ead7ac;
}
.level-1 {
  background: radial-gradient(ellipse at center, #754f3f99, #382b2e88);
}
.level-2 {
  background: radial-gradient(ellipse at center, #32757499, #1a3c4388);
}
.level-3 {
  background: radial-gradient(ellipse at center, #76589199, #382b4488);
}
.level-4 {
  background: radial-gradient(ellipse at center, #ae833d99, #51432a88);
}
.level-5,
.level-6,
.level-7,
.level-8 {
  background: radial-gradient(ellipse at center, #d2b069aa, #71622466);
  box-shadow: 0 0 20px #ecc57044;
  border-color: #ecc57088;
}
.merge-pop {
  animation: merge 0.24s ease-out;
}
@keyframes merge {
  50% {
    transform: scale(1.12);
    filter: brightness(1.4);
  }
}
.game-controls #action {
  width: auto;
  min-width: 100px;
  font-size: 14px;
  background: #c49b5e;
  color: #142d2f;
  font-weight: 700;
  border-color: #d5af73;
}
.game-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}
.game-card h3 {
  min-height: 56px;
}
.card-ski .card-art {
  background:
    linear-gradient(0deg, #13374422, #ffffff00),
    url("../assets/alpine.webp") center 55% / cover;
}
.card-ski .card-art canvas {
  opacity: 0;
}
.has-village .card-delivery .card-art,
.has-village .card-snowball .card-art {
  background-image:
    linear-gradient(0deg, #0a1f2c33, #0a1f2c00), url("../assets/village.webp");
  background-size: cover;
  background-position: 70% 55%;
}
.has-village .card-delivery .card-art canvas {
  opacity: 0.75;
}
.has-village .card-snowball .card-art canvas {
  opacity: 0.55;
}
.card-gnomes .card-art {
  background: radial-gradient(ellipse at 50% 100%, #65827b, #233d43);
}
.has-gnomes .card-gnomes .card-art:after {
  content: "";
  position: absolute;
  inset: 20px 15px 0;
  background: url("../assets/gnomes.webp") left top/200% 200% no-repeat;
  filter: drop-shadow(0 5px 15px #0006);
}
.has-gnomes .card-gnomes .card-art canvas {
  opacity: 0;
}
.tag {
  z-index: 1;
}
.card-copy p {
  min-height: 46px;
}
.hero {
  border-bottom: 1px solid #bdd9cf22;
}
.has-village .hero-copy {
  background: none;
}
.game-header .quiet {
  white-space: nowrap;
}
.game-header h2 {
  text-align: center;
}
#toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #09232be8;
  border: 1px solid #f0d28c33;
  color: #f1d495;
  border-radius: 7px;
  padding: 10px 18px;
  pointer-events: none;
  font-size: 14px;
  z-index: 2;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}
#toast.show {
  opacity: 1;
}
.hud #time {
  font-size: 22px;
}
.gnome-legend {
  font-size: 12px;
  color: #c5d6c9;
}
#playfield:has(.gnome-board:not([hidden])) {
  background:
    linear-gradient(#09212b55, #09212b55),
    url("../assets/village.webp") center/cover;
}
#arcade:has(.gnome-board:not([hidden])) #playfield {
  height: min(66svh, 540px);
  min-height: 320px;
}
@media (max-width: 600px) {
  .game-card h3 {
    min-height: 52px;
    font-size: 20px;
  }
  .card-copy p {
    min-height: 60px;
  }
  .hero {
    height: 670px;
  }
  .hero-copy {
    padding-top: 42px;
  }
  .game-header h2 {
    font-size: 19px;
  }
  .game-header .quiet {
    font-size: 12px;
    padding: 8px;
  }
  .game-header #back span {
    display: none;
  }
  .hud #time {
    font-size: 16px;
  }
  .hud #score-label {
    font-size: 8px;
    letter-spacing: 1px;
  }
  .gnome-board {
    max-width: 390px;
    padding: 9px !important;
    gap: 7px !important;
  }
  .gnome-tile span {
    font-size: 8px;
  }
  .gnome-tile canvas {
    height: 90%;
    transform: translateY(-7%);
  }
  .game-controls {
    gap: 12px;
  }
  .game-controls span {
    font-size: 11px;
  }
  .card-gnomes .card-art:after {
    inset: 15px 8px 0;
  }
  .tag {
    font-size: 7px;
    letter-spacing: 1.2px;
  }
  .hero-copy .intro {
    max-width: 300px;
  }
  .scene-note {
    color: #e7e6c6;
  }
  .hud p {
    max-width: 170px;
  }
  .hud {
    gap: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .merge-pop {
    animation: none;
  }
}
.card-copy p {
  font-size: 14px;
  min-height: 70px;
}
.game-instructions {
  margin: 16px 0 0;
  padding: 14px 18px;
  border: 1px solid #e9bd7244;
  border-radius: 8px;
  background: #173638;
  color: #f1e9cd;
  line-height: 1.6;
  font-size: 16px;
  text-align: center;
}
#arcade[data-game="delivery"] #playfield {
  min-height: 420px;
}
.game-header #game-sound {
  font-size: 14px;
  color: #e9bd72;
}
@media (max-width: 600px) {
  .game-instructions {
    font-size: 14px;
    padding: 10px 12px;
  }
  .game-header #game-sound {
    font-size: 12px;
    padding: 8px 3px;
  }
  .game-header h2 {
    font-size: 17px;
  }
  .game-header {
    gap: 6px;
  }
}
.card-bottom {
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
}
.card-bottom .best {
  font-size: 12px;
}
.game-controls span,
.hud p {
  font-size: 14px;
}
.has-gnomes .card-gnomes .card-art:after {
  width: min(85%, 185px);
  height: auto;
  aspect-ratio: 1;
  inset: auto auto -8px 50%;
  transform: translateX(-50%);
  background-size: 200% 200%;
}
.card-delivery .card-art:after,
.card-snowball .card-art:after {
  content: "";
  position: absolute;
  width: min(90%, 185px);
  height: auto;
  aspect-ratio: 1;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  background-image: url("../assets/game-sprites.webp");
  background-size: 200% 200%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 7px 10px #0005);
}
.card-delivery .card-art:after {
  background-position: left top;
}
.card-snowball .card-art:after {
  background-position: right top;
}
.has-village .card-delivery .card-art canvas,
.has-village .card-snowball .card-art canvas {
  opacity: 0;
}
@media (max-width: 600px) {
  .card-copy p {
    font-size: 14px;
    min-height: 93px;
  }
  .card-bottom {
    font-size: 14px;
  }
  .game-controls span,
  .hud p {
    font-size: 12px;
  }
  .game-card h3 {
    min-height: 75px;
  }
  .card-delivery .card-art:after,
  .card-snowball .card-art:after {
    width: 145px;
  }
  .has-gnomes .card-gnomes .card-art:after {
    width: 145px;
  }
}
