:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1c2229;
  --panel-strong: #252d35;
  --text: #f6f1e8;
  --muted: #b8c1c8;
  --line: rgba(255, 255, 255, 0.12);
  --gold: #f3c55d;
  --green: #48d597;
  --red: #ef6b6b;
  --cyan: #68d8f8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(8, 11, 16, 0.72), rgba(9, 13, 17, 0.96)),
    radial-gradient(circle at 18% 16%, rgba(72, 213, 151, 0.32), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(243, 197, 93, 0.26), transparent 26%),
    linear-gradient(135deg, #151a21 0%, #172a27 42%, #2a2027 100%),
    var(--bg);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    repeating-linear-gradient(45deg, rgba(243, 197, 93, 0.055) 0 2px, transparent 2px 18px);
  background-size: 56px 56px, 56px 56px, 240px 240px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.18));
  animation: world-pan 22s linear infinite;
}

@keyframes world-pan {
  from {
    background-position: 0 0, 0 0, 0 0;
  }

  to {
    background-position: 56px 56px, 56px 56px, 240px 0;
  }
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.battle-strip,
.mode-row,
.score-grid,
.market-board,
.choice-row,
.guess-row,
.feed {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.tag,
.stat span,
.input-wrap span {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.35rem, 6vw, 5rem);
  line-height: 0.95;
}

.toolbar,
.choice-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.primary-button,
.ghost-button,
.mode-button,
.answer-button,
.player-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(28, 34, 41, 0.88);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease, background 160ms ease;
}

.icon-button:hover,
.primary-button:hover,
.ghost-button:hover,
.mode-button:hover,
.answer-button:hover,
.player-chip:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.icon-button {
  width: 46px;
  font-size: 1.35rem;
}

.primary-button,
.ghost-button {
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  border-color: rgba(243, 197, 93, 0.7);
  color: #24190a;
  background: var(--gold);
}

.battle-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.input-wrap {
  display: grid;
  gap: 6px;
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(14, 17, 22, 0.78);
  outline: none;
}

.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--cyan);
}

.input-wrap select {
  appearance: none;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mode-button {
  padding: 0 14px;
  font-weight: 950;
}

.mode-button.active {
  border-color: rgba(104, 216, 248, 0.75);
  color: #061921;
  background: var(--cyan);
}

.players {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.player-chip {
  min-height: 34px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(37, 45, 53, 0.92);
}

.player-chip.active {
  border-color: var(--green);
  color: #0d2218;
  background: var(--green);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.market-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 220ms ease, opacity 220ms ease, transform 220ms ease, margin-bottom 220ms ease;
}

.market-board.expanded {
  max-height: 520px;
  margin-bottom: 16px;
  opacity: 1;
  transform: translateY(0);
}

body[data-mode="market"] .market-board {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: none;
  opacity: 1;
  transform: none;
}

.board-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(14, 17, 22, 0.82);
  box-shadow: var(--shadow);
}

.board-column h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.board-column ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.board-column li {
  cursor: pointer;
  color: var(--muted);
  min-height: 34px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 0 10px;
  transition: color 140ms ease, transform 140ms ease;
}

.board-column li:hover {
  color: var(--text);
  transform: translateX(4px);
}

.board-column li::marker {
  color: var(--gold);
  font-weight: 900;
}

.board-column li span,
.board-column li strong {
  display: inline-block;
  vertical-align: top;
}

.board-column li span {
  max-width: calc(100% - 120px);
  overflow-wrap: anywhere;
}

.board-column li strong {
  float: right;
  color: var(--text);
}

.stat {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(28, 34, 41, 0.84);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.65rem;
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  animation: arena-in 260ms ease both;
}

.item-panel {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(28, 34, 41, 0.9);
  box-shadow: var(--shadow);
  transform-origin: center;
  transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.item-panel:hover {
  border-color: rgba(243, 197, 93, 0.42);
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 30px 86px rgba(0, 0, 0, 0.46);
}

.item-media {
  display: grid;
  place-items: center;
  min-height: 210px;
  background:
    linear-gradient(135deg, rgba(104, 216, 248, 0.17), rgba(243, 197, 93, 0.13)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04) 0 12px, transparent 12px 24px);
}

.item-media img {
  width: min(128px, 40vw);
  height: min(128px, 40vw);
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.45));
  animation: item-float 3s ease-in-out infinite;
}

.item-copy {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.item-copy h2 {
  min-height: 2.4em;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.item-copy p:not(.tag) {
  min-height: 2.8em;
  color: var(--muted);
  line-height: 1.45;
}

.price {
  width: fit-content;
  max-width: 100%;
  border-radius: 8px;
  padding: 10px 14px;
  color: #201606;
  background: var(--gold);
  font-size: clamp(1.25rem, 3vw, 2.05rem);
  overflow-wrap: anywhere;
}

.price-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.price-details span,
.price-details strong {
  display: block;
}

.price-details > span {
  grid-row: 1;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.price-details > strong {
  grid-row: 2;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.hidden-price {
  color: var(--text);
  background: var(--panel-strong);
}

.versus {
  position: absolute;
  z-index: 2;
  top: 45%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #0f1519;
  background: var(--cyan);
  font-weight: 950;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
  animation: vs-pop 1.6s ease-in-out infinite;
}

.choice-row {
  justify-content: center;
  margin: 18px 0;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  gap: 10px;
  justify-content: center;
  align-items: end;
  margin: 18px 0;
}

.guess-row[hidden],
.answer-button[hidden] {
  display: none;
}

.answer-button {
  width: min(260px, 46vw);
  min-height: 62px;
  font-size: 1.25rem;
  font-weight: 950;
}

.answer-button.higher {
  border-color: rgba(72, 213, 151, 0.65);
  background: linear-gradient(180deg, rgba(72, 213, 151, 0.96), rgba(35, 156, 103, 0.96));
  color: #07190f;
}

.answer-button.lower {
  border-color: rgba(239, 107, 107, 0.65);
  background: linear-gradient(180deg, rgba(239, 107, 107, 0.96), rgba(176, 61, 64, 0.96));
}

.answer-button:disabled,
.ghost-button:disabled,
.primary-button:disabled,
.mode-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.feed {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(14, 17, 22, 0.72);
}

.result-line {
  min-height: 28px;
  font-weight: 800;
}

.result-line.correct {
  color: var(--green);
  animation: result-pop 360ms ease both;
}

.result-line.wrong {
  color: var(--red);
  animation: result-pop 360ms ease both;
}

#historyList {
  display: grid;
  gap: 8px;
  max-height: 180px;
  margin: 12px 0 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
}

body[data-mode="guess"] .arena {
  grid-template-columns: minmax(260px, 620px);
  justify-content: center;
}

body[data-mode="guess"] .previous-panel,
body[data-mode="guess"] .versus {
  display: none;
}

body[data-mode="guess"] .challenge-panel {
  min-height: 500px;
}

body[data-mode="guess"] .challenge-panel .item-media {
  min-height: 260px;
}

body[data-mode="guess"] .choice-row {
  display: none;
}

body[data-mode="market"] .arena,
body[data-mode="market"] .choice-row,
body[data-mode="market"] .guess-row,
body[data-mode="market"] .feed {
  display: none;
}

body[data-mode="market"] .score-grid {
  margin-bottom: 14px;
}

@keyframes arena-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes item-float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}

@keyframes vs-pop {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@keyframes result-pop {
  from {
    transform: translateY(8px);
  }

  to {
    transform: translateY(0);
  }
}

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

  .topbar,
  .battle-strip,
  .guess-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .mode-row,
  .choice-row {
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .mode-button,
  .answer-button {
    flex: 1;
  }

  .score-grid,
  .market-board,
  .arena {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-row {
    grid-template-columns: 1fr;
  }

  .market-board.expanded {
    max-height: 760px;
  }

  body[data-mode="market"] .market-board {
    grid-template-columns: 1fr;
  }

  body[data-mode="guess"] .challenge-panel {
    min-height: 390px;
  }

  .price-details {
    grid-template-columns: 1fr;
  }

  .price-details > span,
  .price-details > strong {
    grid-row: auto;
  }

  .stat {
    min-height: 64px;
  }

  .item-panel {
    min-height: 340px;
  }

  .item-media {
    min-height: 150px;
  }

  .versus {
    top: 50%;
    width: 52px;
    height: 52px;
  }
}
