/* --------- Root & Base --------- */
:root {
  --rpg-radius: 6px;
}

body:before {
  position: fixed;
  left: -25%;
  top: -25%;
  width: 150%;
  height: 150%;
  z-index: 0;
  content: "";
  background: url("../img/pokemon-bg.png") top center repeat-y;
  background-size: cover;
  opacity: 0.075;
  transform: rotate(-10deg);
}

#content {
  color: #000;
  position: relative;
  z-index: 2;
}

.container-fluid {
  max-width: 1600px;
}

.mw-empty-elt {
  display: none !important;
}

/* --------- Typography --------- */
@media screen and (max-width: 560px), screen and (max-device-width: 720px) {
  h1 { text-align: left; }
}

@media screen and (max-width: 600px) {
  #content h1 { font-size: 1.4em; }
  #content h2 { font-size: 1.2em; }
}

/* --------- Header --------- */
#header {
  z-index: 20000 !important;
  margin-bottom: 20px;
  background: #fffc !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2) !important;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2) !important;
}
@media screen and (max-width: 960px) {
  #header {
    border: 0 !important;
    box-shadow: none !important;
    margin-bottom: 0;
    background: transparent !important;
  }
}

/* --------- Modal: Result Info --------- */
.rpg-result-info,
#rpg-result-info {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: all;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.9);
  z-index: 30000;
}

#rpg-result-info {
  pointer-events: none;
  background: transparent;
}

.rpg-info { overflow: hidden; }
.rpg-info .rpg-result-info,
.rpg-info #rpg-result-info { display: flex; }

#rpg-result-content {
  opacity: 0;
  transition: all 250ms ease-in-out;
  pointer-events: all;
  transform: scale(0, 0);
  width: min(90vw, 480px);
  padding: 15px;
  height: auto;
  display: flex;
  background: #fffe;
  z-index: 10;
  border-radius: 8px;
  border: 2px solid #000;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
  gap: 10px;
  flex-direction: column;
}
#rpg-result-content h3 {
  margin: 0 !important;
  padding: 0;
}
#rpg-result-content h3 button {
  float: right;
  color: #0009;
  border: none;
}
#rpg-result-content .rpg-ic {
  height: auto;
  max-height: 240px;
  width: 100%;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
#rpg-result-content .rpg-ic p { margin: 0 0 10px 0 !important; }
#rpg-result-content .rpg-ic p:last-child { margin: 0 !important; }

.rpg-info #rpg-result-content.active {
  opacity: 1;
  transform: scale(1, 1);
  display: flex;
}

/* --------- Form & Controls --------- */
#rpg-form {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 5px 0 0 0; /* merged margins */
  gap: 10px;
  color: #000;
}
#rpg-form label {
  line-height: 1.2em;
  margin: 0;
  padding: 0;
}

input.form-control {
  background: #fff;
  font-size: 1.6em;
  height: auto;
  color: #000;
  max-width: 180px;
}

input[type="range"] {
  height: 38px;
  -webkit-appearance: none;
  margin: 10px 0;
  width: 100%;
  padding-left: 10px;
  padding-right: 15px;
  box-sizing: border-box;
  max-width: 240px;
  border-radius: 10px;
  outline: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.4) !important;
}
@media screen and (max-width: 768px) {
  input[type="range"] { max-width: 160px !important; }
}
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 10px;
  cursor: pointer;
  box-shadow: 1px 1px 1px #000;
  background: #333;
  border-radius: 5px;
  border: 1px solid #000;
}
input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
  box-shadow: 1px 1px 1px #000;
  border: 1px solid #000;
  height: 30px;
  width: 15px;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
input[type="range"]:focus::-webkit-slider-runnable-track { background: #333; }
input[type="range"]::-ms-track {
  width: 100%; height: 10px; cursor: pointer;
  background: transparent; border-color: transparent; color: transparent;
}
input[type="range"]::-ms-fill-lower,
input[type="range"]::-ms-fill-upper {
  background: #333; border: 1px solid #000; border-radius: 10px;
  box-shadow: 1px 1px 1px #000;
}
input[type="range"]::-ms-thumb {
  margin-top: 1px;
  box-shadow: 1px 1px 1px #000;
  border: 1px solid #000;
  height: 30px; width: 15px; border-radius: 5px; background: #fff; cursor: pointer;
}
input[type="range"]:focus::-ms-fill-lower,
input[type="range"]:focus::-ms-fill-upper { background: #333; }

.rpg-current-count {
  color: rgba(0, 0, 0, 0.8);
  font-size: 1.1em;
  display: flex;
  justify-content: center;
  align-items: center;
}
#rpg-current-count {
  color: #000;
  line-height: 1em;
  font-size: 1.4em;
  width: 48px;
  height: 36px;
  margin: 0 5px;
  padding: 0 !important;
  outline: none !important;
  display: inline-flex;
  justify-content: center !important;
  align-items: center !important;
  text-align: center !important;
  font-weight: bold;
}
input#rpg-current-count::-webkit-outer-spin-button,
input#rpg-current-count::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* Firefox */
input#rpg-current-count { -moz-appearance: textfield; }

.option {
  display: inline-flex;
  flex-direction: row;
  gap: 10px;
  position: relative;
  top: -2px;
  justify-content: center;
  align-items: center;
  margin-right: 5px;
}
.option label {
  line-height: 1em;
  top: 2px;
  position: relative;
  font-weight: normal;
}

.rpg-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 5px 0;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.rpg-advanced { display: inline-flex; color: #000; position: relative; }

/* Quick action button */
.rpg-link {
  transition: all 250ms ease-in-out;
  width: 36px; height: 36px; margin-right: 6px;
  color: #fff !important; font-size: 20px; background: #333;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  text-decoration: none !important;
  display: inline-flex;
  justify-content: center; align-items: center;
  position: relative; z-index: 3;
  transform: scale(1);
}
.rpg-link:hover {
  transform: scale(1.1);
  background: #444;
  color: #fff;
}

#rpg-advanced-options {
  opacity: 0;
  transition: all 250ms ease-in-out;
  pointer-events: all;
  transform: scale(0, 0);
  position: absolute;
  left: 0; top: 48px;
  width: 320px; padding: 15px; height: auto;
  display: flex; gap: 10px; flex-direction: column;
  background: #fffe; z-index: 10;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
}
#rpg-advanced-options.active {
  opacity: 1;
  transform: scale(1, 1);
  display: flex;
}

/* --------- Rows & Options Layout --------- */
.rpg-row {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  gap: 8px;
  flex: 1;
}
.rpg-row-15 { gap: 15px; }
.rpg-row .rpg-option {
  flex: 1 0 calc(30% - 8px);
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
}
.rpg-row .rpg-option label {
  margin: 0 0 5px 0 !important;
  font-size: 14px;
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
}
.rpg-row .rpg-option select option { height: 20px !important; line-height: 20px; padding: 0; }
.rpg-row .rpg-option select,
.rpg-row .rpg-option input[type="text"] {
  outline: none !important;
  box-shadow: none !important;
  width: 100%;
  display: block;
  padding: 0 10px;
  height: 32px !important;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.rpg-row .rpg-option input[type="text"]:focus { border-color: rgba(0, 0, 0, 0.4); }
.rpg-row .rpg-option.rpg-center,
.rpg-row .rpg-option.rpg-center label {
  justify-content: center;
  align-items: center;
  flex: 1;
  display: flex;
}

.rpg-action-row {
  display: flex;
  gap: 10px;
  margin: 5px 0 0 0;
}
.rpg-action-row a {
  display: flex;
  flex: 1;
  justify-content: center;
  border-radius: 6px;
  align-items: center;
  font-size: 1.1em;
}
.rpg-action-row a i { margin-right: 10px; }

/* Buttons */
.btn-copy, .btn-generate {
  border-radius: 10px;
  text-shadow: 0 0 5px rgba(0,0,0,0.4);
}
.no-results .btn-copy { display: none; }

/* Count label */
#rpg-count { position: relative; }
#rpg-count:after {
  content: "Number of Pokemon";
  white-space: nowrap;
  position: absolute;
  left: 0; top: -22px;
  display: flex;
  font-weight: bold;
  line-height: 1em;
  justify-content: center;
  height: 22px;
  font-size: 14px;
  width: 100%;
}

/* Checkbox matrix */
.rpg-cc > label {
  display: block;
  justify-content: flex-start;
  align-items: center;
  margin: 0 0 10px 0 !important;
  width: 100%;
}
.rpg-cc > label > a {
  float: right;
  color: #f50;
  font-weight: bold;
}
.rpg-checkboxes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.rpg-checkboxes label {
  flex: 1 0 33.3333333333%;
  justify-content: center;
  margin: 0 0 5px 0 !important;
  display: block;
  align-items: center;
  font-weight: normal;
}
.rpg-checkboxes label input[type="checkbox"] { margin: 0 5px 0 0; }

/* --------- Results Grid (Container) --------- */
#rpg-results {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 0 0 30px 0;
  min-height: 240px;
  justify-content: center;
  align-items: center;
}

/* Grid rows inside results */
#rpg-results .rpg-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  justify-items: center;
}

/* --------- Result Card --------- */
.rpg-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-decoration: none !important;
  position: relative;
  aspect-ratio: calc(800 / 700);
  /* desktop grid sizing */
  flex-basis: 25%;
  max-width: 25%;
}

a.rpg-result { cursor: pointer !important; }
a.rpg-result .rpg-image { outline: 2px solid transparent; }
a.rpg-result:hover .rpg-image { outline: 4px solid #333; }

#rpg-results.no-images a.rpg-result:hover { outline: 4px solid #333; }
#rpg-results.no-images a.rpg-result:hover h3 { background: #333; }

/* Title */
.rpg-result h3 {
  padding: 0;
  line-height: 1.4em;
  margin: 0;
  opacity: 0;
  text-align: center;
  font-size: 1.1em;
  color: #000;
  flex: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Image frame shared rules */
.rpg-image,
#rpg-results .rpg-image {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--rpg-radius);
  position: relative;
  width: 100%;
  flex: 1;
  margin: 0 0 10px 0;
  height: 100%;
}

/* Sprite image shared rules */
.rpg-image img,
#rpg-results .rpg-image img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
  visibility: visible;
  opacity: 1;
}

/* Loaded result image animation & base */
.rpg-result img {
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  background: #fff;
  position: absolute;
  padding: 10px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  border-radius: var(--rpg-radius);
  left: 0; top: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  -webkit-animation: zoomfadeinblur 400ms ease-in-out forwards;
  animation: zoomfadeinblur 400ms ease-in-out forwards;
  animation-play-state: running;
}
.rpg-result img[src=""] { animation-play-state: paused; }

/* Alerts */
#rpg-results p.alert {
  font-size: 1.2em;
  font-weight: bold;
  -webkit-animation: fadein 400ms ease-in-out forwards;
  animation: fadein 400ms ease-in-out forwards;
  text-align: center;
  background: #900;
  color: #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  outline: 2px solid rgba(128,0,0,0.6);
  border-radius: 6px;
  border: 4px solid #fff;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
#rpg-results p.alert i { font-size: 1.4em; margin-right: 5px; }

/* No-images state — shared card shell */
#rpg-results.no-images .rpg-result {
  aspect-ratio: calc(800 / 600);
  background-image:
    linear-gradient(to bottom, #fff 0%, #e5e5e5 100%);
  background-repeat: repeat-x;
  animation: zoomfadeinblur 400ms ease-in-out forwards;
  animation-play-state: running;
  border-radius: var(--rpg-radius);
  position: relative;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
  font-size: 1.2em;
  border: 1px solid rgba(0,0,0,0.2);
  padding: 15px !important;
  box-sizing: border-box;
  outline: 2px solid #000; /* default outline, overridden below per category */
}

/* No-images state — titles base */
#rpg-results.no-images .rpg-result h3 {
  padding: 8px 10px !important;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  color: #fff;
  border-radius: 6px;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.2);
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
}

/* No-images state — category gradients */
#rpg-results.no-images .rpg-result.birds h3 {
  background-image: linear-gradient(to bottom, #009 0%, #006 100%);
}
#rpg-results.no-images .rpg-result.dino h3 {
  background-image: linear-gradient(to bottom, #900 0%, #600 100%);
}
#rpg-results.no-images .rpg-result.fish h3 {
  background-image: linear-gradient(to bottom, #f50 0%, #c30 100%);
}
#rpg-results.no-images .rpg-result.reptiles h3 {
  background-image: linear-gradient(to bottom, #090 0%, #060 100%);
}

/* No-images state — category outlines */
#rpg-results.no-images .rpg-result.fish { outline: 2px solid #f50; }
#rpg-results.no-images .rpg-result.reptiles { outline: 2px solid #090; }
#rpg-results.no-images .rpg-result.dino { outline: 2px solid #900; }
#rpg-results.no-images .rpg-result.birds { outline: 2px solid #009; }

/* No-images state — overlays */
#rpg-results.no-images .rpg-result * { z-index: 3; }
#rpg-results.no-images .rpg-result:after,
#rpg-results.no-images .rpg-result:before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 1;
}
#rpg-results.no-images .rpg-result:after { opacity: 0.1; filter: blur(2px); }
#rpg-results.no-images .rpg-result:before { opacity: 0.05; }

/* No-images state — colored before layers */
#rpg-results.no-images .rpg-result.fish:before { background: #f50; }
#rpg-results.no-images .rpg-result.reptiles:before { background: #090; }
#rpg-results.no-images .rpg-result.dino:before { background: #900; }
#rpg-results.no-images .rpg-result.birds:before { background: #009; }

/* No-images state — icon after layers */
#rpg-results.no-images .rpg-result.fish:after {
  background: url("./images/fish-icon.svg") center center no-repeat;
  background-size: 125% 125%;
  overflow: hidden;
}
#rpg-results.no-images .rpg-result.reptiles:after {
  background: url("./images/reptiles-icon.svg") center center no-repeat;
  background-size: 110% 110%;
  overflow: hidden;
}
#rpg-results.no-images .rpg-result.dino:after {
  background: url("./images/dino-icon.svg") center center no-repeat;
  background-size: 200% 200%;
  overflow: hidden;
}
#rpg-results.no-images .rpg-result.birds:after {
  background: url("./images/birds-icon.svg") center center no-repeat;
  background-size: 110% 110%;
}

/* Has-images state — title icons */
#rpg-results.has-images .rpg-result.birds h3,
#rpg-results.has-images .rpg-result.dino h3,
#rpg-results.has-images .rpg-result.fish h3,
#rpg-results.has-images .rpg-result.reptiles h3 {
  padding-left: 29px;
  position: relative;
}
#rpg-results.has-images .rpg-result.birds h3:before,
#rpg-results.has-images .rpg-result.dino h3:before,
#rpg-results.has-images .rpg-result.fish h3:before,
#rpg-results.has-images .rpg-result.reptiles h3:before {
  content: "";
  display: inline-flex;
  position: absolute;
  width: 24px; height: 24px;
  left: 0; top: -2px;
  background-size: 100% 100%;
}
#rpg-results.has-images .rpg-result.birds h3:before {
  background: url("./images/birds-icon.svg") center center no-repeat;
}
#rpg-results.has-images .rpg-result.dino h3:before {
  left: -6px;
  background: url("./images/dino-icon.svg") center center no-repeat;
  background-size: 200% 200%;
}
#rpg-results.has-images .rpg-result.fish h3:before {
  background: url("./images/fish-icon.svg") center center no-repeat;
}
#rpg-results.has-images .rpg-result.reptiles h3:before {
  background: url("./images/reptiles-icon.svg") center center no-repeat;
}

/* --------- Animations --------- */
@-webkit-keyframes fadein {
  0% { opacity: 0; transform: scale(0, 0); }
  100% { opacity: 1; transform: scale(1, 1); }
}
@keyframes fadein {
  0% { opacity: 0; transform: scale(0, 0); }
  100% { opacity: 1; transform: scale(1, 1); }
}

@-webkit-keyframes zoomfadeinblur {
  0% { opacity: 0; transform: scale(0, 0); }
  100% { opacity: 1; transform: scale(1, 1); }
}
@keyframes zoomfadeinblur {
  0% { opacity: 0; transform: scale(0, 0); }
  100% { opacity: 1; transform: scale(1, 1); }
}

.fadein {
  -webkit-animation: fadein 400ms ease-in-out forwards;
  animation: fadein 400ms ease-in-out forwards;
}

/* --------- Responsive Tweaks --------- */
@media screen and (max-width: 768px) {
  .rpg-result {
    flex-basis: calc(50% - 7.5px);
    max-width: calc(50% - 7.5px);
  }
  .rpg-result h3 {
    font-size: 1.1em;
    line-height: 1.3em;
  }
  .rpg-result img {
    padding: 8px;
  }
}

.rpg-result .rpg-image img {
  position: static !important;  /* stop absolute positioning */
  margin: auto !important;      /* center horizontally */
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}