/* Self-hosted fonts (SIL OFL) — no external CDNs */
@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #101117;
  --panel: #1c1e28;
  --panel-edge: #2d303e;
  --accent: #ff4655;
  --accent-text: #ff8089;
  /* lighter red for small text: contrast >= 4.5:1 */
  --text: #f2f3f8;
  --text-muted: #969aaa;
  --win: #56c57f;
  --loss: #e3545f;
  --font: "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -12%, rgba(255, 70, 85, 0.14), transparent 62%),
    linear-gradient(rgba(242, 243, 248, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 243, 248, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 44px 44px, 44px 44px, auto;
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem;
}

/* --- Accessibility helpers --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 12px 0;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

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

/* --- Hero --- */
.hero {
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 span {
  color: var(--accent);
}

.tagline {
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.9rem;
}

main {
  width: 100%;
  max-width: 1000px;
}

/* --- Game selector --- */
.games {
  margin-top: 2rem;
}

.game-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  max-width: 560px;
  margin: 0 auto;
}

.game-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.game-tile:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.game-tile.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(255, 70, 85, 0.25);
}

.game-tile:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.7);
}

.game-name {
  font-weight: 600;
  letter-spacing: 0.06em;
}

.game-state {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--win);
}

.game-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--text-muted);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

/* --- Form --- */
.card-form {
  margin-top: 1.6rem;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 24px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: start;
}

.field {
  border: none;
}

.field label,
.field legend {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input[type="text"] {
  width: 100%;
  min-width: 240px;
  padding: 0.7rem 0.9rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input[type="text"]:focus {
  border-color: var(--accent);
}

.field input[type="text"].is-valid {
  border-color: var(--win);
}

.field input[type="text"].is-invalid {
  border-color: var(--loss);
}

.hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Region pills (radios visually hidden but keyboard-accessible) */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pills input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.pills label {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pills input:checked+label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pills input:focus-visible+label {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

button[type="submit"] {
  padding: 0.75rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.12);
}

button[type="submit"]:active:not(:disabled) {
  transform: translateY(1px);
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Status --- */
.status {
  margin: 1.2rem auto 0;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  text-align: center;
  max-width: 640px;
  display: none;
}

.status.visible {
  display: block;
  animation: slideIn 0.25s ease-out;
}

.status.error {
  background: rgba(227, 84, 95, 0.14);
  color: #ff9aa2;
  border: 1px solid var(--loss);
}

.status.info {
  background: rgba(86, 197, 127, 0.12);
  color: #9fe0b6;
  border: 1px solid var(--win);
}

.status.warn {
  background: rgba(255, 70, 85, 0.1);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}

/* --- Preview + skeleton --- */
.preview {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.skeleton {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 1000 / 400;
  border-radius: 24px;
  background: linear-gradient(100deg, var(--panel) 40%, #262936 50%, var(--panel) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 24px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
}

.preview img.enter {
  animation: cardIn 0.45s ease-out;
}

.download-link {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
}

.download-link:hover {
  text-decoration: underline;
}

/* --- Showcase --- */
.showcase {
  margin-top: 3rem;
}

.showcase-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
}

.showcase-row img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s ease;
}

.showcase-row img:first-child {
  transform: rotate(-1.5deg);
}

.showcase-row img:last-child {
  transform: rotate(1.5deg);
}

.showcase-row img:hover {
  transform: rotate(0deg) scale(1.02);
}

/* --- Footer --- */
footer {
  margin-top: 3.5rem;
  max-width: 760px;
  text-align: center;
}

footer nav {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  margin-bottom: 0.9rem;
}

footer nav a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

footer nav a:hover {
  text-decoration: underline;
}

.legal {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.6;
}

/* --- 404 page --- */
.notfound {
  text-align: center;
  margin-top: 4rem;
}

.notfound h1 {
  font-size: 3rem;
}

.notfound p {
  color: var(--text-muted);
  margin: 1rem 0 1.6rem;
}

.notfound a {
  color: var(--accent-text);
  font-weight: 600;
}

/* --- Animations --- */
@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

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

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Responsive --- */
@media (max-width: 760px) {
  .card-form {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 2rem;
  }
}