/* =========================================================
   01. RESET / BASE / HOME BUTTON
   ========================================================= */

:root {
  --ui-scale: 1;
}

/* Laptop un po' bassi */
@media (max-height: 900px) and (min-width: 901px) {
  :root {
    --ui-scale: 0.85;
  }
}

/* Laptop bassi */
@media (max-height: 820px) and (min-width: 901px) {
  :root {
    --ui-scale: 0.8;
  }
}

/* Laptop molto bassi */
@media (max-height: 740px) and (min-width: 901px) {
  :root {
    --ui-scale: 0.68;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Press Start 2P", monospace;
  /* background: #f3ead7; */
  color: #2b1d1d;
  background-color: lightgreen;
}

/* HOME BUTTON */
.home-button {
  position: fixed;
  top: 16px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #dcfce7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
  z-index: 1000;
}

.home-button:hover {
  background: #064e3b;
  transform: translateY(-1px);
  color: white;
}

.rules-button {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #dcfce7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
  z-index: 1000;
}

.rules-button:hover {
  background: #064e3b;
  transform: translateY(1px);
  color: white;
}

/* =========================================================
   02. PAGE LAYOUT
   ========================================================= */

.page {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  text-align: center;
  color: #c92f2f;
}

/* =========================================================
   03. GAME CARD
   ========================================================= */

.game-card {
  width: min(100%, 1040px);
  margin: auto;
  padding: calc(22px * var(--ui-scale));
  border: 5px solid #2b1d1d;
  border-radius: 26px;
  background:
    radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.16),
      transparent 34%
    ),
    #c92f2f;
  box-shadow: 10px 10px 0 #2b1d1d;
}

/* =========================================================
   04. TOPBAR / STAT SELECTOR / COUNTERS
   ========================================================= */

.game-topbar {
  /*   display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px; */

  width: 100%;
}

#options-rules {
  font-size: 1rem;
}

#topbar-round-error {
  width: 100%;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
}

.stat-selector,
.top-counter {
  padding: 9px 13px;
  border: 4px solid #2b1d1d;
  border-radius: 14px;
  background: #f7d65a;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 4px 4px 0 #2b1d1d;
}

.stat-selector {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: calc(1rem * var(--ui-scale));
}

.stat-label {
  white-space: nowrap;
}

.stat-options {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.stat-options input {
  display: none;
}

.stat-options label {
  padding: 6px 10px;
  border: 3px solid #2b1d1d;
  border-radius: 999px;
  background: #fff8dc;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.stat-options input:checked + label {
  background: #2b1d1d;
  color: #fff8dc;
}

.top-counter {
  white-space: nowrap;
  width: 20%;
}

#roundCounter::after {
  content: "/20";
}

#errorCounter::after {
  content: "/3";
}

/* =========================================================
   05. MAIN GAME LAYOUT
   ========================================================= */

.game-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: calc(22px * var(--ui-scale));
  align-items: stretch;
}

.main-play-area {
  display: grid;
  grid-template-rows: auto auto;
  gap: calc(16px * var(--ui-scale));
}

/* =========================================================
   06. SPRITE AREA
   ========================================================= */

.spriteFrame {
  padding: calc(16px * var(--ui-scale));
  border: 5px solid #2b1d1d;
  border-radius: 24px;
  background: #d8cfb2;
  box-shadow:
    inset 0 0 0 6px #b9ae8e,
    5px 5px 0 #2b1d1d;
}

.spriteContainer {
  height: calc(360px * var(--ui-scale));
  border: 5px solid #2b1d1d;
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    repeating-linear-gradient(
      0deg,
      #9eb067 0,
      #9eb067 3px,
      #93a45f 3px,
      #93a45f 6px
    );
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow:
    inset 0 0 0 7px #5f6f3d,
    inset 0 0 28px rgba(40, 50, 20, 0.55);
}

#pokemonSprite {
  width: calc(288px * var(--ui-scale));
  height: calc(288px * var(--ui-scale));
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(4px 6px 0 rgba(0, 0, 0, 0.25));
}

/* =========================================================
   07. POKEDEX CONTROLS
   ========================================================= */

.pokedexControls {
  min-height: calc(94px * var(--ui-scale));
  padding: calc(13px * var(--ui-scale));
  border: 5px solid #2b1d1d;
  border-radius: 20px;
  background: #b51f1f;
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 14px;
  align-items: center;
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.08),
    5px 5px 0 #2b1d1d;
}

.nameDisplay {
  min-height: calc(62px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border: 4px solid #2b1d1d;
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.08)),
    repeating-linear-gradient(
      0deg,
      #9eb067 0,
      #9eb067 3px,
      #93a45f 3px,
      #93a45f 6px
    );
  color: #2d341c;
  font-family: monospace;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 900;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0 0 5px #5f6f3d,
    inset 0 0 16px rgba(40, 50, 20, 0.45);
}

#playCryBtn {
  width: 76px;
  height: 76px;
  border: 5px solid #2b1d1d;
  border-radius: 50%;
  background: #b9a10d;
  color: white;
  font-size: 16px;
  font-weight: 900;
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.14),
    4px 5px 0 #2b1d1d;
  cursor: pointer;
}

#playCryBtn:disabled,
.cryDisabled {
  opacity: 0.45;
  filter: grayscale(1);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* =========================================================
   08. INFO PANEL / TAGS / DESCRIPTION
   ========================================================= */

.infoContainer {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: calc(14px * var(--ui-scale));
}

.infoBox {
  border: 5px solid #2b1d1d;
  border-radius: 18px;
  padding: 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.08)),
    repeating-linear-gradient(
      0deg,
      #9eb067 0,
      #9eb067 3px,
      #93a45f 3px,
      #93a45f 6px
    );
  color: #2d341c;
  box-shadow:
    inset 0 0 0 5px #5f6f3d,
    inset 0 0 18px rgba(40, 50, 20, 0.35);
}

.tagBox {
  min-height: calc(88px * var(--ui-scale));
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  justify-content: center;
}

.descriptionBox {
  min-height: calc(210px * var(--ui-scale));
  padding: calc(18px * var(--ui-scale));
  line-height: 1.55;
  font-size: calc(16px * var(--ui-scale));
  font-weight: bolder;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typeTag,
.abilityTag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 3px solid #5d5138;
  border-radius: 999px;
  background: #cfc3a1;
  color: #2d341c;
  font-size: 11px;
  font-weight: 900;
  text-transform: capitalize;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.22);
}

.typeIcon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.hiddenAbility {
  opacity: 0.45;
  filter: grayscale(1);
  border-style: dashed;
}

/* =========================================================
   09. INPUT AREA / NEXT BUTTON
   ========================================================= */

.inputContainer {
  margin-top: calc(22px * var(--ui-scale));
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: calc(20px * var(--ui-scale));
  align-items: center;
}

.customInputGroup {
  width: 100%;
}

.customInputGroup .input-group-text {
  min-width: 78px;
  border: 5px solid #2b1d1d;
  border-right: 0;
  border-radius: 14px 0 0 14px;
  background: #f7d65a;
  justify-content: center;
  font-size: 14px;
  box-shadow: 4px 4px 0 #2b1d1d;
}

.customInputGroup .form-control {
  min-height: calc(62px * var(--ui-scale));
  border: 5px solid #2b1d1d;
  border-radius: 0 14px 14px 0;
  background: #fff8dc;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 4px 4px 0 #2b1d1d;
}

.customInputGroup .form-control:focus {
  border-color: #2b1d1d;
  box-shadow: 4px 4px 0 #2b1d1d;
}

#next-round-button {
  width: calc(112px * var(--ui-scale));
  height: calc(112px * var(--ui-scale));
  justify-self: center;
  border: 5px solid #2b1d1d;
  border-radius: 50%;
  background: #377eb8;
  color: white;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 5px 6px 0 #2b1d1d;
  cursor: pointer;
}

#next-round-button:active,
#playCryBtn:active {
  transform: translate(3px, 4px);
  box-shadow: 1px 1px 0 #2b1d1d;
}

/* =========================================================
   10. END MODAL
   ========================================================= */

.end-modal {
  border: 5px solid #2b1d1d;
  border-radius: 24px;
  background: #fff8dc;
  box-shadow: 8px 8px 0 #2b1d1d;
  overflow: hidden;
}

.end-modal-header {
  padding: 18px;
  border-bottom: 5px solid #2b1d1d;
  background: #c92f2f;
  color: #fff8dc;
}

.end-modal-kicker {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 3px solid #2b1d1d;
  border-radius: 999px;
  background: #f7d65a;
  color: #2b1d1d;
  font-size: 10px;
  font-weight: 900;
}

.end-modal-title {
  margin: 0;
  font-size: clamp(18px, 4vw, 30px);
  line-height: 1.25;
  font-weight: 900;
  text-shadow: 3px 3px 0 #2b1d1d;
}

.end-modal-body {
  padding: 20px;
  background:
    radial-gradient(
      circle at top left,
      rgba(201, 47, 47, 0.18),
      transparent 38%
    ),
    #fff8dc;
}

.final-percentage-box {
  margin-bottom: 18px;
  padding: 18px;
  border: 5px solid #2b1d1d;
  border-radius: 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    repeating-linear-gradient(
      0deg,
      #9eb067 0,
      #9eb067 3px,
      #93a45f 3px,
      #93a45f 6px
    );
  color: #2d341c;
  text-align: center;
  box-shadow:
    inset 0 0 0 5px #5f6f3d,
    4px 4px 0 #2b1d1d;
}

.final-summary-box {
  margin-bottom: 18px;
  padding: 18px;
  border: 5px solid #1a1414;
  border-radius: 14px;

  background:
    radial-gradient(
      circle at center,
      rgba(255, 255, 255, 0.06),
      transparent 60%
    ),
    linear-gradient(rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.62)),
    repeating-linear-gradient(
      0deg,
      #1a1a1a 0,
      #1a1a1a 2px,
      #262626 2px,
      #262626 4px
    );

  color: #f4f1d0;
  text-align: center;

  font-family: "Press Start 2P", monospace;

  image-rendering: pixelated;
}

#finalPercentageText {
  display: block;
  font-size: clamp(28px, 8vw, 52px);
  font-weight: 900;
  line-height: 1;
}

.final-result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.final-result-card {
  padding: 16px;
  border: 4px solid #2b1d1d;
  border-radius: 16px;
  background: #f7d65a;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 4px 4px 0 #2b1d1d;
}

#final-result {
  display: block;
  font-size: clamp(15px, 4vw, 22px);
}

.end-modal-footer {
  padding: 16px;
  border-top: 5px solid #2b1d1d;
  background: #b51f1f;
}

.modal-game-button {
  width: 100%;
  min-height: 58px;
  border: 5px solid #2b1d1d;
  border-radius: 16px;
  background: #377eb8;
  color: white;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 4px 5px 0 #2b1d1d;
  cursor: pointer;
}

.modal-game-button:active {
  transform: translate(3px, 4px);
  box-shadow: 1px 1px 0 #2b1d1d;
}

.history-table-wrapper {
  margin-top: 16px;
  max-height: 260px;
  overflow: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.history-table {
  width: 100%;
  /* min-width: 600px; */
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
  white-space: nowrap;
}

.history-table th {
  font-weight: 700;
  position: sticky;
  top: 0;
  background: #f7d65a;
  border: 2px solid black;
  color: #111;
  z-index: 1;
}
.correct-row td {
  color: #6dff57;
  font-weight: bolder;
  text-shadow: #000 1px 1px;
}

.wrong-row td {
  color: #c92f2f;
  font-weight: bolder;
  text-shadow: #000 1px 1px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.skeleton::after {
  content: "";
  position: absolute;
  top: 0;
  left: -150%;
  width: 150%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.18),
    transparent
  );
  animation: shimmer 1.2s infinite;
}

.skeleton-text {
  width: 140px;
  height: 24px;
  margin: 10px auto;
}

.skeleton-tag {
  width: 90px;
  height: 30px;
  display: inline-block;
  margin: 4px;
}

.skeleton-line {
  width: 100%;
  height: 16px;
  margin-top: 8px;
}

.skeleton-line.short {
  width: 70%;
}

@keyframes shimmer {
  100% {
    left: 150%;
  }
}

.loading-spin {
  animation: pokeballSpin 1s linear infinite;
}

@keyframes pokeballSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.correct {
  animation: correct 0.35s ease;
}

@keyframes correct {
  0% {
    transform: scale(1);
    background-color: lightgreen;
  }
  30% {
    transform: scale(1.25);
    background-color: lightgreen;
  }
  60% {
    transform: scale(1.1);
    background-color: lightgreen;
  }
  100% {
    transform: scale(1);
    background-color: lightgreen;
  }
}

.wrong {
  animation: wrong 0.35s ease;
}

@keyframes wrong {
  0% {
    transform: scale(1);
    transform: translateX(0);
    background-color: red;
  }
  30% {
    transform: scale(1.6);
    transform: translateX(1rem);
    background-color: red;
  }
  60% {
    transform: scale(0.85);
    transform: translateX(-1rem);
    background-color: red;
  }
  100% {
    transform: scale(1);
    transform: translateX(0);
    background-color: red;
  }
}

/* =========================================================
   11. RESPONSIVE - TABLET / SMALL DESKTOP
   ========================================================= */

/* @media (max-width: 900px) {
  .page {
    padding: 18px 12px;
  }

  h1 {
    display: none;
  }

  .game-card {
    padding: 16px;
    border-radius: 22px;
    box-shadow: 6px 6px 0 #2b1d1d;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .spriteContainer {
    height: 300px;
  }

  #pokemonSprite {
    width: 250px;
    height: 250px;
  }

  .descriptionBox {
    min-height: 150px;
    font-weight: bolder;
  }

  .inputContainer {
    grid-template-columns: 1fr 90px;
  }

  #answerInput::placeholder {
    font-size: 0.75rem;
  }

  #next-round-button {
    width: 84px;
    height: 64px;
    border-radius: 16px;
    font-size: 15px;
  }

  .history-table {
    font-size: 0.75rem;
  }

  .history-table th,
  .history-table td {
    padding: 6px;
  }
} */

/* =========================================================
   12. RESPONSIVE - MOBILE
   ========================================================= */

@media (max-width: 900px) {
  h1 {
    display: none;
  }

  .page {
    min-height: 100dvh;
    padding: 8px;
  }

  .game-card {
    min-height: calc(100dvh - 58px);
    padding: 10px;
    border-width: 4px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 4px 4px 0 #2b1d1d;
  }

  .game-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    gap: 8px;
  }

  .topbar-left {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-right {
    justify-content: stretch;
  }

  .stat-selector,
  .top-counter {
    width: 100%;
    padding: 7px 8px;
    border-width: 3px;
    border-radius: 12px;
    font-size: 10px;
    box-shadow: 3px 3px 0 #2b1d1d;
  }

  .stat-selector {
    gap: 8px;
  }

  .stat-label {
    width: 100%;
  }

  .stat-options {
    width: 100%;
    gap: 5px;
    flex-wrap: nowrap;
  }

  .stat-options label {
    flex: 1;
    padding: 6px 5px;
    font-size: 9px;
  }

  .top-counter {
    text-align: center;
  }

  .game-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .main-play-area {
    gap: 8px;
  }

  .spriteFrame {
    padding: 8px;
    border-width: 4px;
    border-radius: 16px;
    box-shadow:
      inset 0 0 0 4px #b9ae8e,
      3px 3px 0 #2b1d1d;
  }

  .spriteContainer {
    height: clamp(165px, 32dvh, 230px);
    border-width: 4px;
    box-shadow:
      inset 0 0 0 5px #5f6f3d,
      inset 0 0 20px rgba(40, 50, 20, 0.55);
  }

  #pokemonSprite {
    width: clamp(150px, 48vw, 205px);
    height: clamp(150px, 48vw, 205px);
  }

  .pokedexControls {
    min-height: 62px;
    padding: 8px;
    border-width: 4px;
    border-radius: 15px;
    grid-template-columns: 1fr 54px;
    gap: 8px;
    box-shadow:
      inset 0 0 0 4px rgba(255, 255, 255, 0.08),
      3px 3px 0 #2b1d1d;
  }

  .nameDisplay {
    min-height: 46px;
    padding: 7px 10px;
    border-width: 3px;
    font-size: 16px;
    box-shadow:
      inset 0 0 0 4px #5f6f3d,
      inset 0 0 12px rgba(40, 50, 20, 0.45);
  }

  #playCryBtn {
    width: 50px;
    height: 50px;
    border-width: 4px;
    font-size: 12px;
    box-shadow:
      inset 0 0 0 4px rgba(255, 255, 255, 0.14),
      3px 3px 0 #2b1d1d;
  }

  .inputContainer {
    position: sticky;
    bottom: 8px;
    z-index: 20;
    order: 2;
    margin-top: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    border: 4px solid #2b1d1d;
    border-radius: 16px;
    background: #c92f2f;
    box-shadow: 4px 4px 0 #2b1d1d;
  }

  .customInputGroup .input-group-text {
    min-width: 54px;
    border-width: 4px;
    font-size: 11px;
    box-shadow: 3px 3px 0 #2b1d1d;
  }

  .customInputGroup .form-control {
    min-height: 48px;
    border-width: 4px;
    font-size: 18px;
    box-shadow: 3px 3px 0 #2b1d1d;
  }

  #next-round-button {
    width: 100%;
    height: 50px;
    border-width: 4px;
    border-radius: 12px;
    font-size: 15px;
    box-shadow: 3px 4px 0 #2b1d1d;
  }

  .infoContainer {
    order: 3;
    gap: 8px;
  }

  .infoBox {
    padding: 10px;
    border-width: 4px;
    border-radius: 14px;
    box-shadow:
      inset 0 0 0 4px #5f6f3d,
      inset 0 0 14px rgba(40, 50, 20, 0.35);
  }

  .tagBox {
    min-height: auto;
    gap: 6px;
  }

  .typeTag,
  .abilityTag {
    padding: 6px 8px;
    border-width: 2px;
    font-size: 9px;
  }

  .typeIcon {
    width: 15px;
    height: 15px;
  }

  .descriptionBox {
    min-height: auto;
    max-height: 120px;
    overflow-y: auto;
    padding: 12px;
    font-size: 10px;
    line-height: 1.5;
    font-weight: bolder;
  }

  .modal-dialog {
    margin: 12px;
  }

  .end-modal {
    border-width: 4px;
    border-radius: 18px;
    box-shadow: 4px 4px 0 #2b1d1d;
  }

  .end-modal-header,
  .end-modal-body,
  .end-modal-footer {
    padding: 14px;
  }

  .end-modal-title {
    font-size: 20px;
    text-shadow: 2px 2px 0 #2b1d1d;
  }

  .final-percentage-box {
    padding: 14px;
    border-width: 4px;
  }

  .final-summary-box {
    padding: 14px;
    border-width: 4px;
  }

  .modal-game-button {
    min-height: 52px;
    font-size: 14px;
  }

  #answerInput::placeholder {
    font-size: 0.6rem;
  }

  .history-table {
    font-size: 0.75rem;
  }

  .history-table th,
  .history-table td {
    padding: 6px;
  }
}
