/* ===========================================================
   Tiki Tapu — volcanique / Tiki gravé
   =========================================================== */

:root {
  --basalt:   #14100E;
  --basalt-2: #1E1712;
  --basalt-3: #2A2018;
  --tapa:     #EBDFC8;
  --muted:    #B9A788;

  --ember:    #FF7A2D;
  --ember-hi: #FFB02E;
  --sacred:   #E5343E;
  --jade:     #3FB89A;
  --gold:     #D9A441;

  --grad: linear-gradient(120deg, var(--ember-hi), var(--ember) 60%, #F2541B);
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 18px 40px -18px rgba(0,0,0,.85);
  --tap: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--basalt);
  color: var(--tapa);
  overflow: hidden; position: relative; -webkit-font-smoothing: antialiased;
}

.aura {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(42% 32% at 20% 8%, rgba(255,122,45,.20), transparent 70%),
    radial-gradient(40% 34% at 84% 16%, rgba(229,52,62,.16), transparent 72%),
    radial-gradient(60% 44% at 50% 104%, rgba(255,122,45,.14), transparent 72%);
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateY(0) scale(1); } to { transform: translateY(-10px) scale(1.04); } }

#app { position: relative; z-index: 1; height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; }

.screen {
  display: none; flex-direction: column; width: 100%;
  padding: calc(var(--safe-t) + 18px) 22px calc(var(--safe-b) + 18px);
  animation: screen-in .42s cubic-bezier(.2,.7,.2,1) both;
}
.screen.is-active { display: flex; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }

/* ---- Buttons ---- */
.btn {
  font: inherit; font-weight: 700; font-size: 1.02rem; border: none; border-radius: var(--radius);
  min-height: var(--tap); padding: 0 24px; color: var(--tapa); cursor: pointer; letter-spacing: .2px;
  transition: transform .12s ease, filter .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--grad); color: #2a1505; box-shadow: 0 12px 26px -12px rgba(255,122,45,.6); }
.btn-ghost { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.13); }
.btn.big { width: 100%; min-height: 64px; font-size: 1.12rem; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.pad { padding-top: 14px; }
.stack.full { width: 100%; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1); color: var(--tapa); font-size: 1.3rem; cursor: pointer;
  display: grid; place-items: center;
}

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 42px; }
.bar-title { font-weight: 700; font-size: 1.15rem; letter-spacing: .3px; }
.round-tag {
  margin-left: auto; font-size: .78rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--basalt); background: var(--gold); padding: 5px 12px; border-radius: 6px;
}

/* ===========================================================
   TIKI (SVG injecté)
   =========================================================== */
.tiki-stage { width: 188px; filter: drop-shadow(0 10px 26px rgba(255,122,45,.32)); }
.tiki-stage.small { width: 132px; margin-top: auto; }
.tiki-stage svg { width: 100%; height: auto; display: block; }
.tiki-stage .eye { fill: var(--ember); transition: fill .3s ease; }
.tiki-stage .eye-spark { fill: #FFE3B0; }

.tiki-stage.is-running { animation: tiki-breathe 1.1s ease-in-out infinite; }
.tiki-stage.is-running .eye { animation: eye-glow 1.1s ease-in-out infinite; }
@keyframes tiki-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes eye-glow { 0%,100% { fill: var(--ember); } 50% { fill: var(--sacred); } }

.tiki-stage.is-cursed { animation: curse-shake .5s cubic-bezier(.36,.07,.19,.97) both; filter: drop-shadow(0 0 30px rgba(229,52,62,.8)); }
.tiki-stage.is-cursed .eye { fill: var(--sacred); }
@keyframes curse-shake {
  10%,90% { transform: translateX(-2px) rotate(-1deg); }
  20%,80% { transform: translateX(4px) rotate(1.5deg); }
  30%,50%,70% { transform: translateX(-7px) rotate(-2deg); }
  40%,60% { transform: translateX(7px) rotate(2deg); }
}

/* ===========================================================
   ACCUEIL
   =========================================================== */
.logo {
  margin-top: 18px; font-size: 2.7rem; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; text-align: center;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.eyebrow { font-size: .74rem; letter-spacing: 3px; text-transform: uppercase; color: var(--sacred); text-align: center; margin-top: 8px; }
.tagline { text-align: center; color: var(--muted); margin: 12px auto auto; font-size: 1rem; max-width: 19em; line-height: 1.5; }
[data-screen="home"] .stack { padding-bottom: 6px; }

/* ===========================================================
   RÈGLES
   =========================================================== */
.how { padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.how li { color: var(--muted); line-height: 1.5; }
.how strong { color: var(--tapa); }
.rule-note {
  margin-top: 20px; background: linear-gradient(180deg, rgba(255,122,45,.08), rgba(255,122,45,.02));
  border: 1px solid rgba(255,122,45,.22); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.rule-note p { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.rule-note strong { color: var(--ember-hi); }

/* ===========================================================
   PRÉPARATION
   =========================================================== */
.field-label { font-size: .78rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin: 6px 0 10px; }
.field-label + .segmented, .config-block { margin-bottom: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.chip {
  border: 1px solid rgba(255,255,255,.14); background: var(--basalt-2); color: var(--muted);
  border-radius: 999px; padding: 11px 18px; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  transition: all .18s ease;
}
.chip.on { background: var(--grad); color: #2a1505; border-color: transparent; }

.segmented { display: flex; gap: 8px; background: var(--basalt-2); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 6px; }
.segmented button {
  flex: 1; font: inherit; font-weight: 700; font-size: .95rem; border: none; cursor: pointer;
  background: transparent; color: var(--muted); border-radius: 9px; padding: 12px 0; transition: all .18s ease;
}
.segmented button.on { background: var(--basalt-3); color: var(--ember-hi); box-shadow: inset 0 0 0 1px rgba(255,176,46,.3); }

.config-block { background: var(--basalt-2); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius); overflow: hidden; }
.config-row { display: flex; align-items: center; justify-content: space-between; padding: 16px; gap: 14px; }
.config-row + .config-row { border-top: 1px solid rgba(255,255,255,.06); }
.config-label span { font-weight: 700; display: block; }
.config-label small { color: var(--muted); font-size: .82rem; }

.switch { position: relative; width: 54px; height: 32px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; border-radius: 999px; background: var(--basalt-3); border: 1px solid rgba(255,255,255,.12); transition: .25s; }
.slider::before { content: ""; position: absolute; height: 24px; width: 24px; left: 3px; top: 3px; background: var(--tapa); border-radius: 50%; transition: .25s; }
.switch input:checked + .slider { background: var(--grad); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(22px); }

.hint { margin-top: 16px; color: var(--muted); font-size: .88rem; text-align: center; line-height: 1.5; min-height: 1.2em; }
.hint.warn { color: var(--sacred); }

/* ===========================================================
   JEU
   =========================================================== */
.prompt-pre { font-size: .76rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.prompt {
  font-size: 2.3rem; font-weight: 800; line-height: 1.15; text-align: center; max-width: 12em;
  color: var(--tapa); text-shadow: 0 2px 18px rgba(255,122,45,.25);
}
.live-foot { color: var(--muted); font-size: .9rem; margin-top: 14px; max-width: 20em; }
#armed-block, #running-block { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.running-hint { font-size: 1.25rem; font-weight: 800; color: var(--ember-hi); }
.running-sub { color: var(--muted); font-size: .92rem; letter-spacing: .5px; animation: flicker 2s ease-in-out infinite; }
@keyframes flicker { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* ===========================================================
   MALÉDICTION
   =========================================================== */
[data-screen="cursed"].is-active { background: radial-gradient(120% 80% at 50% 30%, rgba(229,52,62,.18), transparent 60%); }
.cursed-title { font-size: 2.1rem; font-weight: 800; color: var(--sacred); text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.cursed-sub { color: var(--muted); font-size: 1rem; max-width: 20em; text-align: center; }
.gage-card {
  width: 100%; background: linear-gradient(160deg, var(--basalt-3), var(--basalt-2));
  border: 1px solid rgba(229,52,62,.35); border-radius: var(--radius-lg); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
  animation: card-pop .4s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes card-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.gage-label { font-size: .74rem; letter-spacing: 2px; text-transform: uppercase; color: var(--sacred); }
.gage-text { font-size: 1.25rem; font-weight: 700; line-height: 1.35; }

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