.deck-recipe-dialog {
  --recipe-edge-gap: 16px;
  --recipe-safe-top: max(var(--recipe-edge-gap), var(--app-safe-top, env(safe-area-inset-top, 0px)));
  --recipe-safe-bottom: max(var(--recipe-edge-gap), var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
  --recipe-safe-left: max(12px, var(--app-safe-left, env(safe-area-inset-left, 0px)));
  --recipe-safe-right: max(12px, var(--app-safe-right, env(safe-area-inset-right, 0px)));
  --recipe-available-height: calc(min(100dvh, var(--app-viewport-height, 100dvh)) - var(--recipe-safe-top) - var(--recipe-safe-bottom));
  box-sizing: border-box;
  top: var(--recipe-safe-top);
  bottom: var(--recipe-safe-bottom);
  left: var(--recipe-safe-left);
  right: var(--recipe-safe-right);
  width: min(960px, calc(100% - 24px));
  max-width: calc(min(100dvw, var(--app-viewport-width, 100dvw)) - var(--recipe-safe-left) - var(--recipe-safe-right));
  height: fit-content;
  max-height: var(--recipe-available-height);
  margin: auto;
  padding: 0;
  border: 1px solid #b39a62;
  border-radius: 14px;
  color: #eaf0e6;
  background: #102a24;
  box-shadow: 0 20px 80px #0009;
  font-size: clamp(14px, 1.6vw, 18px);
}

.deck-recipe-dialog[open] {
  display: flex;
  flex-direction: column;
}

.deck-recipe-dialog::backdrop { background: #030d0ac9; }
.deck-recipe-dialog * { box-sizing: border-box; }
.deck-recipe-dialog button { min-height: 44px; font: inherit; }
.deck-recipe-heading, .deck-recipe-footer { flex: none; padding: 14px 18px; }
.deck-recipe-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #75815d; }
.deck-recipe-heading h2 { margin: 0; font-size: 1.3em; }
.deck-recipe-heading button { flex: none; }
.deck-recipe-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 18px; }
.deck-recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.deck-recipe-note { font-size: .85em; line-height: 1.6; color: #bacabe; }
.deck-recipe-code-label { display: grid; gap: 8px; margin: 18px 0 10px; }
.deck-recipe-dialog textarea { width: 100%; min-height: 74px; padding: 10px; border: 1px solid #81916a; border-radius: 6px; color: #eff4e8; background: #081b16; font: 16px/1.5 monospace; resize: vertical; overflow-wrap: anywhere; }
.deck-recipe-footer { border-top: 1px solid #75815d; }
.deck-recipe-message { margin: 0 0 10px; overflow-wrap: anywhere; }
.deck-recipe-message:empty { display: none; }
.deck-recipe-actions > button { flex: 1 1 auto; }
.deck-recipe-missing { color: #f4c084; }
.deck-recipe-poster { display: block; width: 100%; height: auto; }
.deck-recipe-poster[hidden] { display: none; }

@media (max-height: 500px) {
  .deck-recipe-dialog { --recipe-edge-gap: 6px; height: var(--recipe-available-height); }
  .deck-recipe-heading, .deck-recipe-footer { padding: 8px 12px; }
  .deck-recipe-message { font-size: 12px; margin-bottom: 4px; }
}

.deck-recipe-library-dialog {
  width: min(1180px, calc(100% - 24px));
  height: min(820px, var(--recipe-available-height));
  font-size: 14px;
  overflow: hidden;
}
.deck-recipe-library-dialog .deck-recipe-heading { padding: 10px 16px; }
.deck-recipe-library-dialog .deck-recipe-heading h2 { font-size: 18px; letter-spacing: .06em; }
.deck-recipe-library-dialog .deck-recipe-heading button { min-height: 36px; padding: 6px 14px; }
.deck-recipe-library-dialog .deck-recipe-body {
  flex: 1;
  display: grid;
  grid-template-columns: clamp(176px, 19vw, 224px) minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
}
.deck-recipe-sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #71826455;
  background: linear-gradient(160deg, #1e382e, #0a1c18);
}
.deck-recipe-sidebar-title { margin: 0; padding: 16px 14px 10px; font-size: 12px; color: #bcb18d; letter-spacing: .08em; }
.deck-recipe-options { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 12px; overflow: auto; overscroll-behavior: contain; }
.deck-recipe-library-dialog .deck-recipe-choice {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 9px;
  min-width: 0;
  width: 100%;
  min-height: 64px;
  text-align: left;
  color: #d9e2d7;
  background: #0b211a80;
  border: 1px solid #77906b44;
  border-radius: 7px;
  box-shadow: none;
}
.deck-recipe-library-dialog .deck-recipe-choice:hover { background: #345243; border-color: #bba76e; }
.deck-recipe-library-dialog .deck-recipe-choice[aria-pressed="true"] { background: linear-gradient(100deg, #65582b99, #253d30); border-color: #d0b265; box-shadow: inset 3px 0 #e3c777; color: #fff1c9; }
.deck-recipe-choice img { width: 32px; height: 46px; object-fit: cover; border-radius: 4px; flex: none; }
.deck-recipe-choice-caption { display: grid; gap: 5px; min-width: 0; }
.deck-recipe-choice strong { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.deck-recipe-choice small { font-size: 11px; color: #abb9a9; font-weight: normal; }
.deck-recipe-library-dialog .deck-recipe-shared-choice { min-height: 48px; margin-top: 8px; }
.deck-recipe-code-symbol { width: 32px; flex: none; text-align: center; font-size: 24px; color: #b7cfc4; }
.deck-recipe-detail { container-type: inline-size; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 14px; background: radial-gradient(ellipse at top right, #26423766, transparent 70%); }
.deck-recipe-preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.deck-recipe-variants {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: none;
  width: min(100%, 320px);
  gap: 4px;
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid #77906b66;
  border-radius: 8px;
  background: #091b1780;
}
.deck-recipe-variants[hidden] { display: none; }
.deck-recipe-library-dialog .deck-recipe-variants button {
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #c6d4c9;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}
.deck-recipe-library-dialog .deck-recipe-variants button:hover { background: #345243; }
.deck-recipe-library-dialog .deck-recipe-variants button[aria-pressed="true"] {
  border-color: #c5ac6b;
  color: #fff1c9;
  background: #60542c80;
}
.deck-recipe-preview-heading { display: flex; align-items: baseline; gap: 12px; flex: none; }
.deck-recipe-preview-heading h3 { flex: 1; min-width: 0; margin: 0; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.deck-recipe-total { color: #ebd49a; font-size: 14px; white-space: nowrap; }
.deck-recipe-type-stats { display: flex; gap: 12px; padding: 6px 0 9px; font-size: 11px; flex: none; }
.deck-recipe-type-stats span::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 4px; background: var(--recipe-type-color); border-radius: 50%; vertical-align: middle; }
.deck-recipe-type-warrior { --recipe-type-color: #d68c80; }
.deck-recipe-type-weapon { --recipe-type-color: #7ca5cb; }
.deck-recipe-type-special { --recipe-type-color: #71b18b; }
.deck-recipe-setup { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 12px; flex: none; }
.deck-recipe-setup > div { min-width: 0; padding: 6px 8px; background: #0a1d1899; border: 1px solid #7f916142; border-radius: 5px; }
.deck-recipe-setup small { display: block; color: #b9ac7e; font-size: 10px; margin-bottom: 3px; }
.deck-recipe-setup span { display: block; font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
.deck-recipe-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(82px, 10cqi, 104px)), 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 5px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1px 3px 2px 1px;
}
.deck-recipe-card {
  min-width: 0;
  border: 1px solid var(--recipe-type-color, #7c856e);
  border-radius: 4px;
  background: #091b17b3;
}
:is(.deck-recipe-library-dialog, .player-shop) .deck-recipe-card-button {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1.6;
  overflow: hidden;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: inherit;
  background: transparent;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}
:is(.deck-recipe-library-dialog, .player-shop) .deck-recipe-card-button:hover { background: #c9dfae14; }
.deck-recipe-card-button:focus-visible { outline: 2px solid #e4c777; outline-offset: -2px; }
.deck-recipe-card img { position: absolute; inset: 0; width: 100%; height: calc(100% - 16px); object-fit: cover; }
.deck-recipe-card-button > div { position: absolute; inset: auto 0 0; display: grid; gap: 3px; padding: 24px 4px 4px; background: linear-gradient(transparent, #071714e8 35%, #071714); overflow-wrap: anywhere; }
.deck-recipe-card strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-height: 2.5em; font-size: clamp(10px, 1.35cqi, 12px); line-height: 1.25; }
.deck-recipe-card small { font-size: 9px; color: #bbccc3; }
.deck-recipe-card-count { position: absolute; top: 4px; right: 4px; min-width: 24px; padding: 2px 4px; text-align: center; border: 1px solid #d9be7e; background: #102b27ed; border-radius: 2px; color: #fff4cd; font-size: 13px; font-variant-numeric: tabular-nums; }
.deck-recipe-card .deck-recipe-card-rarity { position: absolute; z-index: 1; top: 4px; right: 4px; width: 30px; height: 25px; font-size: 10px; pointer-events: none; }
.deck-recipe-card .deck-recipe-missing { position: absolute; z-index: 1; top: 30px; left: 4px; max-width: calc(100% - 8px); padding: 3px 5px; border: 1px solid #ffcc78; border-radius: 3px; color: #fff2d5; background: #713c13f5; font-size: 10px; font-weight: 700; line-height: 1.2; }
.deck-recipe-card.has-missing { border-color: #ffbc62; box-shadow: 0 0 0 1px #ffbc6266; background: #352d1e; }
.deck-recipe-card.has-missing img { filter: saturate(.3) brightness(.65); }
.deck-recipe-card.has-missing small { color: #ffd190; font-weight: 700; }
.deck-recipe-type-stats { flex-wrap: wrap; }
.deck-recipe-missing-total { color: #ffd190; font-weight: 700; }
.deck-recipe-type-stats .deck-recipe-missing-total::before { background: #ffbc62; }
.deck-recipe-shortage { flex: none; margin: 8px 0 0; font-size: 11px; line-height: 1.4; color: #e1bc87; }
.deck-recipe-empty { margin: auto; padding: 20px; color: #96ab9c; font-size: 13px; text-align: center; }
.deck-recipe-import { flex: none; min-height: 0; overflow: auto; max-height: 100%; margin-bottom: 12px; }
.deck-recipe-import[hidden] { display: none; }
.deck-recipe-detail:has(> .deck-recipe-import[open]:not([hidden])) > .deck-recipe-preview { display: none; }
.deck-recipe-import summary { padding: 8px 0; cursor: pointer; font-size: 13px; color: #d6c697; }
.deck-recipe-import .deck-recipe-code-label { margin: 4px 0 8px; font-size: 12px; }
.deck-recipe-import textarea { min-height: 60px; }
.deck-recipe-library-dialog .deck-recipe-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 10px 16px; background: #0b211b; }
.deck-recipe-library-dialog .deck-recipe-message { margin: 0; font-size: 12px; line-height: 1.4; }
.deck-recipe-library-dialog .deck-recipe-note { margin: 3px 0 0; font-size: 10px; color: #94a695; }
.deck-recipe-library-dialog .deck-recipe-actions { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.deck-recipe-library-dialog .deck-recipe-actions button { min-height: 40px; padding: 8px 18px; font-size: 13px; }
@media (max-width: 620px) and (orientation: portrait) {
  .deck-recipe-library-dialog { --recipe-edge-gap: 12px; width: calc(100% - 16px); height: var(--recipe-available-height); }
  .deck-recipe-library-dialog .deck-recipe-heading { padding: 8px 10px; }
  .deck-recipe-library-dialog .deck-recipe-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .deck-recipe-sidebar { border-right: 0; border-bottom: 1px solid #71826455; }
  .deck-recipe-sidebar-title { padding: 7px 10px 4px; font-size: 10px; }
  .deck-recipe-options { flex-direction: row; padding: 0 8px 8px; }
  .deck-recipe-library-dialog .deck-recipe-choice { width: 136px; min-height: 50px; padding: 5px; gap: 6px; }
  .deck-recipe-options[data-grouped="true"] [data-recipe-group] { width: 112px; }
  .deck-recipe-options[data-grouped="true"][data-choice-count="3"] {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding-right: 6px;
    padding-left: 6px;
  }
  .deck-recipe-library-dialog .deck-recipe-options[data-grouped="true"][data-choice-count="3"] > .deck-recipe-choice {
    width: 100%;
    padding: 4px;
    gap: 4px;
  }
  .deck-recipe-options[data-grouped="true"] .deck-recipe-shared-choice { justify-content: center; text-align: center; }
  .deck-recipe-options[data-grouped="true"] .deck-recipe-shared-choice .deck-recipe-code-symbol { display: none; }
  .deck-recipe-choice img { width: 24px; height: 34px; }
  .deck-recipe-choice strong { font-size: 11px; }
  .deck-recipe-choice small { font-size: 10px; }
  .deck-recipe-choice-caption { gap: 2px; }
  .deck-recipe-library-dialog .deck-recipe-shared-choice { order: -1; margin-top: 0; width: 116px; }
  .deck-recipe-code-symbol { width: 24px; font-size: 20px; }
  .deck-recipe-detail { padding: 10px 8px 8px; }
  .deck-recipe-variants { margin-bottom: 8px; }
  .deck-recipe-library-dialog .deck-recipe-variants button { font-size: 13px; }
  .deck-recipe-preview-heading h3 { font-size: 15px; }
  .deck-recipe-total { font-size: 12px; }
  .deck-recipe-type-stats { padding: 4px 0 7px; font-size: 10px; }
  .deck-recipe-setup { gap: 4px; padding-bottom: 8px; }
  .deck-recipe-setup > div { padding: 4px; }
  .deck-recipe-setup span { font-size: 10px; }
  .deck-recipe-setup small { font-size: 9px; }
  .deck-recipe-card-grid { gap: 4px; }
  .deck-recipe-card small, .deck-recipe-card .deck-recipe-missing { font-size: 9px; }
  .deck-recipe-library-dialog .deck-recipe-footer { padding: 8px 10px; column-gap: 8px; }
  .deck-recipe-library-dialog .deck-recipe-actions button { padding: 8px 10px; font-size: 12px; max-width: 140px; }
  .deck-recipe-library-dialog .deck-recipe-note { font-size: 9px; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .deck-recipe-options[data-grouped="true"][data-choice-count="3"] [data-recipe-group] img {
    width: 20px;
    height: 29px;
  }
}

@media (max-height: 500px) {
  .deck-recipe-library-dialog { --recipe-edge-gap: 6px; height: var(--recipe-available-height); }
  .deck-recipe-library-dialog .deck-recipe-heading { padding: 5px 12px; }
  .deck-recipe-library-dialog .deck-recipe-footer { padding: 6px 12px; }
  .deck-recipe-detail { padding: 8px 10px; }
  .deck-recipe-variants { margin-bottom: 6px; }
  .deck-recipe-type-stats { padding: 3px 0 5px; }
  .deck-recipe-setup { padding-bottom: 6px; }
}

.deck-recipe-share-controls { padding: 14px 12px; gap: 12px; overflow: auto; overscroll-behavior: contain; }
.deck-recipe-share-controls > * { flex: none; }
.deck-recipe-share-controls .deck-recipe-code-label { margin: 0; font-size: 12px; color: #d6c697; }
.deck-recipe-share-controls textarea { height: calc(5 * 1.5em + 20px); resize: none; word-break: break-all; font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.deck-recipe-copy-actions { display: grid; gap: 6px; }
.deck-recipe-copy-actions button { padding: 8px; font-size: 12px; }
.deck-recipe-share-note { margin: 0; font-size: 11px; line-height: 1.5; color: #a6b8a9; }
.deck-recipe-image-preview summary { padding: 6px 0; color: #d6c697; font-size: 12px; cursor: pointer; }
.deck-recipe-image-preview img { margin-top: 6px; -webkit-touch-callout: default; }
.deck-recipe-image-preview[hidden] { display: none; }
@media (max-width: 620px) and (orientation: portrait) {
  .deck-recipe-share-dialog .deck-recipe-body { grid-template-rows: minmax(0, auto) minmax(120px, 1fr); }
  .deck-recipe-share-controls { padding: 8px; gap: 6px; max-height: 35dvh; }
  .deck-recipe-share-controls .deck-recipe-code-label { gap: 4px; font-size: 10px; }
  .deck-recipe-share-controls textarea { height: 84px; min-height: 84px; padding: 5px 8px; font-size: 16px; }
  .deck-recipe-copy-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deck-recipe-copy-actions button { min-height: 36px; padding: 5px; font-size: 11px; }
  .deck-recipe-share-note { font-size: 10px; }
  .deck-recipe-image-preview summary { padding: 4px 0; font-size: 11px; }
}
.deck-recipe-card-modal { box-sizing: border-box; max-width: none; max-height: none; margin: 0; border: 0; color: var(--text, #f2eee1); }
.deck-recipe-card-modal::backdrop { background: transparent; }

.deck-recipe-preview-dialog .deck-recipe-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.deck-recipe-preview-dialog .deck-recipe-footer { display: none; }

