.site-nav a[aria-current="page"] {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: #221704;
}

.toolkit-page {
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(223, 243, 232, 0.58) 52%, rgba(255, 247, 223, 0.78)),
    linear-gradient(90deg, rgba(35, 32, 24, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(35, 32, 24, 0.055) 1px, transparent 1px);
  background-size: auto, 42px 42px, 42px 42px;
  min-height: 100svh;
  padding: calc(var(--header-height) + 28px) clamp(16px, 3vw, 42px) 48px;
}

.toolkit-hero,
.toolkit-workbench {
  margin: 0 auto;
  max-width: 1320px;
}

.toolkit-hero {
  align-items: end;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 420px);
  padding: 18px 0 30px;
}

.toolkit-hero h1 {
  font-size: clamp(3.8rem, 10vw, 8rem);
  line-height: 1;
  padding-bottom: 0.06em;
}

.toolkit-deck {
  color: rgba(35, 32, 24, 0.76);
  font-size: clamp(1rem, 1.6vw, 1.22rem);
  max-width: 640px;
}

.toolkit-hero img {
  justify-self: end;
  max-width: min(420px, 100%);
}

.toolkit-workbench {
  background:
    linear-gradient(135deg, rgba(35, 32, 24, 0.97), rgba(31, 121, 128, 0.92) 56%, rgba(143, 36, 48, 0.9)),
    linear-gradient(90deg, rgba(255, 253, 247, 0.075) 1px, transparent 1px),
    linear-gradient(rgba(255, 253, 247, 0.075) 1px, transparent 1px);
  background-size: auto, 30px 30px, 30px 30px;
  border: 2px solid rgba(243, 182, 31, 0.72);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 253, 247, 0.14), 0 28px 72px rgba(35, 32, 24, 0.22);
  color: #fffdf7;
  overflow: hidden;
}

.tool-tabs {
  background: rgba(35, 32, 24, 0.46);
  border-bottom: 1px solid rgba(255, 253, 247, 0.16);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: hidden;
  padding: 12px;
}

.tool-tab {
  background: rgba(255, 253, 247, 0.09);
  border: 2px solid rgba(255, 253, 247, 0.14);
  border-radius: 999px;
  color: rgba(255, 253, 247, 0.82);
  cursor: pointer;
  align-items: center;
  display: inline-flex;
  flex: 1 1 145px;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 900;
  justify-content: center;
  line-height: 1.22;
  min-height: 42px;
  padding: 9px 14px;
  text-align: center;
}

.tool-tab:hover,
.tool-tab:focus-visible,
.tool-tab.is-active {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: #211602;
  outline: none;
}

.tool-panel {
  padding: clamp(18px, 3vw, 34px);
}

.tool-panel[hidden] {
  display: none;
}

.panel-copy {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel-copy h2 {
  color: #fffdf7;
  font-size: clamp(1.8rem, 4vw, 3.35rem);
  line-height: 1.12;
  max-width: 820px;
  padding-bottom: 0.05em;
}

.tool-control-card {
  background: rgba(255, 253, 247, 0.94);
  border: 2px solid rgba(35, 32, 24, 0.12);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(35, 32, 24, 0.16);
  color: var(--ink);
  padding: clamp(14px, 2vw, 20px);
}

.tool-form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-control-sections {
  display: grid;
  gap: 14px;
}

.map-control-section {
  border-left: 4px solid rgba(31, 121, 128, 0.42);
  display: grid;
  gap: 10px;
  padding-left: 12px;
}

.map-control-section h3 {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
  text-transform: uppercase;
}

.tile-control-section {
  border-left-color: rgba(243, 182, 31, 0.85);
}

.tool-control-card label {
  color: rgba(35, 32, 24, 0.68);
  display: grid;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 900;
  gap: 6px;
  line-height: 1.28;
  text-transform: uppercase;
}

.tool-control-card input,
.tool-control-card select,
.tool-control-card textarea {
  background: #fff;
  border: 2px solid rgba(35, 32, 24, 0.14);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.32;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

.tool-control-card input[type="range"] {
  accent-color: var(--teal);
  padding-left: 0;
  padding-right: 0;
}

.tool-control-card input:focus,
.tool-control-card select:focus,
.tool-control-card textarea:focus {
  border-color: var(--teal);
  outline: none;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.mini-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.dice-crafter-grid,
.card-workbench-grid,
.generator-grid {
  align-items: start;
  display: grid;
  gap: clamp(18px, 3vw, 30px);
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1fr);
}

.side-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.side-fields label {
  font-size: 0.7rem;
}

.dice-list,
.dice-result {
  display: grid;
  gap: 10px;
}

.dice-result {
  margin-top: 14px;
}

.die-row,
.die-result-row {
  align-items: center;
  background: rgba(255, 253, 247, 0.94);
  border: 2px solid rgba(35, 32, 24, 0.12);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 10px;
}

.die-copy {
  min-width: 0;
}

.die-name-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.die-row strong,
.die-result-row strong {
  color: #241a0a;
  display: block;
  line-height: 1.24;
  min-width: 0;
  overflow-wrap: anywhere;
}

.die-row small,
.die-result-row span {
  color: rgba(35, 32, 24, 0.62);
  align-items: center;
  display: flex;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 900;
  gap: 6px;
  line-height: 1.28;
  margin-top: 3px;
}

.die-roll-badge {
  background: var(--gold);
  border: 2px solid rgba(35, 32, 24, 0.1);
  border-radius: 999px;
  color: #211602;
  display: inline-flex;
  flex: 0 1 auto;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.1;
  max-width: min(230px, 100%);
  overflow-wrap: anywhere;
  padding: 6px 9px;
}

.die-color-swatch {
  background: var(--swatch-color);
  border: 2px solid rgba(35, 32, 24, 0.18);
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px rgba(255, 253, 247, 0.34);
  display: inline-block;
  height: 17px;
  width: 17px;
}

.die-icon {
  --die-color: #3c3f3f;
  align-items: center;
  aspect-ratio: 1;
  display: inline-flex;
  flex: 0 0 82px;
  height: 82px;
  justify-content: center;
  max-width: 82px;
  padding: 0;
  position: relative;
  text-align: center;
}

.die-canvas {
  display: block;
  height: 82px;
  width: 82px;
}

.die-icon.is-rolling {
  filter: drop-shadow(0 0 12px rgba(243, 182, 31, 0.42));
}

.card-workbench-grid {
  grid-template-columns: minmax(260px, 0.46fr) minmax(320px, 1fr);
}

.card-stage {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(255, 253, 247, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 253, 247, 0.08) 1px, transparent 1px),
    rgba(255, 253, 247, 0.1);
  background-size: 22px 22px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 650px;
  padding: clamp(16px, 3vw, 32px);
}

.draggable-card {
  --card-border: #ffffff;
  --card-border-width: 0px;
  --card-color: #ffffff;
  aspect-ratio: 2.5 / 3.5;
  background: var(--card-color);
  border: var(--card-border-width) solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 28px 62px rgba(0, 0, 0, 0.32);
  color: var(--ink);
  max-height: 620px;
  max-width: min(440px, 100%);
  overflow: hidden;
  position: relative;
  touch-action: none;
  width: 100%;
}

.card-field {
  --field-color: var(--ink);
  align-items: center;
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 8px;
  color: var(--field-color);
  cursor: grab;
  display: flex;
  font-size: var(--field-font);
  height: var(--field-h);
  left: var(--field-x);
  line-height: 1.28;
  min-height: 0;
  min-width: 0;
  padding: 0;
  position: absolute;
  top: var(--field-y);
  transform: translate(-50%, -50%);
  user-select: text;
  vertical-align: top;
  width: var(--field-w);
}

.card-field-content {
  align-items: center;
  display: flex;
  height: 100%;
  min-height: 100%;
  overflow-wrap: anywhere;
  width: 100%;
}

.card-field svg {
  color: rgba(35, 32, 24, 0.72);
  display: block;
  height: 100%;
  width: 100%;
}

.card-field:hover,
.card-field.is-selected {
  border-color: rgba(31, 121, 128, 0.64);
  box-shadow: 0 0 0 3px rgba(31, 121, 128, 0.12);
}

.card-field:active {
  cursor: grabbing;
}

.card-field[contenteditable]:focus {
  outline: none;
}

.card-field-title {
  font-family: var(--font-display);
  font-size: var(--field-font);
  font-weight: 700;
  line-height: 1.12;
  padding: 2px 6px;
}

.card-field-label,
.card-field-badge {
  font-family: var(--font-ui);
  font-size: var(--field-font);
  font-weight: 900;
  line-height: 1.28;
  text-transform: uppercase;
}

.card-field-label {
  padding: 2px 6px;
}

.card-field-badge {
  background: var(--field-color);
  border-radius: 999px;
  color: #fffdf7;
  justify-content: center;
  padding: 2px 10px;
  text-align: center;
}

.card-field-number {
  align-items: center;
  aspect-ratio: 1;
  background: var(--field-color);
  border-radius: 50%;
  color: #211602;
  display: inline-flex;
  font-family: var(--font-ui);
  font-size: var(--field-font);
  font-weight: 900;
  justify-content: center;
  line-height: 1.18;
  padding: 3px;
  height: var(--field-h);
  width: var(--field-w);
}

.card-field-text {
  padding: 4px 6px;
}

.card-field-text .card-field-content,
.card-field-box .card-field-content {
  align-items: flex-start;
}

.card-field-label .card-field-content,
.card-field-badge .card-field-content,
.card-field-number .card-field-content {
  justify-content: center;
  text-align: center;
}

.card-field-box {
  background: rgba(255, 253, 247, 0.72);
  border: 2px solid rgba(35, 32, 24, 0.18);
  font-size: var(--field-font);
  height: var(--field-h);
  overflow: hidden;
  padding: 10px 12px;
}

.card-field-art {
  background: rgba(35, 32, 24, 0.04);
  border: 2px solid rgba(35, 32, 24, 0.14);
  border-radius: 12px;
  height: var(--field-h);
  padding: 10px;
}

.card-field-art .card-field-content {
  height: 100%;
}

.card-field[class*="card-field-shape-"] {
  background: transparent;
  border-radius: 0;
  color: var(--field-color);
  padding: 0;
}

.card-field[class*="card-field-shape-"] .card-field-content {
  display: block;
}

.card-shape-svg {
  display: block;
  height: 100%;
  overflow: visible;
  width: 100%;
}

.card-shape-svg rect,
.card-shape-svg circle,
.card-shape-svg polygon {
  fill: var(--field-color);
  stroke: rgba(35, 32, 24, 0.2);
  stroke-width: 2;
}

.card-shape-svg line {
  fill: none;
  stroke: var(--field-color);
  stroke-linecap: round;
  stroke-width: 18;
}

.card-resize-handle,
.tile-resize-handle {
  background: var(--gold);
  border: 2px solid #fffdf7;
  border-radius: 5px;
  bottom: 3px;
  box-shadow: 0 6px 14px rgba(35, 32, 24, 0.28);
  cursor: nwse-resize;
  height: 18px;
  position: absolute;
  right: 3px;
  width: 18px;
  z-index: 2;
}

.card-delete-handle,
.map-delete-handle,
.tile-delete-handle {
  align-items: center;
  background: #8f2430;
  border: 2px solid #fffdf7;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(35, 32, 24, 0.28);
  color: #fffdf7;
  cursor: pointer;
  display: inline-flex;
  height: 22px;
  justify-content: center;
  padding: 0;
  position: absolute;
  width: 22px;
  z-index: 6;
}

.card-delete-handle {
  right: 3px;
  top: 3px;
}

.card-delete-handle svg,
.map-delete-handle svg,
.tile-delete-handle svg {
  display: block;
  fill: none;
  height: 15px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 15px;
}

.card-resize-handle::before,
.tile-resize-handle::before {
  border-bottom: 2px solid rgba(35, 32, 24, 0.58);
  border-right: 2px solid rgba(35, 32, 24, 0.58);
  bottom: 4px;
  content: "";
  height: 6px;
  position: absolute;
  right: 4px;
  width: 6px;
}

.card-bench-layout {
  align-items: start;
  grid-template-columns: minmax(280px, 0.42fr) minmax(360px, 1fr);
}

.card-bench-controls {
  align-content: start;
  gap: 14px;
  position: relative;
}

.card-bench-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-control-group {
  align-content: start;
  display: grid;
  gap: 9px;
  min-width: 0;
}

.card-text-control,
.card-color-control {
  grid-column: 1 / -1;
}

.card-control-group .mini-action {
  min-height: 38px;
}

.shape-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.shape-action {
  align-items: center;
  background: #fffdf7;
  border: 2px solid rgba(35, 32, 24, 0.18);
  border-radius: 8px;
  box-shadow: 0 8px 0 rgba(35, 32, 24, 0.12);
  cursor: pointer;
  display: inline-flex;
  height: 48px;
  justify-content: center;
  padding: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.shape-action:hover {
  border-color: rgba(31, 121, 128, 0.62);
  box-shadow: 0 5px 0 rgba(35, 32, 24, 0.16);
  transform: translateY(3px);
}

.shape-icon {
  background: #232018;
  display: block;
  height: 24px;
  width: 34px;
}

.shape-icon-rectangle {
  border-radius: 4px;
}

.shape-icon-circle {
  border-radius: 999px;
  height: 28px;
  width: 28px;
}

.shape-icon-triangle {
  background: #232018;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  height: 30px;
  width: 34px;
}

.card-export-actions .mini-action {
  min-height: 40px;
  padding-inline: 10px;
}

.card-export-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-save-popover {
  background: #fffdf7;
  border: 2px solid rgba(35, 32, 24, 0.18);
  border-radius: 8px;
  box-shadow: 0 20px 44px rgba(35, 32, 24, 0.22);
  display: grid;
  gap: 10px;
  padding: 12px;
}

.card-save-popover[hidden] {
  display: none;
}

.card-save-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-bench-layout .card-stage {
  align-items: flex-start;
  height: clamp(790px, 86vh, 920px);
  min-height: 0;
  overflow: hidden;
  padding: clamp(16px, 2vw, 30px);
}

.card-stack-shell {
  align-items: flex-start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(46px, auto) minmax(0, 1fr);
  height: 100%;
  justify-items: center;
  min-height: 0;
  width: min(520px, 100%);
}

.card-number-list {
  align-content: center;
  align-self: start;
  background: rgba(255, 253, 247, 0.9);
  border: 2px solid rgba(35, 32, 24, 0.12);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(35, 32, 24, 0.12);
  display: grid;
  gap: 8px;
  justify-items: center;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 6px;
  position: static;
  scrollbar-width: thin;
  z-index: 12;
}

.card-number-button {
  align-items: center;
  background: rgba(255, 253, 247, 0.9);
  border: 2px solid rgba(35, 32, 24, 0.18);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.card-number-button.is-active {
  background: var(--gold);
  border-color: rgba(35, 32, 24, 0.5);
}

.card-preview-column {
  align-items: center;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  height: 100%;
  justify-items: center;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.card-deck-scroll {
  align-items: start;
  display: grid;
  gap: 22px;
  height: 100%;
  justify-items: center;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 4px 8px 18px;
  position: relative;
  scroll-padding-block: 4px 18px;
  scroll-snap-type: y mandatory;
  scrollbar-width: thin;
  width: 100%;
}

.card-frame {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
  padding: 8px;
  scroll-margin-block: 4px 18px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  width: min(460px, 100%);
}

.card-frame.is-active {
  align-content: start;
  background: rgba(255, 253, 247, 0.2);
  border-radius: 10px;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 2px rgba(243, 182, 31, 0.36);
}

.card-frame-bar {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  width: min(430px, 100%);
}

.card-frame-label,
.card-delete-card {
  align-items: center;
  background: rgba(255, 253, 247, 0.92);
  border: 2px solid rgba(35, 32, 24, 0.16);
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(35, 32, 24, 0.12);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 900;
  min-height: 30px;
}

.card-frame-label {
  padding: 5px 12px;
}

.card-delete-card {
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.card-delete-card svg {
  height: 15px;
  width: 15px;
}

.card-delete-card:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.card-frame:not(.is-active) .card-preview-card {
  cursor: pointer;
}

.card-preview-card .card-layer {
  cursor: pointer;
  pointer-events: none;
}

.add-card-button {
  max-width: 260px;
  width: 100%;
}

.card-bench-layout .draggable-card {
  --card-color: #fff8e8;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 34%),
    var(--card-color);
  border: 0;
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(35, 32, 24, 0.08);
  max-height: min(700px, calc(100vh - 210px));
  max-width: min(430px, 100%);
}

.card-layer,
.card-border-layer {
  box-sizing: border-box;
  left: 0;
  position: absolute;
  top: 0;
}

.card-layer {
  align-items: center;
  cursor: grab;
  display: flex;
  height: var(--layer-h);
  justify-content: center;
  left: var(--layer-x);
  touch-action: none;
  top: var(--layer-y);
  user-select: none;
  width: var(--layer-w);
}

.card-layer:active {
  cursor: grabbing;
}

.card-layer.is-selected {
  outline: 2px dashed rgba(31, 121, 128, 0.8);
  outline-offset: 3px;
}

.card-layer-scene {
  z-index: 1;
}

.card-layer-banner {
  z-index: 3;
}

.card-layer-text {
  z-index: 5;
}

.card-layer-shape {
  z-index: 4;
}

.card-layer img {
  display: block;
  height: 100%;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

.card-layer-scene img {
  object-fit: cover;
}

.card-layer-banner img {
  object-fit: contain;
}

.card-border-layer {
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.card-border-layer img {
  display: block;
  height: 100%;
  object-fit: fill;
  width: 100%;
}

.card-text-box {
  align-items: center;
  color: var(--layer-color);
  display: flex;
  font-family: var(--layer-font-family);
  font-size: var(--layer-font-size);
  font-weight: var(--layer-font-weight);
  height: 100%;
  justify-content: center;
  line-height: 1.16;
  overflow: hidden;
  padding: 0.18em 0.28em 0.28em;
  text-align: center;
  text-wrap: balance;
  width: 100%;
  word-break: break-word;
}

.card-text-box:focus {
  outline: none;
}

.card-text-box[contenteditable="false"] {
  cursor: grab;
}

.card-text-box[contenteditable="true"] {
  cursor: text;
  user-select: text;
}

.card-shape {
  background: var(--layer-color);
  display: block;
  height: 100%;
  opacity: 1;
  width: 100%;
}

.card-shape-rectangle {
  border-radius: 10px;
}

.card-shape-circle {
  border-radius: 50%;
}

.card-shape-triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.card-color-handle {
  background: #fffdf7;
  border: 2px solid #fffdf7;
  border-radius: 999px;
  bottom: -12px;
  box-shadow: 0 6px 14px rgba(35, 32, 24, 0.28);
  cursor: pointer;
  height: 24px;
  left: -12px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 24px;
  z-index: 6;
}

.card-layer .card-delete-handle,
.card-layer .card-resize-handle,
.card-layer .card-color-handle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.card-layer.is-selected .card-delete-handle,
.card-layer.is-selected .card-resize-handle,
.card-layer.is-selected .card-color-handle {
  opacity: 1;
  pointer-events: auto;
}

.card-layer .card-delete-handle {
  right: -12px;
  top: -12px;
}

.card-layer .card-resize-handle {
  bottom: -12px;
  right: -12px;
}

.card-exporting .card-layer {
  outline: 0 !important;
}

.card-exporting .card-delete-handle,
.card-exporting .card-resize-handle,
.card-exporting .card-color-handle {
  display: none !important;
}

.generator-output,
.board-output {
  background:
    linear-gradient(90deg, rgba(255, 253, 247, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 253, 247, 0.08) 1px, transparent 1px),
    rgba(255, 253, 247, 0.1);
  background-size: 24px 24px;
  border-radius: 8px;
  min-width: 0;
  padding: clamp(14px, 2vw, 18px);
}

.piece-editor {
  border-top: 2px dashed rgba(35, 32, 24, 0.14);
  margin-top: 16px;
  padding-top: 14px;
}

.piece-editor .eyebrow {
  color: rgba(35, 32, 24, 0.56);
  margin-bottom: 8px;
}

.piece-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.piece-actions {
  gap: 8px;
}

.generated-map-title {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.generated-map-title h3 {
  color: #fffdf7;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.15;
  padding-bottom: 0.04em;
}

.map-canvas,
.board-canvas {
  background: #fffdf7;
  border-radius: 8px;
  box-shadow: 0 20px 42px rgba(35, 32, 24, 0.2);
  min-height: 500px;
  overflow: hidden;
}

.board-map-canvas {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: clamp(10px, 2vw, 18px);
}

.generated-board-map {
  aspect-ratio: 16 / 10;
  background: #fffdf7;
  border: 3px solid rgba(35, 32, 24, 0.12);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.58);
  max-width: 920px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  width: 100%;
}

.map-pattern-layer {
  background-color: var(--map-pattern-color, #7ecf45);
  background-image: var(--map-pattern-image);
  background-position: center;
  background-size: cover;
  display: block;
  inset: 0;
  position: absolute;
  z-index: 0;
}

.generated-board-map.is-drawing-mode {
  cursor: crosshair;
}

.generated-board-map.board-layout-rectangle {
  aspect-ratio: 16 / 10;
}

.generated-board-map.board-layout-square,
.generated-board-map.board-layout-round {
  aspect-ratio: 1;
  max-width: 660px;
}

.generated-board-map.board-layout-round {
  border-radius: 50%;
}

.generated-board-map.board-layout-tiles {
  aspect-ratio: 14 / 10;
}

.map-layer {
  display: block;
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}

.generated-board-map > .map-layer {
  height: 100%;
  width: 100%;
}

.tile-layer {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.board-tile {
  --tile-size: 11%;
  --tile-art-h: 900%;
  --tile-art-w: 900%;
  --tile-art-x: 0%;
  --tile-art-y: 0%;
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  box-shadow: 0 4px 10px rgba(35, 32, 24, 0.1);
  cursor: grab;
  height: auto;
  isolation: isolate;
  left: var(--tile-x);
  overflow: hidden;
  pointer-events: auto;
  position: absolute;
  top: var(--tile-y);
  transform: translate(-50%, -50%);
  width: var(--tile-size);
}

.board-tile::before {
  background: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.board-tile:active {
  cursor: grabbing;
}

.board-tile.is-selected {
  border-color: rgba(0, 0, 0, 0.9);
  box-shadow: 0 0 0 3px rgba(243, 182, 31, 0.5), inset 0 0 0 1px rgba(255, 253, 247, 0.5);
  z-index: 3;
}

.board-tile-hex {
  aspect-ratio: 1.154700538 / 1;
  box-shadow: none;
}

.board-tile-hex.is-selected {
  box-shadow: none;
  filter: drop-shadow(0 0 7px rgba(243, 182, 31, 0.52));
}

.board-tile-hex::before,
.board-tile-hex .tile-art-static {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.tile-art {
  background-color: var(--map-pattern-color, #7ecf45);
  background-image: var(--map-pattern-image);
  background-position: center;
  background-size: 100% 100%;
  display: block;
  height: var(--tile-art-h);
  left: var(--tile-art-x);
  pointer-events: none;
  position: absolute;
  top: var(--tile-art-y);
  width: var(--tile-art-w);
}

.tile-art-static {
  border-radius: 3px;
  height: auto;
  inset: 1px;
  width: auto;
  background-size: cover;
  z-index: 1;
}

.tile-art > .map-layer {
  display: block;
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}

.tile-delete-handle {
  right: 4px;
  top: 4px;
  z-index: 8;
}

.tile-resize-handle {
  bottom: 4px;
  right: 4px;
  z-index: 8;
}

.tile-number-badge {
  align-items: center;
  background: rgba(35, 32, 24, 0.92);
  border: 2px solid #fffdf7;
  border-radius: 999px;
  color: #fffdf7;
  display: inline-flex;
  font-size: 0.68rem;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  left: 5px;
  line-height: 1;
  position: absolute;
  top: 5px;
  width: 24px;
  z-index: 4;
}

.tile-number-badge-large {
  height: 34px;
  left: 12px;
  top: 12px;
  width: 34px;
}

.tile-individual-shell {
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr);
  height: min(620px, calc(100vh - 228px));
  min-height: 500px;
  width: 100%;
}

.tile-number-list {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 100%;
  overflow-y: auto;
  padding: 4px;
  scrollbar-width: thin;
}

.tile-number-button {
  align-items: center;
  aspect-ratio: 1;
  background: rgba(255, 253, 247, 0.82);
  border: 1px solid rgba(35, 32, 24, 0.18);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 900;
  justify-content: center;
  min-width: 34px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tile-number-button:hover,
.tile-number-button:focus-visible {
  background: #fffdf7;
  border-color: rgba(35, 32, 24, 0.48);
  outline: none;
  transform: translateY(-1px);
}

.tile-number-button.is-active {
  background: var(--gold);
  border-color: rgba(35, 32, 24, 0.55);
}

.tile-preview-column {
  display: grid;
  gap: 14px;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
}

.tile-deck-scroll {
  display: block;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 0 18px 0 8px;
  scroll-padding-block: 0;
  scroll-snap-type: y mandatory;
  scrollbar-color: rgba(35, 32, 24, 0.42) rgba(255, 253, 247, 0.42);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.tile-deck-scroll::-webkit-scrollbar {
  width: 10px;
}

.tile-deck-scroll::-webkit-scrollbar-track {
  background: rgba(255, 253, 247, 0.42);
  border-radius: 999px;
}

.tile-deck-scroll::-webkit-scrollbar-thumb {
  background: rgba(35, 32, 24, 0.42);
  border-radius: 999px;
}

.tile-frame {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  height: 100%;
  justify-content: center;
  min-height: 100%;
  padding: 10px 0 14px;
  scroll-margin-block: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  width: 100%;
}

.individual-tile {
  --individual-tile-size: 11;
  --individual-tile-width: 352px;
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 18px 38px rgba(35, 32, 24, 0.18);
  cursor: pointer;
  isolation: isolate;
  max-height: calc(100% - 24px);
  max-width: min(440px, 82vw);
  min-height: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
  transition: box-shadow 160ms ease, transform 160ms ease;
  width: min(var(--individual-tile-width), 440px, 86%);
}

.individual-tile::before,
.individual-tile::after {
  border-radius: 10px;
  content: "";
  pointer-events: none;
  position: absolute;
}

.individual-tile::before {
  background: rgba(0, 0, 0, 0.9);
  inset: 0;
  z-index: 0;
}

.individual-tile::after {
  background-color: var(--map-pattern-color, #7ecf45);
  background-image: var(--map-pattern-image);
  background-position: center;
  background-size: cover;
  inset: 1px;
  z-index: 1;
}

.individual-tile:hover,
.individual-tile:focus-visible,
.tile-frame.is-active .individual-tile {
  box-shadow: 0 0 0 4px rgba(243, 182, 31, 0.45), 0 20px 42px rgba(35, 32, 24, 0.22);
  outline: none;
  transform: translateY(-1px);
}

.individual-tile:not(.is-selected) > .tile-delete-handle,
.individual-tile:not(.is-selected) > .tile-resize-handle {
  display: none;
}

.individual-tile-hex {
  aspect-ratio: 1.154700538 / 1;
  box-shadow: none;
}

.individual-tile-hex::before,
.individual-tile-hex::after {
  border-radius: 0;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.individual-tile-hex:hover,
.individual-tile-hex:focus-visible,
.tile-frame.is-active .individual-tile-hex {
  box-shadow: none;
  filter: drop-shadow(0 0 7px rgba(243, 182, 31, 0.52)) drop-shadow(0 16px 22px rgba(35, 32, 24, 0.18));
}

.add-tile-button {
  justify-self: center;
  max-width: 260px;
  width: 100%;
}

.map-piece {
  --piece-color: var(--teal);
  --piece-scale: 1;
  --piece-w: 66px;
  --piece-h: 66px;
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--piece-color);
  cursor: grab;
  display: grid;
  grid-template-rows: var(--piece-h) auto;
  height: auto;
  justify-items: center;
  left: var(--piece-x);
  min-height: var(--piece-h);
  padding: 0;
  position: absolute;
  top: var(--piece-y);
  touch-action: none;
  transform: translate(-50%, -50%) scale(var(--piece-scale));
  transform-origin: center;
  transition: filter 150ms ease, transform 150ms ease;
  width: var(--piece-w);
  z-index: 4;
}

.board-tile .map-piece {
  transition: filter 150ms ease;
}

.map-piece:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(calc(var(--piece-scale) * 1.04));
}

.map-piece:hover,
.map-piece:focus-visible,
.map-piece.is-selected {
  filter: drop-shadow(0 9px 10px rgba(35, 32, 24, 0.22)) drop-shadow(0 0 0 rgba(243, 182, 31, 0.8));
  outline: none;
}

.map-piece.is-selected {
  z-index: 4;
}

.map-piece.is-selected::before {
  border: 2px dashed rgba(243, 182, 31, 0.95);
  border-radius: 12px;
  content: "";
  inset: -7px;
  pointer-events: none;
  position: absolute;
}

.map-piece-art {
  display: block;
  height: var(--piece-h);
  pointer-events: none;
  width: var(--piece-w);
}

.map-piece-image {
  background: var(--piece-color);
  mask: var(--piece-image) center / contain no-repeat;
  -webkit-mask: var(--piece-image) center / contain no-repeat;
}

.map-text-piece {
  display: block;
  min-height: var(--piece-h);
  width: var(--piece-w);
  z-index: 5;
}

.map-piece-text {
  align-items: center;
  color: var(--piece-color);
  display: flex;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.35rem, 2.3rem);
  font-weight: 800;
  height: 100%;
  justify-content: center;
  line-height: 1.15;
  overflow-wrap: anywhere;
  pointer-events: auto;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 253, 247, 0.55), 0 8px 16px rgba(35, 32, 24, 0.18);
  width: 100%;
}

.individual-tile .map-drawn-path,
.individual-tile .map-path-control,
.individual-tile .map-piece {
  z-index: 4;
}

.map-piece-text[contenteditable="true"] {
  background: rgba(255, 253, 247, 0.86);
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(243, 182, 31, 0.34);
  cursor: text;
  outline: none;
}

.map-piece-label {
  background: rgba(255, 253, 247, 0.78);
  border: 1px solid rgba(35, 32, 24, 0.14);
  border-radius: 999px;
  color: rgba(35, 32, 24, 0.88);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
  max-width: 120px;
  overflow-wrap: anywhere;
  padding: 2px 7px 3px;
  pointer-events: auto;
  text-align: center;
}

.map-piece-label[contenteditable="true"] {
  background: #fffdf7;
  box-shadow: 0 0 0 3px rgba(243, 182, 31, 0.3);
  cursor: text;
  min-width: 48px;
  outline: none;
}

.map-label-toggle {
  align-items: center;
  background: rgba(35, 32, 24, 0.94);
  border: 1px solid rgba(255, 253, 247, 0.18);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(35, 32, 24, 0.25);
  color: #fffdf7;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.62rem;
  font-weight: 900;
  gap: 4px;
  left: 50%;
  line-height: 1;
  padding: 5px 8px;
  position: absolute;
  top: -36px;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 6;
}

.map-label-toggle input {
  accent-color: var(--gold);
  height: 12px;
  margin: 0;
  width: 12px;
}

.map-piece svg,
.map-canvas .map-piece .map-piece-svg {
  color: currentColor;
  display: block;
  height: 100%;
  overflow: visible;
  width: 100%;
}

.piece-soft {
  fill: currentColor;
  opacity: 0.16;
}

.piece-fill {
  fill: currentColor;
  opacity: 0.42;
}

.piece-solid {
  fill: currentColor;
  opacity: 0.9;
}

.piece-line {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.piece-line-wide {
  opacity: 0.42;
  stroke-width: 15;
}

.piece-mark {
  opacity: 0.74;
  stroke-width: 4;
}

.map-drawn-path {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 3;
}

.map-path-svg {
  display: block;
  height: 100%;
  overflow: visible;
  width: 100%;
}

.map-path-svg path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-path-underlay {
  opacity: 0.35;
  stroke: rgba(35, 32, 24, 0.42);
  stroke-width: calc(var(--path-width) * 1.9);
}

.map-path-main {
  stroke: var(--path-color);
  stroke-dasharray: var(--path-dash);
  stroke-width: var(--path-width);
}

.map-path-highlight {
  opacity: 0.66;
  stroke: rgba(232, 249, 255, 0.78);
  stroke-width: 1.2;
}

.map-path-divider {
  opacity: 0.86;
  stroke: rgba(255, 253, 247, 0.86);
  stroke-dasharray: 5 5;
  stroke-width: 0.8;
}

.map-path-control {
  --path-control-size: 24px;
  align-items: center;
  background: #fffdf7;
  border: 2px solid rgba(35, 32, 24, 0.35);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(35, 32, 24, 0.22);
  cursor: grab;
  display: inline-flex;
  height: var(--path-control-size);
  justify-content: center;
  left: var(--path-control-x);
  padding: 0;
  position: absolute;
  top: var(--path-control-y);
  touch-action: none;
  transform: translate(-50%, -50%);
  width: var(--path-control-size);
  z-index: 5;
}

.map-path-control::before {
  background: var(--gold);
  border-radius: 999px;
  content: "";
  height: 8px;
  width: 8px;
}

.map-path-control:hover,
.map-path-control:focus-visible,
.map-path-control.is-selected {
  border-color: var(--gold);
  outline: none;
}

.map-drawn-path.is-selected .map-path-main {
  filter: drop-shadow(0 0 5px rgba(243, 182, 31, 0.55));
}

.map-export .map-delete-handle,
.map-export .map-resize-handle,
.map-export .tile-delete-handle,
.map-export .tile-resize-handle,
.map-export .map-label-toggle,
.map-export .map-path-control,
.map-export .map-piece.is-selected::before {
  display: none !important;
}

.map-export .map-piece,
.map-export .map-drawn-path {
  filter: none !important;
}

.map-resize-handle {
  background: var(--gold);
  border: 2px solid #fffdf7;
  border-radius: 5px;
  bottom: -10px;
  box-shadow: 0 6px 14px rgba(35, 32, 24, 0.28);
  cursor: nwse-resize;
  height: 18px;
  pointer-events: auto;
  position: absolute;
  right: -10px;
  width: 18px;
  z-index: 5;
}

.map-delete-handle {
  right: 0;
  top: 0;
}

.map-resize-handle::before {
  border-bottom: 2px solid rgba(35, 32, 24, 0.58);
  border-right: 2px solid rgba(35, 32, 24, 0.58);
  bottom: 4px;
  content: "";
  height: 6px;
  position: absolute;
  right: 4px;
  width: 6px;
}

.map-canvas > svg:not(.map-layer),
.board-canvas svg {
  display: block;
  height: auto;
  width: 100%;
}

.map-canvas .generated-board-map > svg.map-layer {
  display: block;
  height: 100%;
  inset: 0;
  max-height: none;
  max-width: none;
  position: absolute;
  width: 100%;
}

.board-canvas {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 18px;
}

.board-visual {
  display: grid;
  gap: 7px;
  max-width: min(620px, 100%);
  width: 100%;
}

.board-visual.board-rectangle {
  aspect-ratio: 16 / 10;
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.board-visual.board-square {
  aspect-ratio: 1;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.board-visual.board-tiles {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.board-cell {
  align-items: center;
  aspect-ratio: 1;
  background: rgba(31, 121, 128, 0.12);
  border: 2px solid rgba(35, 32, 24, 0.12);
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
}

.board-token {
  aspect-ratio: 1;
  background: var(--gold);
  border: 2px solid rgba(35, 32, 24, 0.14);
  border-radius: 50%;
  width: 42%;
}

.round-board {
  aspect-ratio: 1;
  background:
    radial-gradient(circle at center, rgba(243, 182, 31, 0.18) 0 26%, transparent 27%),
    conic-gradient(from 0deg, rgba(31, 121, 128, 0.2), rgba(243, 182, 31, 0.2), rgba(177, 74, 53, 0.2), rgba(31, 121, 128, 0.2));
  border: 3px solid rgba(35, 32, 24, 0.14);
  border-radius: 50%;
  max-width: 560px;
  position: relative;
  width: 100%;
}

.round-board .board-token {
  left: var(--token-x);
  position: absolute;
  top: var(--token-y);
  transform: translate(-50%, -50%);
  width: 4.8%;
}

@media (max-width: 980px) {
  .toolkit-hero,
  .dice-crafter-grid,
  .card-workbench-grid,
  .generator-grid {
    grid-template-columns: 1fr;
  }

  .toolkit-hero img {
    justify-self: start;
    max-width: 360px;
  }

  .card-stage {
    min-height: auto;
  }

  .card-bench-layout .draggable-card {
    max-height: min(660px, 82vh);
  }

  .tile-individual-shell {
    height: min(580px, calc(100vh - 210px));
  }
}

@media (max-width: 680px) {
  .toolkit-page {
    padding: calc(var(--header-height) + 18px) 14px 34px;
  }

  .tool-form-grid,
  .side-fields,
  .card-bench-form {
    grid-template-columns: 1fr;
  }

  .shape-toolbar,
  .card-export-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shape-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel-copy,
  .generated-map-title {
    align-items: start;
    flex-direction: column;
  }

  .die-row,
  .die-result-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .die-row .mini-action {
    grid-column: span 2;
  }

  .map-canvas,
  .board-canvas {
    min-height: 320px;
  }

  .card-bench-layout .card-stage {
    height: clamp(620px, 82vh, 740px);
    padding: 12px;
  }

  .card-stack-shell {
    gap: 8px;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .card-number-list {
    grid-auto-flow: column;
    justify-self: stretch;
    justify-content: flex-start;
    max-height: none;
    max-width: 100%;
    order: -1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px;
    position: static;
    z-index: 18;
  }

  .tile-individual-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 420px;
  }

  .tile-number-list {
    flex-direction: row;
    max-height: none;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .individual-tile {
    width: min(360px, 84vw);
  }
}
