/* Player-owned town decorations sit above scenery and below interactive buildings. */
.decoration-map-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout style;
}

.map-decoration {
  position: absolute;
  display: block;
  width: clamp(42px, var(--decoration-size, 12%), 104px);
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
}

.map-decoration img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(2px 4px 2px #263b3438);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.decoration-placement-surface {
  position: absolute;
  z-index: 7;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: #eff7f21c;
  box-shadow: 0 0 0 4px #fff8 inset, 0 0 0 7px var(--ui-primary) inset;
  cursor: crosshair;
  touch-action: manipulation;
}

.decoration-placement-surface:focus-visible {
  outline: 4px solid var(--ui-coral);
  outline-offset: -8px;
  box-shadow: 0 0 0 4px #fff inset, 0 0 0 8px var(--ui-coral) inset;
}

.decoration-placement-cursor {
  position: absolute;
  left: 50%;
  top: 62%;
  display: block;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ui-primary) 74%, transparent);
  box-shadow: 0 0 0 3px var(--ui-primary-dark), 0 3px 9px #263b3466;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.decoration-placement-cursor::before,
.decoration-placement-cursor::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
  content: "";
  transform: translate(-50%, -50%);
}

.decoration-placement-cursor::after { transform: translate(-50%, -50%) rotate(90deg); }

.decoration-placement-bar {
  position: absolute;
  z-index: 18;
  right: 10px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px);
  left: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 7px 8px 8px 12px;
  border: 1px solid var(--ui-primary-dark);
  border-radius: 14px;
  color: var(--ink);
  background: #fffdf8f2;
  box-shadow: 0 4px 0 var(--ui-primary-dark), 0 10px 24px #263b3447;
  backdrop-filter: blur(5px);
}

.decoration-placement-copy {
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.decoration-cancel,
.decoration-action {
  min-width: 64px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--ui-primary-dark);
  border-radius: 10px;
  color: #fff;
  background: var(--ui-primary);
  box-shadow: 0 2px 0 var(--ui-primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.decoration-cancel {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--ui-primary-soft);
  box-shadow: 0 2px 0 #a4b5aa;
}

.decoration-action:disabled {
  color: #69736e;
  border-color: #c2cac5;
  background: #e4e8e5;
  box-shadow: none;
  opacity: .82;
}

.decoration-action:active:not(:disabled),
.decoration-cancel:active { transform: translateY(2px); box-shadow: none; }

/* Collection dialog */
.decoration-dialog {
  width: min(94%, 520px);
  height: min(680px, calc(100dvh - max(12px, var(--safe-top)) - max(12px, var(--safe-bottom))));
}
.decoration-dialog .close-button { width: 44px; height: 44px; }


.decoration-zone-copy {
  flex: 0 0 auto;
  margin: 0 0 8px !important;
  padding: 7px 9px;
  border: 1px solid #c9d7ce;
  border-radius: 9px;
  color: var(--ink-soft) !important;
  background: var(--ui-primary-soft);
  font-size: 12px !important;
  line-height: 1.35 !important;
}

.decoration-zone-copy.is-locked {
  border-color: #d2c5ad;
  color: #745f3d !important;
  background: #f4ecdd;
}

.decoration-dialog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1px 3px 8px 1px;
  scrollbar-width: thin;
  touch-action: pan-y;
}

.decoration-section + .decoration-section {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.decoration-section-heading {
  display: flex;
  min-height: 28px;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.decoration-section-heading h3 {
  margin: 0;
  font: 800 15px/1.2 var(--font-display);
}

.decoration-section-heading small {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  text-align: right;
}

.decoration-collection,
.decoration-placed-list,
.decoration-board-list {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.decoration-collection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.decoration-board-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.decoration-card,
.decoration-placed,
.decoration-board-card {
  display: grid;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--paper);
  box-shadow: 0 2px 0 #b6c1ba;
}

.decoration-card { grid-template-columns: 58px minmax(0, 1fr); }
.decoration-card > .decoration-action { grid-column: 1 / -1; width: 100%; }
.decoration-placed { grid-template-columns: 46px minmax(0, 1fr) auto; }
.decoration-board-card { grid-template-columns: 50px minmax(0, 1fr); }
.decoration-board-card > .decoration-action { grid-column: 1 / -1; width: 100%; }

.decoration-art {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--ui-cream);
}

.decoration-art-small { width: 46px; height: 46px; }
.decoration-art img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }

.decoration-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.decoration-card-copy b,
.decoration-board-card > b {
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decoration-card-copy small {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.decoration-placed-actions { display: grid; gap: 5px; }
.decoration-placed-actions .decoration-action { min-width: 58px; min-height: 44px; padding-inline: 7px; }
.decoration-recall:not(:disabled) { color: #793e34; border-color: #bf806f; background: #f6ded7; box-shadow: 0 2px 0 #c79586; }

.decoration-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--ink-soft);
  background: var(--ui-cream);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  text-align: center;
}

.decoration-feedback {
  flex: 0 0 auto;
  min-height: 20px;
  margin: 8px 0 0 !important;
  color: var(--ui-primary-dark) !important;
  font-size: 12px !important;
  font-weight: 750 !important;
  line-height: 1.35 !important;
}

.decoration-feedback:empty { min-height: 0; margin-top: 0 !important; }
.decoration-feedback.is-error { color: var(--danger) !important; }

.decoration-swatch {
  display: block;
  width: 46px;
  height: 46px;
  border: 1px solid #9ca9a1;
  border-radius: 10px;
  box-shadow: 0 1px #fff9 inset, 0 2px 4px #263b3424;
}

.swatch-default { background: repeating-conic-gradient(#f3efe7 0 25%, #ebe5db 0 50%) 0 / 18px 18px; }
.swatch-board-grass { background: radial-gradient(circle at 28% 30%, #f2ebca 0 6%, transparent 7%), repeating-linear-gradient(135deg, #dce8d2 0 8px, #cbdcc1 8px 16px); }
.swatch-board-sand { background: radial-gradient(circle, #bda477 0 1px, transparent 1.5px) 0 0 / 8px 8px, linear-gradient(145deg, #f3dfb8, #dbc192); }
.swatch-board-night { border-color: #50666a; background: radial-gradient(circle at 30% 26%, #f6e6a7 0 3%, transparent 4%), radial-gradient(circle at 68% 64%, #fff 0 1.5%, transparent 2.5%), linear-gradient(145deg, #344e56, #698081); }

/* Skins only repaint surfaces: grid tracks, dimensions, children and input stay untouched. */
#board.decor-board-grass {
  background: repeating-linear-gradient(135deg, #7f9c79 0 8px, #769171 8px 16px);
  box-shadow: 0 2px 5px #354e354f inset;
}

#board.decor-board-grass > .cell:not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) {
  border-color: #bfd0b5;
  background: #edf2df;
  box-shadow: 0 1px #fff inset, 0 -1px #c8d7be inset;
}

#board.decor-board-grass > .cell:nth-child(12n + 2):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-grass > .cell:nth-child(12n + 4):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-grass > .cell:nth-child(12n + 6):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-grass > .cell:nth-child(12n + 7):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-grass > .cell:nth-child(12n + 9):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-grass > .cell:nth-child(12n + 11):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) { background: #e2ecd5; }

#board.decor-board-sand {
  background: radial-gradient(circle, #9b805d 0 1px, transparent 1.4px) 0 0 / 9px 9px, #b9a078;
  box-shadow: 0 2px 5px #5d49324f inset;
}

#board.decor-board-sand > .cell:not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) {
  border-color: #dfcaa5;
  background: #f8e9cc;
  box-shadow: 0 1px #fff8ed inset, 0 -1px #dcc59d inset;
}

#board.decor-board-sand > .cell:nth-child(12n + 2):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-sand > .cell:nth-child(12n + 4):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-sand > .cell:nth-child(12n + 6):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-sand > .cell:nth-child(12n + 7):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-sand > .cell:nth-child(12n + 9):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-sand > .cell:nth-child(12n + 11):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) { background: #f1ddba; }

#board.decor-board-night {
  background: radial-gradient(circle at 20% 25%, #f0dda0 0 1px, transparent 1.8px) 0 0 / 27px 27px, linear-gradient(145deg, #3e5960, #567175);
  box-shadow: 0 2px 6px #182b315e inset;
}

#board.decor-board-night > .cell:not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) {
  border-color: #91a6a4;
  background: #e4ece8;
  box-shadow: 0 1px #fff inset, 0 -1px #bccbc7 inset;
}

#board.decor-board-night > .cell:nth-child(12n + 2):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-night > .cell:nth-child(12n + 4):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-night > .cell:nth-child(12n + 6):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-night > .cell:nth-child(12n + 7):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-night > .cell:nth-child(12n + 9):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle),
#board.decor-board-night > .cell:nth-child(12n + 11):not(.selected):not(.sel):not(.drop-target):not(.rare):not(.obstacle) { background: #d6e2de; }

@media (max-width: 370px) {
  .decoration-dialog { width: min(96%, 430px); }
  .decoration-collection,
  .decoration-board-list { grid-template-columns: 1fr; }
  .decoration-card { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .decoration-card > .decoration-action { grid-column: auto; width: auto; min-width: 58px; }
  .decoration-art { width: 52px; height: 52px; }
  .decoration-section-heading small { max-width: 48%; }
}

@media (max-height: 600px) {
  .decoration-dialog {
    width: min(96%, 560px);
    height: calc(100dvh - max(8px, var(--safe-top)) - max(8px, var(--safe-bottom)));
  }
  .decoration-zone-copy { margin-bottom: 4px !important; padding-block: 4px; }
  .decoration-section + .decoration-section { margin-top: 7px; padding-top: 7px; }
  .decoration-section-heading { min-height: 22px; margin-bottom: 4px; }
  .decoration-card,
  .decoration-placed,
  .decoration-board-card { gap: 5px; padding: 4px; }
  .decoration-art { width: 44px; height: 44px; }
  .decoration-art-small { width: 40px; height: 40px; }
  .decoration-action { padding-block: 4px; }
  .decoration-placement-bar { min-height: 50px; padding-block: 4px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .decoration-dialog { width: min(96%, 680px); }
  .decoration-dialog-scroll {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 8px;
  }
  .decoration-section + .decoration-section { margin-top: 0; padding-top: 0; padding-left: 8px; border-top: 0; border-left: 1px solid var(--line); }
  .decoration-collection,
  .decoration-board-list { grid-template-columns: 1fr; }
  .decoration-section-heading { display: block; }
  .decoration-section-heading small { display: block; margin-top: 1px; text-align: left; }
  .decoration-placement-bar { right: calc(44% + 12px); bottom: calc(var(--nav-h) + var(--safe-bottom) + 6px); left: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-decoration img { transition: none; }
}
