/*
 * Démo GameCoin — styles. Même identité que le site public (nuit indigo, rose néon, bleu électrique, or pour l'argent,
 * verre dépoli), en plus « jeu » : arène, barre de vie, HUD de solde. Page statique, sans framework.
 * Mobile d'abord (375 px), contrastes AA, focus visible, mouvement réduit respecté, repli sans `backdrop-filter`.
 */

@font-face {
  font-family: "Chakra Petch";
  src: url("fonts/chakra-petch-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0718;
  --fg: #f4f1ff;
  --muted: #bdb7de;
  --card: rgb(22 14 50 / 0.9);
  --card-line: rgb(255 255 255 / 0.16);
  --soft: rgb(255 255 255 / 0.06);
  --pink: #ff4fc3;
  --pink-text: #ff8ae0;
  --violet: #9b6bff;
  --blue: #3da5ff;
  --cyan: #35e0ff;
  --gold: #ffc94d;
  --ok-bg: #0c3a2c;
  --ok-border: #6ff2bd;
  --ok-fg: #d2ffee;
  --err-bg: #4a1020;
  --err-border: #ff8da1;
  --err-fg: #ffdbe2;
  --info-bg: #241854;
  --warn-bg: rgb(70 48 6 / 0.9);
  --warn-border: #ffc94d;
  --warn-fg: #ffe8a6;
  --radius: 16px;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Chakra Petch", "Geist", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(44rem 28rem at 4% -4rem, rgb(255 79 195 / 0.2), transparent 70%),
    radial-gradient(40rem 26rem at 100% 2rem, rgb(61 165 255 / 0.18), transparent 70%),
    radial-gradient(40rem 30rem at -6% 55%, rgb(124 77 255 / 0.14), transparent 70%),
    radial-gradient(44rem 30rem at 50% 105%, rgb(255 79 195 / 0.16), transparent 70%);
  background-repeat: no-repeat;
  color: var(--fg);
  font: 16px/1.55 var(--font);
}

/* Horizon synthwave au pied de la page (CSS pur, fixe, sans animation) : grille en perspective, très discrète. */
body::after {
  content: "";
  position: fixed;
  left: -40%;
  right: -40%;
  bottom: 0;
  height: 11rem;
  z-index: -1;
  pointer-events: none;
  transform-origin: 50% 100%;
  transform: perspective(14rem) rotateX(58deg);
  background-image:
    linear-gradient(rgb(255 79 195 / 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgb(61 165 255 / 0.45) 1px, transparent 1px);
  background-size: 3rem 3rem;
  mask-image: linear-gradient(0deg, #000 0%, transparent 85%);
  -webkit-mask-image: linear-gradient(0deg, #000 0%, transparent 85%);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.005em;
}

p {
  margin: 0;
}

a {
  color: var(--pink-text);
  text-underline-offset: 3px;
}
a:hover {
  color: #ffb3ee;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgb(53 224 255 / 0.1);
  color: #b8f1ff;
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

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

.skip {
  position: absolute;
  left: 8px;
  top: -80px;
  background: var(--pink);
  color: #14041f;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 10px;
  z-index: 20;
}
.skip:focus {
  top: 8px;
  color: #14041f;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* En-tête et bandeau de test */

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  background: rgb(11 7 24 / 0.94);
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
}
.top::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pink) 25%, var(--blue) 75%, transparent);
  opacity: 0.8;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--fg);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}
.brand-mark {
  flex: none;
  filter: drop-shadow(0 0 8px rgb(255 79 195 / 0.55));
}
.brand b {
  background: linear-gradient(95deg, #ff7ad9, #b99aff 55%, #5cd6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
}
.top-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}
.top-link:hover {
  background: var(--soft);
  color: var(--fg);
}

.banner {
  padding: 10px 16px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn-fg);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 16px;
}

/* Boutons et champs */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff6ed2, #ff3da6);
  color: #14041f;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.5),
    0 0 20px rgb(255 79 195 / 0.5),
    0 10px 24px -12px rgb(255 61 166 / 0.8);
  transition:
    transform 0.15s,
    box-shadow 0.2s,
    filter 0.2s;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.6),
    0 0 30px rgb(255 79 195 / 0.75),
    0 14px 28px -12px rgb(255 61 166 / 0.9);
  color: #14041f;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.6);
}
.btn.secondary,
#items .btn {
  background: rgb(53 224 255 / 0.1);
  color: #e6fbff;
  border-color: rgb(53 224 255 / 0.7);
  box-shadow:
    inset 0 0 14px rgb(53 224 255 / 0.14),
    0 0 16px rgb(53 224 255 / 0.25);
}
.btn.secondary:hover:not(:disabled),
#items .btn:hover:not(:disabled) {
  background: rgb(53 224 255 / 0.2);
  color: #e6fbff;
  box-shadow:
    inset 0 0 18px rgb(53 224 255 / 0.2),
    0 0 26px rgb(53 224 255 / 0.5);
}
.btn.small {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.95rem;
}
.btn.block {
  width: 100%;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}
input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #8a83bd;
  border-radius: 12px;
  background: rgb(8 5 20 / 0.7);
  color: var(--fg);
  font: inherit;
}
input::placeholder {
  color: #a39dc8;
}

/* Cartes : verre dépoli (flou léger dès 900 px seulement ; repli quasi opaque sans `backdrop-filter`) */

.card {
  position: relative;
  background:
    linear-gradient(150deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.02) 55%),
    var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.24),
    inset 0 -1px 0 rgb(0 0 0 / 0.3),
    0 22px 50px -26px rgb(0 0 0 / 0.85);
}
@media (min-width: 880px) {
  @supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .card {
      background:
        linear-gradient(150deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.02) 55%),
        rgb(22 14 50 / 0.52);
      -webkit-backdrop-filter: blur(12px) saturate(1.4);
      backdrop-filter: blur(12px) saturate(1.4);
    }
  }
}
@media (prefers-reduced-transparency: reduce) {
  .card {
    background: rgb(22 14 50 / 0.97);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
.card > h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.card .hint {
  color: var(--muted);
  font-size: 0.92rem;
}
.stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.cols {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

/* Messages : collés en haut pour rester visibles quand on achète plus bas dans la page */

.messages {
  position: sticky;
  top: 8px;
  z-index: 5;
}

.message {
  margin-bottom: 16px;
  box-shadow: 0 10px 30px -8px rgb(0 0 0 / 0.7);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-line);
  background: #160e32;
  color: var(--fg);
}
.message.ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-fg);
}
.message.error {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-fg);
}
.message.info {
  background: var(--info-bg);
  border-color: var(--violet);
}
.message:empty {
  /* Reste dans l'arbre d'accessibilité (région live) sans prendre de place. */
  margin: 0;
  padding: 0;
  border: 0;
  height: 0;
  overflow: hidden;
  box-shadow: none;
}

/* Écran sans clé / erreur de démarrage */

.intro {
  display: grid;
  gap: 16px;
  max-width: 640px;
  margin: 24px auto;
  padding: 24px 20px;
}
.intro h1 {
  font-size: 1.9rem;
  background: linear-gradient(95deg, #ff7ad9, #b99aff 50%, #5cd6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 0.08em;
}
.intro ol {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 6px;
}
.intro form {
  display: grid;
  gap: 8px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Solde : HUD, une pièce par monnaie */

.wallet-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.wallet-list li {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 12px 14px 12px 56px;
  border: 1px solid rgb(255 201 77 / 0.35);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgb(255 201 77 / 0.1), rgb(255 79 195 / 0.06)),
    rgb(8 5 20 / 0.55);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12);
}
.wallet-list li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff6c9 0 14%, transparent 15%),
    radial-gradient(circle at 50% 50%, transparent 56%, rgb(176 109 0 / 0.55) 58% 64%, transparent 66%),
    linear-gradient(145deg, #ffe38a, #ffc94d 45%, #e8920c);
  box-shadow:
    inset 0 -2px 3px rgb(150 80 0 / 0.5),
    inset 0 2px 2px rgb(255 255 255 / 0.55),
    0 0 14px rgb(255 201 77 / 0.55);
}
.wallet-list .name {
  font-weight: 600;
}
.wallet-list .total {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff1b8, #ffc94d 55%, #f0a21b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.refresh-line {
  margin: 12px 0 8px;
}

.wallet-list .detail {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Jeu : arène avec sol en grille, monstre néon, barre de vie */

.arena {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 16px 12px 18px;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(22rem 14rem at 50% 38%, rgb(255 79 195 / 0.22), transparent 70%),
    linear-gradient(180deg, rgb(26 12 62 / 0.9), rgb(11 7 24 / 0.95));
}
.arena::after {
  content: "";
  position: absolute;
  left: -30%;
  right: -30%;
  bottom: 0;
  height: 7rem;
  z-index: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
  transform: perspective(10rem) rotateX(56deg);
  background-image:
    linear-gradient(rgb(255 79 195 / 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgb(61 165 255 / 0.5) 1px, transparent 1px);
  background-size: 2.25rem 2.25rem;
  mask-image: linear-gradient(0deg, #000, transparent 90%);
  -webkit-mask-image: linear-gradient(0deg, #000, transparent 90%);
}
.arena > * {
  position: relative;
  z-index: 1;
}
.monster-name {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.monster-svg {
  width: min(180px, 55vw);
  height: auto;
  filter: drop-shadow(0 0 20px rgb(255 79 195 / 0.6));
}
.monster-body {
  fill: url(#monster-fill);
}
.monster-eye {
  fill: #ffffff;
}
.monster-pupil,
.monster-mouth {
  fill: #14041f;
}
.hit .monster-svg {
  animation: shake 0.18s;
}
.boosted .monster-body {
  fill: url(#monster-fill-boost);
}
.boosted .monster-svg {
  filter: drop-shadow(0 0 24px rgb(255 201 77 / 0.75));
}
@keyframes shake {
  25% {
    transform: translateX(-6px) rotate(-3deg);
  }
  75% {
    transform: translateX(6px) rotate(3deg);
  }
}

.hp {
  width: min(320px, 100%);
}
.hp progress {
  display: block;
  width: 100%;
  height: 18px;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 999px;
  overflow: hidden;
  background: rgb(8 5 20 / 0.8);
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 0 14px rgb(255 79 195 / 0.3);
}
.hp progress::-webkit-progress-bar {
  background: rgb(8 5 20 / 0.8);
}
.hp progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3da6, #ff7ad9 60%, #ffc4f1);
  transition: width 0.2s;
}
.hp progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3da6, #ff7ad9 60%, #ffc4f1);
}
.hp-text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tap {
  width: min(320px, 100%);
  min-height: 60px;
  font-family: var(--display);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 8px 0 0;
}
.stats div {
  padding: 8px 10px;
  background: var(--soft);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 12px;
}
.stats dt {
  font-size: 0.82rem;
  color: var(--muted);
}
.stats dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rule {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--pink);
  background: rgb(255 79 195 / 0.08);
  border-radius: 0 12px 12px 0;
  font-size: 0.95rem;
}
.rule strong {
  color: var(--pink-text);
}

.finish {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--card-line);
  display: grid;
  gap: 8px;
}
.finish h3 {
  font-size: 1.05rem;
}
.finish .row {
  align-items: end;
}
.finish .field {
  flex: 1 1 140px;
  display: grid;
  gap: 4px;
}

/* Boutiques et inventaire */

.list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.product {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: 14px;
  background: rgb(255 255 255 / 0.04);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.1);
}
.product-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.product-head h3 {
  font-size: 1.05rem;
}
.tag {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid rgb(255 79 195 / 0.6);
  border-radius: 999px;
  background: rgb(255 79 195 / 0.14);
  color: #ffc4f1;
  font-size: 0.78rem;
  font-weight: 700;
}
.product .desc {
  color: var(--muted);
  font-size: 0.92rem;
}
.product .gives {
  font-size: 0.95rem;
}
.empty {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed rgb(255 255 255 / 0.4);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}
.empty strong {
  color: var(--fg);
}

.footer {
  margin-top: 24px;
  padding: 16px 0 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

@media (min-width: 880px) {
  main {
    padding: 24px;
  }
  .cols {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    align-items: start;
  }
}

@media (forced-colors: active) {
  .card,
  .product,
  .btn,
  .tag,
  .message {
    border: 1px solid CanvasText;
  }
  .brand b,
  .intro h1,
  .wallet-list .total {
    background: none;
    color: CanvasText;
  }
  body::after {
    display: none;
  }
}

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