:root {
  --ink: #17233f;
  --muted: #5c6882;
  --paper: #fff8e6;
  --surface: #ffffff;
  --line: #263454;
  --red: #e83442;
  --red-dark: #b91827;
  --blue: #2468b2;
  --blue-dark: #153d7a;
  --yellow: #ffd84d;
  --green: #2fb36d;
  --partial: #ffb72c;
  --bad: #d9423d;
  --shadow: 0 18px 38px rgba(21, 33, 63, 0.22);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 216, 77, 0.7) 0 110px, transparent 112px),
    linear-gradient(140deg, #d9212e 0 34%, #f4f7ff 34% 39%, #245aa7 39% 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.arena-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.pokeball {
  position: absolute;
  width: 300px;
  aspect-ratio: 1;
  border: 18px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  opacity: 0.65;
}

.pokeball::before {
  content: "";
  position: absolute;
  left: -18px;
  right: -18px;
  top: calc(50% - 9px);
  height: 18px;
  background: rgba(255, 255, 255, 0.28);
}

.pokeball::after {
  content: "";
  position: absolute;
  inset: 96px;
  border: 18px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.pokeball-a {
  right: -80px;
  top: 80px;
}

.pokeball-b {
  width: 210px;
  left: -70px;
  bottom: 40px;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero {
  min-height: 210px;
  display: flex;
  align-items: center;
  gap: 24px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
}

.brand-mark {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: linear-gradient(#f23846 0 48%, #1b2543 48% 54%, #fff 54%);
  border: 8px solid #1b2543;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-mark span {
  width: 34px;
  height: 34px;
  border: 7px solid #1b2543;
  border-radius: 50%;
  background: #fff;
}

.brand-copy {
  max-width: 690px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loading-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
}

.loader-ball {
  width: 54px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 5px solid var(--line);
  background: linear-gradient(var(--red) 0 47%, var(--line) 47% 55%, #fff 55%);
  animation: spin 1.1s linear infinite;
  flex: 0 0 auto;
}

.loader-ball.small {
  width: 30px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.play-panel {
  padding: 18px;
}

.control-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: linear-gradient(90deg, #1e5aa8, #2c78d0);
  color: #fff;
  border-radius: 6px;
  border: 3px solid var(--line);
}

.control-bar .eyebrow {
  color: var(--yellow);
}

.control-bar p:not(.eyebrow) {
  color: #e8f1ff;
}

.bar-actions,
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.volume-control,
.mute-control {
  min-height: 42px;
  display: grid;
  grid-template-columns: 74px minmax(130px, 1fr) 48px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--blue-dark);
  font-weight: 900;
}

.mute-control {
  grid-template-columns: auto 1fr;
}

.volume-control span,
.volume-control strong,
.mute-control span {
  font-size: 0.88rem;
}

.volume-control input {
  accent-color: var(--yellow);
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  padding: 0 16px;
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
  transform: translateY(0);
}

.primary:active,
.secondary:active,
.ghost:active {
  box-shadow: 0 1px 0 var(--line);
  transform: translateY(3px);
}

.primary {
  background: var(--yellow);
  color: var(--ink);
}

.secondary {
  background: #fff;
  color: var(--blue-dark);
}

.ghost {
  min-height: 34px;
  padding: 0 12px;
  background: #eef4ff;
  color: var(--ink);
  box-shadow: none;
}

.options-menu {
  margin: 14px 0;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  display: grid;
  gap: 14px;
}

.option-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 2px solid rgba(38, 52, 84, 0.45);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
}

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.generation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 9px;
}

.generation-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 900;
}

.generation-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.guess-form {
  display: grid;
  gap: 8px;
  padding: 18px 4px 8px;
}

.guess-form label {
  color: var(--blue-dark);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.autocomplete {
  position: relative;
}

input[type="text"] {
  width: 100%;
  min-height: 54px;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 216, 77, 0.38);
}

.suggestions {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 310px;
  overflow-y: auto;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.suggestion {
  width: 100%;
  min-height: 40px;
  display: block;
  padding: 8px 12px;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid #d8dfef;
  box-shadow: none;
}

.suggestion:hover,
.suggestion.active {
  background: var(--yellow);
}

.error {
  min-height: 20px;
  color: var(--red-dark);
  font-weight: 900;
}

.result-message {
  min-height: 28px;
  color: var(--blue-dark);
  font-size: 1.08rem;
  font-weight: 900;
  padding: 0 4px;
}

.clue-summary {
  display: grid;
  gap: 12px;
  margin: 12px 0 8px;
  padding: 12px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(32, 91, 164, 0.96), rgba(22, 59, 116, 0.96));
  color: #fff;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-head .eyebrow {
  color: var(--yellow);
}

.summary-count {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 9px;
}

.summary-empty {
  margin: 0;
  color: #e8f1ff;
  font-weight: 800;
}

.summary-item {
  position: relative;
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px;
  border: 4px solid #0e1424;
  border-radius: 7px;
  background: #eef2f8;
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 4px 0 #0e1424;
}

.summary-item.correct {
  background: #42e789;
}

.summary-item.partial {
  background: #f4dc43;
}

.summary-item.hint {
  background: #f35b43;
}

.summary-label,
.summary-hint {
  font-size: 0.76rem;
  color: rgba(23, 35, 63, 0.76);
  font-weight: 900;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.summary-item strong {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 1rem;
}

.summary-item.direction-up::before,
.summary-item.direction-down::before {
  content: "";
  position: absolute;
  inset: 8px 14px;
  background: rgba(90, 37, 22, 0.42);
  z-index: 0;
}

.summary-item.direction-up::before {
  clip-path: polygon(50% 0, 96% 42%, 72% 42%, 72% 100%, 28% 100%, 28% 42%, 4% 42%);
}

.summary-item.direction-down::before {
  clip-path: polygon(28% 0, 72% 0, 72% 58%, 96% 58%, 50% 100%, 4% 58%, 28% 58%);
}

.guesses {
  padding-top: 8px;
  overflow-x: auto;
  scrollbar-color: var(--yellow) var(--line);
}

.guess-table {
  min-width: 994px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(87, 172, 218, 0.88), rgba(231, 245, 255, 0.52) 45%, rgba(76, 142, 83, 0.22)),
    rgba(255, 255, 255, 0.72);
}

.guess-table-header,
.guess-table-row {
  display: grid;
  grid-template-columns: 176px 64px 88px 88px 104px 108px 82px 92px 92px;
  gap: 8px;
}

.guess-table-header {
  align-items: end;
  padding-bottom: 4px;
}

.guess-head-cell {
  min-height: 44px;
  display: grid;
  align-items: end;
  color: #fff;
  font-size: 1.02rem;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  text-align: center;
}

.guess-head-cell::after {
  content: "";
  display: block;
  width: 86%;
  height: 7px;
  margin: 8px auto 0;
  background: #fff;
}

.guess-table-body {
  display: grid;
  gap: 10px;
}

.sprite-frame {
  width: 74px;
  height: 74px;
  border-radius: 6px;
  border: 4px solid #0e1424;
  background: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.sprite-frame img {
  width: 66px;
  height: 66px;
  object-fit: contain;
}

.guess-cell {
  position: relative;
  min-height: 96px;
  padding: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 4px solid #0e1424;
  border-radius: 8px;
  box-shadow: 0 5px 0 #0e1424;
  overflow: hidden;
  opacity: 0;
  filter: saturate(0.2) brightness(1.25);
  transform: perspective(700px) rotateY(84deg) scale(0.78);
  transition:
    opacity 260ms ease var(--delay),
    filter 420ms ease var(--delay),
    transform 560ms cubic-bezier(0.17, 0.84, 0.44, 1.25) var(--delay);
}

.guess-cell.revealed {
  opacity: 1;
  filter: saturate(1) brightness(1);
  transform: perspective(700px) rotateY(0deg) scale(1);
  animation: reveal-pop 620ms ease var(--delay) both;
}

@keyframes reveal-pop {
  0% {
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  }
  55% {
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.18);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

.guess-cell.neutral {
  background: #fff;
}

.pokemon-cell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  place-items: center start;
  text-align: left;
}

.pokemon-cell strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.pokemon-cell span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.comparison-cell.correct,
.pokemon-cell.correct {
  background: #42e789;
  color: #072c17;
}

.comparison-cell.incorrect {
  background: #f35b43;
  color: #111827;
}

.comparison-cell.partial {
  background: #f4dc43;
  color: #3b2400;
}

.comparison-cell.unknown {
  background: #c9d2df;
  color: #31405a;
}

.comparison-cell.direction-up::before,
.comparison-cell.direction-down::before {
  content: "";
  position: absolute;
  inset: 8px 13px;
  background: rgba(90, 37, 22, 0.42);
  z-index: 0;
}

.comparison-cell.direction-up::before {
  clip-path: polygon(50% 0, 96% 42%, 72% 42%, 72% 100%, 28% 100%, 28% 42%, 4% 42%);
}

.comparison-cell.direction-down::before {
  clip-path: polygon(28% 0, 72% 0, 72% 58%, 96% 58%, 50% 100%, 4% 58%, 28% 58%);
}

.api-loader {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--blue-dark);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.comparison-cell .value {
  position: relative;
  z-index: 1;
  font-size: 0.96rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 18px, 1120px);
    padding-top: 18px;
  }

  .hero {
    min-height: 180px;
    align-items: flex-start;
  }

  .brand-mark {
    width: 76px;
    height: 76px;
    border-width: 6px;
  }

  .brand-mark span {
    width: 24px;
    height: 24px;
    border-width: 5px;
  }

  .control-bar,
  .menu-head,
  .guess-row {
    display: grid;
  }

  .bar-actions {
    width: 100%;
  }

  .bar-actions button,
  .volume-control,
  .mute-control,
  .guess-row button {
    width: 100%;
  }

  .volume-control {
    grid-template-columns: auto 1fr 44px;
  }

  .guess-table {
    min-width: 850px;
  }

  .guess-table-header,
  .guess-table-row {
    grid-template-columns: 148px 58px 84px 84px 94px 98px 76px 86px 86px;
    gap: 6px;
  }

  .guess-cell {
    min-height: 86px;
    padding: 7px;
    border-width: 3px;
  }

  .sprite-frame {
    width: 58px;
    height: 58px;
    border-width: 3px;
  }

  .sprite-frame img {
    width: 52px;
    height: 52px;
  }

  .comparison-cell .value {
    font-size: 0.92rem;
  }
}
