:root {
  --wam-mtg-accent: #0693e3;
  --wam-mtg-accent-dark: #045f99;
  --wam-mtg-panel: #01345e;
  --wam-mtg-panel-2: #02497f;
  --wam-mtg-ink: #f7fbff;
}

.wam-mtg-index {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 0 12px;
}

.wam-mtg-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  padding: 8px;
  border-radius: 12px;
  background: rgba(2, 73, 127, 0.08);
}

.wam-mtg-search,
.wam-mtg-set {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  background: #f1f4f7;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.wam-mtg-search {
  flex: 1;
  min-width: 180px;
  padding: 11px 14px;
}

.wam-mtg-set {
  padding: 11px 12px;
}

.wam-mtg-search:focus,
.wam-mtg-set:focus {
  outline: none;
  border-color: var(--wam-mtg-accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(6, 147, 227, 0.2);
}

.wam-mtg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 175px));
  gap: 16px;
  justify-content: flex-start;
}

.wam-mtg-card {
  display: block;
  text-align: left;
  border: 2px solid var(--wam-mtg-accent);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--wam-mtg-accent) 0%, var(--wam-mtg-accent-dark) 100%);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(1, 27, 44, 0.22);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.wam-mtg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(1, 27, 44, 0.3);
  filter: saturate(1.06);
}

.wam-mtg-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55), 0 0 0 6px rgba(6, 147, 227, 0.45);
}

.wam-mtg-card--white { border-color: #d6d0bf; background: linear-gradient(180deg, #b8b3a7 0%, #a39d90 100%); }
.wam-mtg-card--blue { border-color: #0693e3; background: linear-gradient(180deg, #0b8fdf 0%, #086fb0 100%); }
.wam-mtg-card--black { border-color: #707070; background: linear-gradient(180deg, #6a6a6a 0%, #565656 100%); }
.wam-mtg-card--red { border-color: #c44d45; background: linear-gradient(180deg, #bf5f58 0%, #983a34 100%); }
.wam-mtg-card--green { border-color: #4ba368; background: linear-gradient(180deg, #52ab70 0%, #3a7d52 100%); }
.wam-mtg-card--multi { border-color: #8e7b3b; background: linear-gradient(180deg, #948445 0%, #6f6334 100%); }
.wam-mtg-card--colorless,
.wam-mtg-card--unknown { border-color: #7b7b7b; background: linear-gradient(180deg, #7e7e7e 0%, #666 100%); }

.wam-mtg-card--token {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2), 0 5px 16px rgba(1, 27, 44, 0.22);
}

.wam-mtg-card__thumb {
  aspect-ratio: 5 / 7;
  background: #e8eef6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  line-height: 0;
}

.wam-mtg-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wam-mtg-card__ph {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #d8e6f8, #eaf2ff);
}

.wam-mtg-card__body {
  padding: 10px;
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.wam-mtg-card__name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.18;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.wam-mtg-card__type {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  opacity: 0.97;
}

.wam-mtg-card__author {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.88;
}

.wam-mtg-empty {
  padding: 20px;
  color: #fff;
  border-radius: 12px;
  background: rgba(1, 52, 94, 0.55);
}

.wam-mtg-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.wam-mtg-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.wam-mtg-modal__panel {
  position: relative;
  width: min(1020px, calc(100vw - 22px));
  max-width: 1320px;
  margin: 10px auto;
  max-height: calc(100vh - 20px);
  overflow: auto;
  background:
    radial-gradient(110% 180% at 100% -20%, rgba(106, 190, 255, 0.22) 0%, transparent 50%),
    linear-gradient(160deg, var(--wam-mtg-panel) 0%, var(--wam-mtg-panel-2) 100%);
  color: var(--wam-mtg-ink);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.46);
}

.wam-mtg-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 11px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 22px;
  line-height: 32px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wam-mtg-modal__close:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}

.wam-mtg-detail {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wam-mtg-detail__art-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wam-mtg-detail__art {
  display: flex;
  justify-content: center;
}

.wam-mtg-detail__img {
  width: 100%;
  max-width: 360px;
  border-radius: 16px;
  display: block;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
}

.wam-mtg-detail__credits,
.wam-mtg-detail__set {
  padding: 6px 10px 8px;
}

.wam-mtg-detail__credits {
  padding: 9px 10px;
  font-size: 14px;
  line-height: 1.45;
}

.wam-mtg-detail__author,
.wam-mtg-detail__artist {
  margin-top: 2px;
}

.wam-mtg-detail__set {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.wam-mtg-detail__set-symbol {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f8f9ff 0%, #dcecff 100%);
  color: #003560;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 13px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}

.wam-mtg-detail__set-symbol.is-image {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  padding: 2px;
}

.wam-mtg-detail__set-symbol img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.wam-mtg-detail__set-text {
  font-size: 13px;
  line-height: 1.3;
  opacity: 0.95;
}

.wam-mtg-detail__printing {
  display: grid;
  gap: 6px;
  padding: 8px 10px 10px;
}

.wam-mtg-detail__printing-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  opacity: 0.9;
  text-transform: uppercase;
  margin: 0;
}

.wam-mtg-detail__printing-select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
}

.wam-mtg-detail__printing-select:focus {
  outline: none;
  border-color: #7ec9ff;
  box-shadow: 0 0 0 3px rgba(91, 182, 255, 0.22);
}

.wam-mtg-detail__text {
  min-width: 0;
}

.wam-mtg-detail__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding-right: 44px;
  margin-top: 0;
}

.wam-mtg-detail__titleblock {
  min-width: 0;
  overflow: hidden;
  padding-top: 4px;
}

.wam-mtg-detail__name {
  margin: 0;
  font-size: 44px;
  font-weight: 760;
  line-height: 0.95;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.wam-mtg-detail__nickname {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.35;
  opacity: 0.9;
  font-style: italic;
}

.wam-mtg-detail__mana {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-self: end;
  white-space: nowrap;
  align-items: center;
  min-width: max-content;
}

.wam-mtg-detail__mana .ms {
  margin: 0 !important;
  font-size: 27px !important;
  line-height: 1 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.wam-mtg-detail__meta {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.wam-mtg-detail__type {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  font-size: 22px;
  font-weight: 680;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 7px 12px;
}

.wam-mtg-detail__oracle {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 12px 11px;
}

.wam-mtg-detail__oracle .ms,
.wam-mtg-detail__flavor .ms {
  font-size: 1em;
  line-height: 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.08em;
  position: relative;
  top: 0;
  transform: translateY(0.06em);
}

.wam-mtg-detail__flavor {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.45;
  opacity: 0.92;
  font-style: italic;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
}

.wam-mtg-detail__pt {
  margin-top: 10px;
  display: inline-block;
  font-size: 50px;
  font-weight: 740;
  line-height: 0.95;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 4px 12px 6px;
}

.wam-mtg-detail__actions {
  margin-top: 12px;
}

.wam-mtg-detail__flip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wam-mtg-detail__flip:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 980px) {
  .wam-mtg-toolbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px;
  }

  .wam-mtg-set {
    min-width: 130px;
  }

  .wam-mtg-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 160px));
    gap: 12px;
  }

  .wam-mtg-modal__panel {
    width: calc(100vw - 14px);
    margin: 7px auto;
    max-height: calc(100vh - 14px);
    padding: 12px;
    border-radius: 16px;
  }

  .wam-mtg-detail {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .wam-mtg-detail__img {
    max-width: 420px;
  }

  .wam-mtg-detail__header {
    padding-right: 40px;
    gap: 8px;
  }

  .wam-mtg-detail__titleblock {
    padding-top: 2px;
  }

  .wam-mtg-detail__name {
    font-size: 34px;
    line-height: 0.98;
  }

  .wam-mtg-detail__mana .ms {
    font-size: 24px !important;
  }

  .wam-mtg-detail__meta {
    margin-top: 3px;
    padding-top: 7px;
  }

  .wam-mtg-detail__type {
    font-size: 19px;
  }

  .wam-mtg-detail__oracle {
    font-size: 15px;
  }

  .wam-mtg-detail__flavor {
    font-size: 14px;
  }

  .wam-mtg-detail__pt {
    font-size: 40px;
  }
}

@media (max-width: 560px) {
  .wam-mtg-detail__header {
    padding-right: 36px;
    gap: 6px;
  }

  .wam-mtg-detail__name {
    font-size: 28px;
  }

  .wam-mtg-detail__type {
    font-size: 16px;
  }

  .wam-mtg-detail__mana .ms {
    font-size: 22px !important;
  }

  .wam-mtg-detail__oracle {
    font-size: 14px;
    line-height: 1.45;
  }

  .wam-mtg-detail__flavor {
    font-size: 13px;
  }

  .wam-mtg-detail__pt {
    font-size: 34px;
  }
}

body.wam-mtg-modal-open {
  overflow: hidden;
}
