:root {
  --bg: #232326;
  --bg-alt: #2d2328;
  --bg-panel: rgba(30, 25, 27, 0.88);
  --bg-soft: rgba(247, 235, 212, 0.92);
  --text: #f2ead9;
  --text-dark: #312823;
  --muted: #c7bda8;
  --gold: #d6b26b;
  --gold-deep: #a17a35;
  --copper: #8f5d42;
  --blue: #7fb4ff;
  --line: rgba(214, 178, 107, 0.25);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 20px;
  --max: 1220px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(118, 36, 45, 0.42), transparent 32%),
    radial-gradient(circle at top right, rgba(84, 42, 56, 0.35), transparent 28%),
    linear-gradient(180deg, #2f3137 0%, #231f23 42%, #20181c 100%);
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.2rem;
  padding: 0.95rem 1.5rem;
  background: rgba(26, 22, 24, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: var(--gold);
  border: 1px solid rgba(214, 178, 107, 0.4);
  background: linear-gradient(180deg, rgba(214, 178, 107, 0.16), rgba(127, 180, 255, 0.08));
}
.brand-title {
  font-family: 'Cinzel', serif;
  font-size: 1.35rem;
  letter-spacing: 0.16rem;
  color: #f4efe2;
}
.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.main-nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.4rem 0.2rem;
  position: relative;
}
.main-nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -0.15rem;
  width: 100%;
  height: 2px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.main-nav a:hover { color: #fff5de; }
.main-nav a:hover::after { transform: scaleX(1); }

.account-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  border: 1px solid transparent;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}
.btn-gold {
  color: #231a10;
  background: linear-gradient(180deg, #e0c37d, #c9994c);
  border-color: rgba(252, 234, 183, 0.2);
}
.btn-ghost {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border-color: rgba(214, 178, 107, 0.28);
}
.btn-large {
  width: 100%;
  padding-block: 1rem;
  font-size: 1rem;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
}
.mobile-menu {
  display: none;
  background: rgba(26, 22, 24, 0.98);
  border-bottom: 1px solid var(--line);
  padding: 0 1.3rem 1rem;
}
.mobile-menu a {
  display: block;
  padding: 0.75rem 0;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mobile-menu.open { display: block; }

main {
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
  padding: 1.3rem 0 3rem;
}
.section-shell { margin-top: 1.3rem; }
.content-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.span-2 { grid-column: span 2; }
.card {
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.05);
}
.dark-card {
  background: linear-gradient(180deg, rgba(38, 30, 33, 0.95), rgba(24, 21, 23, 0.95));
}
.parchment-card {
  background: linear-gradient(180deg, rgba(247, 235, 212, 0.95), rgba(232, 219, 194, 0.93));
  color: var(--text-dark);
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  align-items: stretch;
}
.hero h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.6rem, 6vw, 4.9rem);
  line-height: 1;
  margin: 0.3rem 0 0.9rem;
  color: #f2ece0;
  letter-spacing: 0.15rem;
}
.eyebrow {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.12rem;
  font-size: 0.82rem;
}
.hero-text {
  font-size: 1.03rem;
  line-height: 1.8;
  color: #eee2cf;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.crest-card {
  display: grid;
  place-items: center;
}
.crest-frame {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border-radius: 18px;
  border: 1px solid rgba(214, 178, 107, 0.3);
  background:
    radial-gradient(circle at top, rgba(214, 178, 107, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.6rem;
}
.crest-title {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  letter-spacing: 0.12rem;
  text-transform: uppercase;
}
.crest-symbol {
  font-size: 4rem;
  margin: 1rem 0 0.2rem;
}
.crest-line {
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0.6rem 0 1rem;
}

h2, h3 {
  font-family: 'Cinzel', serif;
  margin-top: 0;
}
h2 { font-size: 1.7rem; }
h3 { font-size: 1.2rem; }
p { line-height: 1.7; }
.section-heading {
  margin-bottom: 0.9rem;
}
.section-heading p { margin-top: -0.4rem; color: var(--muted); }
.bullet-list { margin: 0.75rem 0 0; padding-left: 1.1rem; }
.bullet-list li { margin-bottom: 0.5rem; }
.light-list li { color: #e8deca; }

.kingdom-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.kingdom {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  overflow: hidden;
  position: relative;
}
.kingdom::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.3));
}
.kingdom > * { position: relative; }
.neulbert { background: linear-gradient(135deg, #455340, #31392d); }
.luberten { background: linear-gradient(135deg, #6f4534, #43251c); }
.renbeltu { background: linear-gradient(135deg, #5e3640, #351d24); }
.terluben { background: linear-gradient(135deg, #3d4e59, #253038); }

.map-placeholder {
  position: relative;
  border-radius: 18px;
  min-height: 220px;
  margin-top: 1rem;
  border: 1px solid rgba(214, 178, 107, 0.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02)),
    repeating-linear-gradient(45deg, rgba(214, 178, 107, 0.05), rgba(214, 178, 107, 0.05) 8px, transparent 8px, transparent 16px);
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}
.map-glow {
  position: absolute;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(127, 180, 255, 0.18), transparent 65%);
  border-radius: 50%;
}
.map-text {
  position: relative;
  padding: 1rem;
  color: #f5ead7;
  font-weight: 600;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}
.tag {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(49, 40, 35, 0.08);
  color: #4c3d33;
  border: 1px solid rgba(49, 40, 35, 0.1);
  font-size: 0.9rem;
  font-weight: 700;
}

.dice-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}
.inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.inputs-grid label {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
  color: #ece2cf;
}
.inputs-grid input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(214, 178, 107, 0.24);
  background: rgba(255,255,255,0.06);
  color: #fff;
  padding: 0.85rem 0.8rem;
  font: inherit;
}
.threshold-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0;
  border: 1px solid rgba(214, 178, 107, 0.18);
  border-radius: 18px;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
}
.threshold-box strong {
  font-size: 2rem;
  color: var(--gold);
}
.small-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.rule-note {
  color: #ece2cf;
}
.dice-visuals {
  display: grid;
  align-content: center;
}
.dice-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.die-block { text-align: center; }
.die-face {
  width: 130px;
  height: 130px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff7e8, #ead5ad);
  color: #2f2620;
  display: grid;
  place-items: center;
  font-family: 'Cinzel', serif;
  font-size: 2.6rem;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 12px 26px rgba(0,0,0,0.14);
  border: 1px solid rgba(161, 122, 53, 0.26);
}
.die-face.rolling {
  animation: shake 0.12s linear infinite;
}
@keyframes shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(1px, -1px) rotate(-1deg); }
  50% { transform: translate(-1px, 1px) rotate(1deg); }
  75% { transform: translate(1px, 1px) rotate(0deg); }
  100% { transform: translate(0, 0) rotate(-1deg); }
}
.result-display {
  text-align: center;
  margin-top: 1.3rem;
}
.final-result {
  font-family: 'Cinzel', serif;
  font-size: 3.4rem;
  color: #4f3b26;
  margin: 0.35rem 0;
}
.verdict {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-weight: 800;
  margin-bottom: 0.6rem;
}
.verdict.success { background: rgba(59, 124, 77, 0.12); color: #366d44; }
.verdict.crit-success { background: rgba(74, 130, 181, 0.16); color: #2f628c; }
.verdict.failure { background: rgba(139, 84, 57, 0.12); color: #874a2e; }
.verdict.crit-failure { background: rgba(137, 50, 63, 0.16); color: #8b2f45; }
.detail-line { color: #5d5046; margin-bottom: 0; }

.market-demo {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}
.market-item {
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(49, 40, 35, 0.06);
  border: 1px solid rgba(49, 40, 35, 0.08);
}

.site-footer {
  width: min(calc(100% - 2rem), var(--max));
  margin: 1rem auto 2rem;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
}
.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
  }
  .main-nav { display: none; }
  .menu-toggle { display: inline-block; }
  .account-actions { display: none; }
  .hero,
  .dice-layout,
  .content-grid,
  .kingdom-grid {
    grid-template-columns: 1fr 1fr;
  }
  .hero .hero-side,
  .hero .hero-copy,
  .span-2 { grid-column: span 2; }
}

@media (max-width: 760px) {
  main { width: min(calc(100% - 1rem), var(--max)); }
  .topbar { padding: 0.85rem 1rem; }
  .hero,
  .content-grid,
  .dice-layout,
  .kingdom-grid,
  .inputs-grid {
    grid-template-columns: 1fr;
  }
  .span-2,
  .hero .hero-side,
  .hero .hero-copy { grid-column: span 1; }
  .dice-row { gap: 0.75rem; }
  .die-face { width: 110px; height: 110px; font-size: 2.2rem; }
  .threshold-box {
    grid-template-columns: 1fr;
  }
}

/* V4.1 : logo canonique et dés à dix faces */
.brand-badge {overflow:hidden; padding:0; border-color:rgba(127,180,255,.35)}
.brand-badge img {width:100%;height:100%;object-fit:cover;object-position:center}
.crest-card {padding:0;overflow:hidden;background:linear-gradient(135deg,#12171f,#30212b)}
.crest-frame {padding:0;min-height:310px;overflow:hidden;border:0;background:none}
.official-logo {width:100%;height:100%;min-height:310px;max-height:470px;object-fit:cover;object-position:center;display:block}
.die-face {width:146px;height:159px;display:block;border:0;background:none;border-radius:0;box-shadow:none;filter:drop-shadow(4px 13px 11px rgba(44,32,20,.34));transform-style:preserve-3d;}
.die-face svg {width:100%;height:100%;display:block}
.die-face.rolling {animation:dice-tumble .21s linear infinite}
@keyframes dice-tumble {0%{transform:translateY(0) rotate(-13deg) scale(.96)}25%{transform:translateY(-19px) rotate(18deg) scale(1.04)}50%{transform:translateY(-7px) rotate(75deg) scale(1.02)}75%{transform:translateY(-21px) rotate(140deg) scale(.98)}100%{transform:translateY(0) rotate(220deg) scale(1)}}
@media(max-width:760px){.die-face{width:118px;height:130px}.official-logo{max-height:340px}}
@media(prefers-reduced-motion:reduce){.die-face.rolling{animation:none}}

/* CAREIMS V4.2 — musique d'accueil discrète et accessible */
.ambient-player { display:flex; flex-wrap:wrap; gap:.65rem; align-items:center; margin:1.2rem 0 .5rem; padding:.8rem; border:1px solid rgba(214,178,107,.28); border-radius:14px; background:rgba(8,8,12,.28); }
.ambient-toggle, .ambient-file-label { cursor:pointer; padding:.6rem .75rem; border:1px solid rgba(214,178,107,.35); border-radius:10px; color:#f4e5c8; background:rgba(214,178,107,.1); font:inherit; font-size:.83rem; font-weight:700; }
.ambient-toggle[aria-pressed="true"] { color:#1c1813; background:#d6b26b; }
.ambient-file-label:hover,.ambient-toggle:hover { border-color:#e9c988; }
.ambient-volume-label {font-size:.82rem;color:#d6c5a5;}
#ambientVolume { width:85px;accent-color:#d6b26b; }
.ambient-status { color:#bdac90;font-size:.75rem; flex-basis:100%; }
@media(max-width:550px){.ambient-player{align-items:center}.ambient-status{line-height:1.5}}

/* CAREIMS V4.4 — dés polyvalents */
[hidden]{display:none!important}
.roll-mode{display:flex;gap:.55rem;flex-wrap:wrap;margin-bottom:1rem}
.roll-mode-btn{background:rgba(255,255,255,.06);color:#eddfc7;border:1px solid rgba(214,178,107,.25);padding:.75rem 1rem;border-radius:13px;font:600 .91rem Inter,sans-serif;cursor:pointer}
.roll-mode-btn.active{background:#d6b26b;color:#271d18;border-color:#e8d6a5}
.free-roll-controls{padding-bottom:.35rem}
.inputs-grid select{width:100%;padding:.85rem .8rem;border-radius:12px;border:1px solid rgba(214,178,107,.24);background:#3c3030;color:white;font:inherit}
.quick-rolls{display:flex;flex-wrap:wrap;gap:.45rem;margin:.85rem 0}
.quick-rolls button{color:#f5ddac;background:#483631;border:1px solid #80634a;border-radius:999px;padding:.5rem .8rem;cursor:pointer;font-weight:600}
.quick-rolls button:hover{background:#5b4134}
.dice-help{font-size:.8rem;color:#d1bfa4;margin:.3rem 0 1rem}
.dice-row{flex-wrap:wrap;gap:.6rem;align-items:center}
.dice-row .die-face{width:112px;height:120px;border:0;background:none;box-shadow:none;border-radius:0}
.dice-row .die-face svg{width:100%;height:100%;filter:drop-shadow(0px 8px 6px rgba(0,0,0,.25))}
.dice-row .die-block .small-label{font-size:.66rem;text-align:center}
.dice-breakdown{font-weight:700;color:#78512c;min-height:1.4em;overflow-wrap:anywhere}
@media (max-width:760px){.dice-row .die-face{width:85px;height:96px}.roll-mode-btn{flex:1}.inputs-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* CAREIMS V4.5 — logo cadré et écran d'entrée musical */
.crest-card {display:flex;align-items:center;justify-content:center;min-width:0; padding:12px; background:#151820;}
.crest-frame {display:flex;justify-content:center;align-items:center;width:100%;height:100%;min-height:0;overflow:hidden;background:linear-gradient(140deg,#171a24,#24212c);border-radius:15px;}
.official-logo {width:100%;height:auto;min-height:0;max-height:none;aspect-ratio:3/2;object-fit:contain;object-position:center;display:block;border-radius:12px;}
.welcome-launcher {position:fixed;inset:0;z-index:9999;display:grid;place-items:center;padding:16px;background:radial-gradient(circle at 48% 30%,rgba(75,36,46,.48),transparent 55%),rgba(15,15,21,.96);backdrop-filter:blur(9px);overflow-y:auto;}
.welcome-launcher[hidden] {display:none!important}
.welcome-panel {max-width:660px;width:min(100%,660px);margin:auto;border:1px solid rgba(214,178,107,.34);border-radius:22px;overflow:hidden;box-shadow:0 30px 100px rgba(0,0,0,.7);background:linear-gradient(180deg,#242027,#191a20);text-align:center;}
.welcome-logo {display:block;width:100%;aspect-ratio:3/2;object-fit:contain;background:#10131c;}
.welcome-details {padding:20px 26px 24px;}
.welcome-kicker {font-size:.72rem;letter-spacing:.2em;font-weight:700;color:#deb979;}
.welcome-details h2 {font-family:Cinzel,Georgia,serif;color:#f4e6d0;margin:.55rem 0;font-size:clamp(1.45rem,4vw,2.2rem);}
.welcome-details p {color:#d6c6ac;font-size:.9rem;line-height:1.55;margin:.45rem 0 .9rem;}
.welcome-enter {font-size:1rem;padding:14px 28px;cursor:pointer;margin-top:5px;}
.welcome-silent {display:block;margin:12px auto 2px;color:#c7b9a3;background:transparent;border:0;text-decoration:underline;text-underline-offset:4px;cursor:pointer;font:inherit;font-size:.86rem;}
.welcome-details .welcome-note {font-size:.72rem;color:#a99c87;margin-top:.6rem;}
body.launcher-open {overflow:hidden;}
@media(max-width:700px){.welcome-details{padding:16px}.welcome-panel{max-width:430px}.welcome-details p{font-size:.81rem}.crest-card{padding:7px}}
@media(prefers-reduced-motion:reduce){.welcome-launcher{backdrop-filter:none}}

.welcome-logo, .official-logo { background:#10131c; }


/* CAREIMS V4.8 — vidéo jouée une fois puis image finale figée */
.welcome-logo,
.official-logo {
  object-fit: contain;
  object-position: center;
}

/* V4.10 : vidéo d’accueil entière, image finale immobile sans saut */
.crest-frame {position:relative;}
.hero-final-frame {width:100%;height:auto;aspect-ratio:3/2;object-fit:contain;object-position:center;border-radius:12px;display:block;background:#10131c;}
.hero-final-frame[hidden], .official-logo[hidden] {display:none!important;}
