/* lombada: a página é iluminada pelo jogo do card. --glow e --tint mudam a cada desenho. */
:root {
  --night: #16121d;
  --panel: rgba(22, 18, 29, 0.8);
  --paper: #f4efe7;
  --muted: rgba(244, 239, 231, 0.62);
  --line: rgba(244, 239, 231, 0.12);
  --glow: #a27fd6;
  --tint: #1a1424;
  --xbox: #4cc26e;
  --psn: #7b93ff;
  --error: #ff8a7a;
  --warn: #e8c46a;
  --bar: 64px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--night);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse 80% 70% at 30% 35%, color-mix(in srgb, var(--tint) 85%, transparent), var(--night) 75%);
  color: var(--paper);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.8s;
}

/* A arte do jogo, desfocada, atrás de tudo. */
.ambient {
  position: fixed;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(90px) saturate(1.35);
  opacity: 0.3;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.8s;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 3px;
}

/* Barra */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(22, 18, 29, 0.55);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-stretch: 125%;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--paper);
  text-decoration: none;
}

.mark {
  width: 22px;
  height: 20px;
  fill: var(--glow);
  transition: fill 0.8s;
}

.bar-link {
  color: var(--muted);
  font-size: 15px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.bar-link:hover {
  color: var(--paper);
  text-decoration-color: currentColor;
}

/* Palco: o card em pé numa prateleira iluminada */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: calc(100dvh - var(--bar));
}

.stage {
  --room: calc(100dvh - var(--bar) - 230px);
  --fw: min(100%, 980px, calc(var(--room) * 1200 / 630));
  position: sticky;
  top: var(--bar);
  height: calc(100dvh - var(--bar));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 48px;
}

.stage:has(.frame[data-format="quadrado"]) {
  --fw: min(100%, 660px, var(--room));
}

.stage:has(.frame[data-format="stories"]) {
  --fw: min(100%, 440px, calc(var(--room) * 1080 / 1920));
}

.frame {
  position: relative;
  width: var(--fw);
  aspect-ratio: 1200 / 630;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(244, 239, 231, 0.04);
  box-shadow:
    0 34px 70px -24px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(244, 239, 231, 0.07);
}

.frame[data-format="quadrado"] {
  aspect-ratio: 1;
}

.frame[data-format="stories"] {
  aspect-ratio: 1080 / 1920;
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity 0.25s;
}

.frame:not([data-ready]) img {
  visibility: hidden;
}

.frame[data-ready] img {
  animation: settle 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.frame[data-ready][data-busy] img {
  opacity: 0.72;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(-18px) scale(0.985);
  }
}

.drawing {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(22, 18, 29, 0.8);
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.frame[data-busy] .drawing {
  opacity: 1;
}

.frame:not([data-ready]) .drawing {
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: none;
  font-size: 16px;
}

.shelf-ui {
  width: min(100%, calc(var(--fw) + 72px));
  height: 7px;
  margin-top: -1px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--glow) 70%, var(--paper)) 50%, transparent);
  box-shadow: 0 10px 50px 6px color-mix(in srgb, var(--glow) 32%, transparent);
  transition:
    width 0.4s,
    background 0.8s,
    box-shadow 0.8s;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 30px;
}

.actions button {
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(22, 18, 29, 0.5);
  font-weight: 600;
  min-width: 132px;
}

.actions button:hover:not(:disabled) {
  border-color: rgba(244, 239, 231, 0.4);
}

.actions .primary {
  background: var(--glow);
  border-color: transparent;
  color: var(--night);
  font-weight: 700;
  transition: background 0.8s;
}

.actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.caption {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* Trilho de controles */

.rail {
  background: var(--panel);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--line);
  padding: 40px 36px 72px;
}

.rail h1 {
  margin: 0 0 12px;
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(28px, 2.3vw, 34px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 38ch;
  color: var(--muted);
}

.profiles {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.legend,
legend {
  font-stretch: 75%;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--paper);
}

.field input,
.select select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 231, 0.05);
  font-size: 17px;
}

.field input::placeholder {
  color: rgba(244, 239, 231, 0.32);
}

.field[data-platform="xbox"] {
  --p: var(--xbox);
}

.field[data-platform="psn"] {
  --p: var(--psn);
}

.field[data-platform] input {
  border-left: 3px solid var(--p);
}

.fetch {
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--night);
  font-weight: 700;
  font-size: 16px;
}

.fetch:disabled {
  opacity: 0.6;
  cursor: progress;
}

.status {
  margin: 0;
  min-height: 1.5em;
  font-size: 14px;
  color: var(--muted);
}

.status[data-tone="error"] {
  color: var(--error);
}

.status[data-tone="warn"] {
  color: var(--warn);
}

.options {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.group {
  margin: 0;
  padding: 22px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.group:last-child {
  border-bottom: 0;
}

legend,
.legend {
  display: block;
  padding: 0;
  margin-bottom: 12px;
}

.hint {
  margin: -6px 0 12px;
  font-size: 14px;
  color: var(--muted);
}

/* Inputs escondidos dentro dos rótulos clicáveis */
.format input,
.segmented input,
.swatches input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

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

.format {
  position: relative;
  display: grid;
  justify-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.shape {
  width: var(--w);
  height: var(--h);
  margin: calc(32px - var(--h)) 0 10px;
  border: 2px solid var(--muted);
  border-radius: 3px;
}

.fname {
  font-weight: 600;
  font-size: 15px;
}

.fsize {
  font-size: 13px;
  color: var(--muted);
}

.format:has(input:checked) {
  border-color: var(--glow);
  background: color-mix(in srgb, var(--glow) 12%, transparent);
}

.format:has(input:checked) .shape {
  border-color: var(--glow);
  background: color-mix(in srgb, var(--glow) 35%, transparent);
}

.format:has(input:focus-visible),
.segmented label:has(input:focus-visible),
.swatches .swatch:has(input:focus-visible) {
  outline: 2px solid var(--glow);
  outline-offset: 2px;
}

.select {
  position: relative;
}

.select select {
  appearance: none;
  padding-right: 40px;
  font-size: 16px;
  background-color: rgba(244, 239, 231, 0.05);
}

.select select option {
  background: var(--night);
}

.select::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips:empty::before {
  content: "Os jogos aparecem aqui depois da busca.";
  font-size: 14px;
  color: var(--muted);
}

.chip {
  --p: var(--xbox);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip[data-platform="psn"] {
  --p: var(--psn);
}

.chip::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--p);
}

.chip[aria-pressed="true"] {
  color: var(--paper);
  background: rgba(244, 239, 231, 0.08);
  border-color: rgba(244, 239, 231, 0.22);
}

.chip[aria-pressed="false"] {
  text-decoration: line-through;
  text-decoration-color: rgba(244, 239, 231, 0.35);
}

.chip:disabled {
  color: var(--paper);
  border-color: var(--glow);
  cursor: default;
}

.segmented {
  display: flex;
  margin-top: 12px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 231, 0.04);
}

legend + .segmented {
  margin-top: 0;
}

.segmented label {
  position: relative;
  flex: 1;
  border-radius: 7px;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 8px 6px;
  border-radius: 7px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.segmented input:checked + span {
  background: rgba(244, 239, 231, 0.12);
  color: var(--paper);
  font-weight: 600;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.swatches .swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: pointer;
}

.swatches .swatch.auto {
  width: auto;
  display: inline-flex;
  align-items: center;
  padding: 0 12px 0 34px;
  border-radius: 999px;
  background: rgba(244, 239, 231, 0.07);
  font-size: 14px;
}

.swatches .swatch.auto::before {
  content: "";
  position: absolute;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: conic-gradient(#e0565b, #e8b04b, #4cc26e, #4fb6d8, #7b93ff, #c06ad8, #e0565b);
}

.swatches .swatch:has(input:checked) {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.toggle {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  cursor: pointer;
}

.toggle input {
  appearance: none;
  flex: none;
  position: relative;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: rgba(244, 239, 231, 0.16);
  cursor: pointer;
  transition: background 0.2s;
}

.toggle input::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.2s;
}

.toggle input:checked {
  background: var(--glow);
}

.toggle input:checked::before {
  transform: translateX(16px);
  background: var(--night);
}

.field.plain {
  padding-bottom: 0;
}

/* Histórico */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 32px 96px;
}

.page .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
}

.page h1 {
  margin: 0 0 14px;
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.page h1 .who {
  display: block;
  margin-top: 8px;
  font-stretch: 100%;
  font-weight: 600;
  font-size: 0.45em;
  letter-spacing: 0;
  color: var(--muted);
}

.page h2 {
  margin: 0 0 16px;
  font-stretch: 75%;
  font-weight: 700;
  font-size: 20px;
}

.page section {
  margin-top: 48px;
}

.note {
  color: var(--muted);
  font-size: 14px;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--muted);
  font-size: 13px;
  font-family: "Archivo", sans-serif;
}

.chart .strong {
  fill: var(--paper);
  font-weight: 600;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.list .game {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list .time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.list .when {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.list .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.plat-tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--p);
}

.empty-state {
  margin-top: 48px;
  padding: 28px;
  background: rgba(244, 239, 231, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 720px;
}

.empty-state p {
  margin: 0;
}

.empty-state .note {
  margin-top: 10px;
}

/* Telas menores: o card em cima, os controles embaixo */

@media (max-width: 960px) {
  .bar {
    padding: 0 16px;
  }

  .studio {
    grid-template-columns: 1fr;
  }

  .stage {
    position: static;
    height: auto;
    padding: 28px 16px 32px;
    --fw: 100%;
  }

  .stage:has(.frame[data-format="quadrado"]) {
    --fw: min(100%, 560px);
  }

  .stage:has(.frame[data-format="stories"]) {
    --fw: min(100%, 360px);
  }

  .shelf-ui {
    width: 100%;
  }

  .rail {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 32px 16px 64px;
  }

  .format {
    padding: 10px;
  }

  .page {
    padding: 20px 16px 64px;
  }

  .page .top {
    margin-bottom: 36px;
  }

  .cols {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
    transition: none !important;
  }
}
