:root {
  color-scheme: dark;
  font: 16px/1.4 system-ui, sans-serif;
  --night: #100d0b;
  --panel: #201813;
  --kaolin: #f0ece1;
  --muted: #b9aa96;
  --gold: #efb968;
  --stroke: #ffffff20;
  background: var(--night);
  color: var(--kaolin);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; scroll-behavior: smooth; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
.shell { width: min(1180px, calc(100% - 88px)); margin-inline: auto; }

#home {
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
}

.hero {
  position: relative;
  isolation: isolate;
  background-color: #24150e;
  background-image:
    linear-gradient(90deg, #120d09 0%, #120d09b0 35%, transparent 75%),
    linear-gradient(0deg, var(--night) 0%, #100d0b18 38%, #0b080567 100%),
    url("../assets/circle-cover.webp");
  background-size: cover;
  background-position: center, center, center 52%;
}

.site-header {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--stroke);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.wordmark strong { color: var(--gold); }
.seal { width: 28px; height: 28px; border: 1px dashed var(--gold); border-radius: 50%; position: relative; margin-right: 3px; }
.seal::after { content: ""; position: absolute; inset: 7px; border: 1px solid var(--gold); border-radius: inherit; }

.hero-copy { padding-block: clamp(20px, 5vh, 68px) clamp(18px, 4vh, 56px); }
.hero h1 {
  margin: 0;
  width: max-content;
  max-width: 100%;
  font-family: "Arial Black", Impact, system-ui, sans-serif;
  font-size: clamp(3.8rem, min(9vw, 12vh), 8.75rem);
  font-weight: 1000;
  letter-spacing: -.079em;
  line-height: .78;
  text-shadow: 0 5px 35px #100a08aa;
}
.hero h1 span { display: block; color: var(--gold); margin-top: .08em; }
.hero-copy p { margin: clamp(14px, 2.5vh, 26px) 0 10px; color: #e5d7c2; font-size: clamp(1rem, 2vw, 1.25rem); font-weight: 560; }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.avatar-card {
  display: inline-grid;
  place-items: center;
  width: 51px;
  min-height: 49px;
  padding: 2px;
  border: 1px solid #caab8861;
  border-radius: 6px;
  background: #19120dee;
  color: #f0e2ce;
  font-size: .78rem;
  font-weight: 750;
}
.avatar-card img { width: 34px; height: 42px; object-fit: contain; filter: drop-shadow(0 2px 3px #0a0603); }
.avatar-card:hover { background: #362415; }
.avatar-card[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #372619f5; }
.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 23px;
  min-height: 46px;
  padding-inline: 18px;
  border-radius: 5px;
  color: #201306;
  background: var(--gold);
  font-size: .86rem;
  font-weight: 850;
}
.hero-link:hover { background: #ffe0aa; }

.selection {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: clamp(16px, 3vw, 40px);
  padding-block: 16px 21px;
  scroll-margin-top: max(12px, env(safe-area-inset-top));
}
.selection-section { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.selection h2 { margin: 0; font-size: clamp(1.15rem, 2.2vw, 1.6rem); line-height: 1.2; letter-spacing: -.04em; }
.voduns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.vodun-card {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 82px;
  padding: 6px 3px;
  background: #191410;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  text-align: center;
}
.vodun-name { font-size: clamp(.77rem, 2.4vw, .95rem); line-height: 1.15; font-weight: 780; }
.vodun-card:enabled:hover { background: #292019; }
.vodun-card:disabled .vodun-name { color: var(--muted); }
.vodun-card[aria-pressed="true"] { border-color: #d39a53; background: #2b2015; }
.vodun-icon { position: relative; width: 36px; height: 36px; border-radius: 5px; background-color: #2a2119; }
.vodun-icon--raffia { background: #342117 url("../zangbeto.webp") center / 90% auto no-repeat; }
.vodun-icon--cloth { background: #342123 url("../egungun.webp") center / auto 96% no-repeat; }
.vodun-icon--water { background: #163239 url("../mami-wata.webp") center / auto 96% no-repeat; }
.vodun-icon--lightning { display: grid; place-items: center; background: radial-gradient(ellipse, #3d3655, #211f2c); }
.vodun-icon--lightning::before {
  content: "";
  width: 55%;
  height: 75%;
  background: linear-gradient(#efe3ff, #a093cd);
  clip-path: polygon(58% 0, 97% 0, 63% 39%, 91% 39%, 16% 100%, 41% 55%, 9% 55%);
}
.card-status { font-size: .67rem; line-height: 1.15; color: var(--muted); white-space: nowrap; }
.selection-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border: 1px solid #d7a66b; border-radius: 50%; }
[aria-pressed="true"] .selection-dot { background: var(--gold); box-shadow: 0 0 11px #efb96870; }

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 7px;
  min-height: 172px;
  min-width: 0;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background-color: #362519;
  background-image: var(--cover-shade, linear-gradient(0deg, #100b08 2%, #130c08c9 30%, #1e130d13 88%)), var(--cover);
  background-size: cover;
  background-position: center;
  text-align: left;
  transition: border-color .2s, transform .2s;
}
.mode-card--arena { --cover: url("../assets/circle-cover.webp"); background-position: center, 76% 41%; }
.mode-card--village { --cover: url("../assets/village-cover.webp"); }
#defi[data-vodun="mami-wata"] { --cover-shade: linear-gradient(0deg, #0a141e 2%, #0b1b25d9 30%, #0a37455e 88%); }
#defi[data-vodun="heviosso"] { --cover-shade: linear-gradient(0deg, #111020 2%, #161630d9 30%, #34365e6b 88%); }
.mode-card:not(:disabled):hover { border-color: var(--gold); transform: translateY(-3px); }
.mode-card:disabled { filter: saturate(.48); opacity: .57; }
.mode-card-content { display: grid; gap: 2px; }
.mode-name { font-size: clamp(1.12rem, 2vw, 1.62rem); font-weight: 850; letter-spacing: -.035em; }
.mode-detail { font-size: .76rem; font-weight: 540; color: #eadac5; }
.launch-icon { flex: 0 0 33px; display: grid; place-items: center; height: 33px; border: 1px solid #e7c79a6a; border-radius: 4px; color: var(--gold); }
.mode-status { color: var(--muted); font-size: .85rem; }
.home-footer { padding-block: 12px 16px; border-top: 1px solid var(--stroke); font-size: .78rem; color: var(--muted); }

#play-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  visibility: hidden;
  background: radial-gradient(ellipse at center, #251912, #100d0b 70%);
}
body.is-playing { overflow: hidden; }
.is-playing #play-screen { visibility: visible; }
.play-top {
  position: relative;
  display: flex;
  width: min(100%, 1080px);
  flex: 0 0 auto;
  align-items: center;
  gap: clamp(6px, 1.7vw, 20px);
  min-height: 52px;
  padding: env(safe-area-inset-top) clamp(9px, 2vw, 20px) 0;
  border-bottom: 1px solid var(--stroke);
  background: #100d0b;
}
.play-top button {
  flex: none;
  min-height: 42px;
  border: 0;
  padding: 3px 5px;
  background: none;
  font-weight: 750;
  font-size: clamp(.68rem, 2.6vw, .85rem);
}
.play-top button span { color: var(--gold); margin-right: 3px; }
.play-actions { display: flex; flex: none; align-items: center; gap: clamp(2px, 1vw, 8px); }
.play-top .hud-icon { display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0; }
.play-top .hud-icon span { position: relative; display: block; width: 20px; height: 20px; margin: 0; color: var(--gold); }
.sound-icon::before, .sound-icon::after, .pause-icon::before { position: absolute; content: ""; }
.sound-icon::before { inset: 3px 9px 3px 1px; background: currentColor; clip-path: polygon(0 32%, 36% 32%, 100% 0, 100% 100%, 36% 68%, 0 68%); }
.sound-icon::after { inset: 4px 1px 4px 9px; border-right: 2px solid currentColor; border-radius: 50%; }
#play-sound[aria-pressed="false"] .sound-icon::after { inset: 3px 2px 3px 15px; border-radius: 0; transform: rotate(35deg); }
.pause-icon::before { inset: 3px 4px; background: linear-gradient(90deg, currentColor 0 36%, transparent 36% 65%, currentColor 65%); }
#play-pause[aria-pressed="true"] .pause-icon::before { inset: 2px 4px 2px 6px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
#play-resume { margin-top: 18px; color: #201306; background: var(--gold); }
.play-context { flex: 1 1 auto; min-width: 0; display: grid; align-content: center; }
#play-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: clamp(.59rem, 2.2vw, .73rem); font-weight: 750; text-transform: uppercase; }
#play-objective { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: clamp(.66rem, 2.4vw, .92rem); font-weight: 720; line-height: 1.2; }
#play-time { flex: none; min-width: 3.25ch; text-align: end; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 850; font-size: clamp(1.18rem, 4vw, 1.65rem); }
#play-progress {
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--gold);
  transform-origin: left;
  transform: scaleX(var(--time-left, 1));
  pointer-events: none;
}
@media (max-width: 420px) {
  .play-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0 4px;
    padding-bottom: 5px;
  }
  .play-context { display: contents; }
  #play-objective { grid-column: 1 / -1; grid-row: 2; min-height: 1.2em; font-size: .75rem; }
}

.play-stage { position: relative; display: flex; flex: 1 1 auto; min-height: 0; width: min(100%, 1080px); }
#game { width: 100%; height: 100%; touch-action: none; user-select: none; outline: none; }
#game canvas { display: block; touch-action: none; }
.play-result { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; background: #100d0bcf; }
#play-screen[data-mode="arena"] .play-result {
  background: linear-gradient(#100d0b99, #100d0bdc), url("../assets/circle-cover.webp") center / cover;
}
#play-screen[data-mode="village"] .play-result {
  background: linear-gradient(#100d0b99, #100d0bdc), url("../assets/village-cover.webp") center / cover;
}
#play-screen[data-vodun="mami-wata"][data-mode="arena"] .play-result {
  background: linear-gradient(#061b2499, #0a141edc), url("../assets/mami-arena.webp") center / cover;
}
#play-screen[data-vodun="mami-wata"][data-mode="village"] .play-result {
  background: linear-gradient(#061b2499, #0a141edc), url("../assets/mami-river.webp") center 27% / cover;
}
#play-screen[data-vodun="heviosso"][data-mode="arena"] .play-result {
  background: linear-gradient(#10102999, #111020df), url("../assets/heviosso-arena.webp") center / cover;
}
#play-screen[data-vodun="heviosso"][data-mode="village"] .play-result {
  background: linear-gradient(#10102999, #111020df), url("../assets/heviosso-street.webp") center 22% / cover;
}
.result-card { width: min(100%, 400px); max-height: 100%; overflow: auto; padding: clamp(14px, 4vw, 32px); border: 1px solid var(--stroke); border-top: 3px solid var(--gold); border-radius: 9px; background: var(--panel); text-align: center; }
.result-card h2 { margin: 0; font-size: clamp(1.7rem, 6vw, 3.2rem); line-height: 1; color: var(--gold); }
.result-card p { color: var(--muted); margin: 12px 0 20px; white-space: pre-line; }
.result-card button { min-height: 44px; padding: 6px 15px; border: 1px solid var(--stroke); border-radius: 5px; background: transparent; font-weight: 750; }
#play-retry { color: #201306; background: var(--gold); }
#status { position: fixed; bottom: 1rem; inset-inline: 1rem; margin: 0; padding: 1rem; background: #431e18; text-align: center; }

@media (min-width: 701px) and (max-height: 680px) {
  .site-header { min-height: 52px; }
  .hero-copy { padding-block: 18px 20px; }
  .hero h1 { font-size: clamp(3.2rem, min(9vw, 11vh), 6rem); }
  .hero-copy p { margin-block: 12px 9px; }
  .selection { padding-block: 12px 16px; }
  .vodun-card { min-height: 72px; padding-block: 4px; }
  .vodun-icon { width: 30px; height: 30px; }
  .mode-card { min-height: 152px; }
}

@media (max-width: 700px) {
  .shell { width: calc(100% - 28px); }
  .site-header { min-height: 51px; }
  .hero { background-position: center, center, 64% center; }
  .hero-copy { padding-block: clamp(16px, 3.2dvh, 32px) clamp(12px, 2dvh, 22px); }
  .hero h1 { font-size: clamp(3.15rem, min(14vw, 9dvh), 6.25rem); }
  .hero-copy p { margin-block: 14px 9px; }
  .selection { grid-template-columns: minmax(0, 1fr); gap: 13px; padding-block: 11px 13px; }
  .selection-section { gap: 7px; }
  .vodun-card { min-height: 72px; padding-block: 4px; }
  .vodun-icon { width: 31px; height: 31px; }
  .modes { gap: 8px; }
  .mode-card { min-height: clamp(105px, 16dvh, 143px); padding: 10px; }
  .mode-detail { font-size: .7rem; }
  .launch-icon { flex-basis: 23px; height: 23px; font-size: .75rem; }
  .home-footer { padding-block: 8px 10px; }
}
@media (max-height: 620px) {
  .site-header { min-height: 43px; }
  .hero-copy { padding-block: 12px; }
  .hero h1 { font-size: clamp(1.95rem, min(8.8vw, 11dvh), 5.1rem); line-height: .9; }
  .hero h1 span { display: inline; }
  .hero-copy p { margin-block: 9px 7px; }
  .avatars { margin-bottom: 7px; }
  .avatar-card { min-height: 42px; width: 44px; }
  .avatar-card img { height: 35px; width: 28px; }
  .hero-link { min-height: 39px; }
  .selection { padding-block: 9px 11px; }
  .vodun-card { min-height: 63px; padding-block: 3px; }
  .vodun-icon { width: 27px; height: 27px; }
  .home-footer { padding-block: 7px 8px; }
}
@media (min-width: 580px) and (max-height: 530px) {
  .hero-copy {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 18px;
  }
  .hero h1 { grid-area: 1 / 1; }
  .hero-copy p { grid-area: 2 / 1; margin: 0; }
  .avatars { grid-area: 1 / 2; justify-self: end; margin: 0; }
  .hero-link { grid-area: 2 / 2; justify-self: end; }
  .selection { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 15px; }
  .mode-card { min-height: 134px; }
}
@media (max-width: 355px) {
  .wordmark { font-size: .72rem; gap: 5px; }
  .seal { width: 22px; height: 22px; margin-right: 1px; }
  .seal::after { inset: 5px; }
  .launch-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .mode-card { transition: none; }
}

.info-trigger, .info-close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #d5ab796b;
  border-radius: 50%;
  background: #1a140fd6;
  color: var(--gold);
}
.info-trigger span { font: italic 750 1.25rem/.95 Georgia, serif; }
.info-trigger:hover, .info-close:hover { background: #39291d; }

body:has(.game-info[open]) { overflow: hidden; }
.game-info {
  width: min(670px, calc(100% - 24px));
  max-height: min(680px, calc(100dvh - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #92765a80;
  border-radius: 15px;
  background: #1a1512;
  color: var(--kaolin);
  box-shadow: 0 22px 85px #000a;
}
.game-info[open] {
  display: flex;
  flex-direction: column;
  animation: info-reveal .18s ease-out;
}
.game-info::backdrop { background: #08070bc7; backdrop-filter: blur(5px); }
@keyframes info-reveal {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
}
.info-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: none;
  padding: 13px clamp(14px, 4vw, 26px);
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(100deg, #2b2017, #1c1716);
}
.info-top h2 { margin: 0; font-size: clamp(1.25rem, 4vw, 1.7rem); letter-spacing: -.045em; }
.info-close { font-size: 1.42rem; line-height: 1; }
.info-body { overflow: auto; overscroll-behavior: contain; padding: 14px clamp(14px, 4vw, 26px) 21px; }
.info-controls { margin: 0 0 12px; color: #e2d4c6; font-size: .91rem; }
.info-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.info-modes p, .info-voduns li {
  margin: 0;
  padding: 9px 11px;
  border-radius: 7px;
  background: #261e19;
  color: #d8c9ba;
  font-size: .78rem;
}
.info-modes strong, .info-voduns strong { display: block; color: #f1dfcc; font-size: .9rem; }
.info-modes strong { color: var(--gold); margin-bottom: 2px; }
.info-body h3 { margin: 17px 0 7px; font-size: 1rem; }
.info-voduns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.info-voduns strong { margin-bottom: 3px; }
.info-voduns small { margin-left: 5px; color: #c8af96; font-size: .67rem; font-weight: 550; white-space: nowrap; }
@media (max-width: 510px) {
  .info-voduns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .game-info[open] { animation: none; }
}
