:root {
  color-scheme: dark;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #e3f5e9;
  background: #070c09;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; }
[hidden] { display: none !important; }

#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 50% 49%, #0004 14%, #000 76%);
}

main {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.9rem, 2.8vh, 1.65rem);
  min-height: 100svh;
  padding: clamp(1rem, 2.8vh, 2.75rem) clamp(0.75rem, 3vw, 2.5rem);
}

#overall {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 4vw, 2.1rem);
  padding: 0.65rem clamp(1rem, 3.5vw, 2.3rem);
  background: #0d1b14ed;
  border: 1px solid #315340;
  border-radius: 0.8rem;
}

#overall h1 { margin: 0; font-size: 0.95rem; color: #bad5c3; }
#overall dl { display: flex; align-items: baseline; gap: clamp(1rem, 3vw, 2.2rem); margin: 0; }
#overall dl div { display: grid; justify-items: center; }
#overall dd { grid-row: 1; margin: 0; font-size: clamp(1.75rem, 3.8vw, 2.6rem); font-weight: 700; line-height: 1; }
#overall dt { font-size: 0.8rem; margin-top: 0.3rem; }
#overall .wins { color: #a6e6b9; }
#overall .losses { color: #f2bdb7; }

#legends {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: min(100%, 75rem);
  gap: clamp(0.65rem, 2vw, 1.4rem);
}

.legend {
  flex: 1 1 16rem;
  max-width: 22.5rem;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.85rem;
  padding: clamp(0.6rem, 1.6vw, 1.2rem);
  background: linear-gradient(160deg, #112018e0, #0a110eda 70%);
  border: 1px solid #31523e;
  border-radius: 1rem;
}

.card-art {
  display: grid;
  place-items: center;
  aspect-ratio: 744 / 1039;
  min-width: 0;
  overflow: hidden;
}

.card-art img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.legend > .card-art {
  width: min(100%, clamp(10.5rem, calc(44svh - 2.5rem), 18.5rem));
  filter: drop-shadow(0 0.6rem 0.65rem #0008);
}

.missing-art {
  border: 1px solid #375643;
  border-radius: 0.5rem;
  background: #172b21;
  color: #c7e5d2;
  text-align: center;
  padding: 0.45rem;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
}

.legend-numbers { display: grid; gap: 0.3rem; justify-items: center; }
.record { color: #b5d3c1; font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.rate {
  font-size: clamp(2.15rem, 4.7vw, 3.25rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.08em;
  line-height: 1;
}

button {
  border: 1px solid #527762;
  background: #13271d;
  color: #c7e9d4;
  border-radius: 0.45rem;
  min-height: 2.65rem;
  padding: 0.45rem 0.72rem;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

button:hover, button:focus-visible {
  border-color: #a3d3b5;
  background: #223b2e;
}

button:focus-visible { outline: 2px solid #b0e5c4; outline-offset: 3px; }
button:disabled { cursor: default; opacity: 0.55; }
button:disabled:hover { background: #13271d; border-color: #527762; }
#notice { text-align: center; }

dialog {
  width: min(77rem, calc(100% - 1.5rem));
  max-height: 94svh;
  padding: 0;
  color: inherit;
  background: #0b1510;
  border: 1px solid #436752;
  border-radius: 0.9rem;
  box-shadow: 0 1rem 5rem #000b;
}

dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
dialog::backdrop { background: #020604bb; }
dialog header, dialog footer { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; }
dialog header { justify-content: space-between; border-bottom: 1px solid #223c2d; }
dialog footer { justify-content: flex-end; border-top: 1px solid #223c2d; }
dialog h1 { font-size: clamp(0.95rem, 3vw, 1.3rem); margin: 0; }
#deck-cards { padding: 1rem 1.25rem 1.5rem; overflow-y: auto; overscroll-behavior: contain; }
#deck-gallery { display: flex; flex-wrap: wrap; align-items: start; gap: 1.35rem 1.25rem; }
.deck-section { flex: 1 0 100%; min-width: 0; }
.deck-setup { flex: 0 1 auto; }
.deck-section h2 { margin: 0 0 0.7rem; font-size: 1rem; color: #cde7d6; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(5rem, 15vw, 8rem), 1fr)); gap: 0.95rem 0.75rem; }
.deck-setup .deck-grid { display: flex; flex-wrap: wrap; }
.deck-grid figure { margin: 0; width: min(100%, 9rem); min-width: 0; text-align: center; }
.deck-setup figure { width: clamp(4.75rem, 14vw, 7rem); }
.deck-grid figcaption {
  width: max-content;
  margin: 0.35rem auto 0;
  padding: 0.16rem 0.5rem;
  border: 1px solid #355b46;
  border-radius: 0.4rem;
  background: #152a1f;
  color: #dcefe1;
  font-size: 0.93rem;
  font-weight: 700;
}
#deck-raw { margin: 1rem 0 0; white-space: pre-wrap; font-size: 0.96rem; line-height: 1.45; }

@media (max-width: 690px) {
  .legend { flex-basis: 42%; max-width: 18rem; }
  .legend > .card-art { width: min(100%, 14rem); }
  dialog header, dialog footer, #deck-cards { padding-inline: 0.85rem; }
  .deck-grid { gap: 0.8rem 0.5rem; }
}
