/* ==========================================================================
   Thème « Kamui » — palette inspirée d'Obito : orange du masque, cramoisi du
   Sharingan, violet du Rinnegan, sur un noir profond.
   Toutes les formes sont dessinées en CSS/canvas : aucune image externe.
   ========================================================================== */

:root {
  --bg:        #06050a;
  --bg-2:      #0c0912;
  --surface:   #14101d;
  --surface-2: #1e1729;
  --line:      #2e2340;
  --line-soft: #221a30;

  --text:  #f4eef8;
  --muted: #9e8fb0;
  --dim:   #6d6182;

  --orange:  #ff6b1a;
  --crimson: #e01e37;
  --violet:  #7b2cbf;
  --gold:    #ffb703;

  --accent: var(--orange);
  --grad:      linear-gradient(135deg, #ff6b1a 0%, #e01e37 55%, #a01e8f 100%);
  --grad-soft: linear-gradient(135deg, rgba(255,107,26,.15), rgba(224,30,55,.13) 55%, rgba(123,44,191,.15));

  --ok:     #3ddc84;
  --warn:   #ffb703;
  --danger: #ff4d5e;

  --r:    14px;
  --r-lg: 20px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Le canvas du vortex occupe tout l'écran, derrière l'interface. */
#bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* Voile sombre : garantit la lisibilité du texte par-dessus l'animation. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 85% at 50% 38%, transparent 30%, rgba(6,5,10,.62) 78%, rgba(6,5,10,.9) 100%);
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.dim   { color: var(--dim); font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ============================ Animations ============================ */

@keyframes fadeUp    { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn     { 0% { opacity: 0; transform: scale(.86); } 60% { transform: scale(1.03); } 100% { opacity: 1; transform: scale(1); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes shimmer   { to { background-position: 200% 0; } }
@keyframes toastIn   { from { opacity: 0; transform: translate(-50%, 22px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes blink     { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

@keyframes emberRing {
  0%   { box-shadow: 0 0 0 0 rgba(255,107,26,.45); }
  70%  { box-shadow: 0 0 0 15px rgba(255,107,26,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,26,0); }
}
@keyframes sealGlow {
  0%,100% { box-shadow: 0 0 24px rgba(224,30,55,.22), inset 0 0 34px rgba(224,30,55,.07); }
  50%     { box-shadow: 0 0 46px rgba(255,107,26,.42), inset 0 0 44px rgba(224,30,55,.13); }
}
@keyframes sweep {
  from { transform: translateX(-120%) skewX(-18deg); }
  to   { transform: translateX(320%) skewX(-18deg); }
}

.anim-in > * { animation: fadeUp .42s var(--ease) both; }
.anim-in > *:nth-child(1) { animation-delay: .02s; }
.anim-in > *:nth-child(2) { animation-delay: .06s; }
.anim-in > *:nth-child(3) { animation-delay: .10s; }
.anim-in > *:nth-child(4) { animation-delay: .14s; }
.anim-in > *:nth-child(5) { animation-delay: .18s; }
.anim-in > *:nth-child(n+6) { animation-delay: .21s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================ Authentification ============================ */

.auth {
  position: relative; z-index: 1;
  min-height: 100dvh; display: grid; place-items: center; padding: 22px;
}

.auth-card {
  position: relative;
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, rgba(30,23,41,.86), rgba(12,9,18,.94));
  border: 1px solid rgba(224,30,55,.3);
  border-radius: var(--r-lg);
  padding: 34px 26px 30px;
  backdrop-filter: blur(22px);
  animation: popIn .6s var(--ease) both, sealGlow 5s ease-in-out 1s infinite;
  overflow: hidden;
}

/* Liseré incandescent en haut de la carte. */
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--orange), var(--crimson), transparent);
}

/* Sceau tournant en filigrane, dessiné en dégradés coniques. */
.auth-card::after {
  content: ''; position: absolute; z-index: -1;
  width: 300px; height: 300px; right: -110px; top: -110px;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0deg, rgba(224,30,55,.16) 40deg, transparent 80deg,
                   transparent 120deg, rgba(255,107,26,.14) 160deg, transparent 200deg,
                   transparent 240deg, rgba(123,44,191,.15) 280deg, transparent 320deg);
  animation: spin 26s linear infinite;
}

.logo { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.logo span {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo.sm { font-size: 19px; }

.kanji {
  display: inline-block; margin-left: 9px;
  font-size: 13px; font-weight: 700; letter-spacing: 3px;
  color: var(--crimson); opacity: .75; vertical-align: 4px;
}

.tabs {
  display: flex; gap: 4px; margin: 24px 0 18px;
  background: rgba(6,5,10,.7); padding: 4px; border-radius: 12px;
  border: 1px solid var(--line-soft);
}
.tab {
  flex: 1; padding: 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-weight: 650; cursor: pointer;
  transition: color .2s, background .28s var(--ease);
}
.tab.active {
  background: var(--grad-soft); color: var(--text);
  border: 1px solid rgba(255,107,26,.28);
  box-shadow: 0 2px 14px rgba(224,30,55,.2);
}

/* ============================ Formulaires ============================ */

.form { display: grid; gap: 11px; animation: fadeIn .3s ease both; }

input, select, textarea {
  width: 100%; padding: 13px 15px;
  background: rgba(6,5,10,.6);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text); font: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  background: rgba(20,16,29,.85);
  box-shadow: 0 0 0 3px rgba(255,107,26,.15);
}
select {
  appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
label { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin-bottom: 7px; }

.btn {
  position: relative; overflow: hidden;
  padding: 13px 17px; border: 0; border-radius: 11px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer;
  transition: transform .16s var(--ease), filter .2s, opacity .2s, box-shadow .25s;
}
.btn:active:not(:disabled) { transform: scale(.965); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 22px rgba(224,30,55,.34);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); box-shadow: 0 8px 28px rgba(255,107,26,.42); }

/* Reflet qui balaie le bouton principal : attire l'œil sur l'action clé. */
.btn.primary::before {
  content: ''; position: absolute; top: 0; left: 0; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.26), transparent);
  animation: sweep 3.6s ease-in-out 1.4s infinite;
}
.btn.primary:disabled::before { animation: none; }

.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--orange); }
.btn.danger { background: rgba(255,77,94,.13); color: #ff8f9b; border: 1px solid rgba(255,77,94,.32); }
.btn.danger:hover:not(:disabled) { background: rgba(255,77,94,.2); }
.btn.xs { padding: 8px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }

.btn::after {
  content: ''; position: absolute; left: var(--rx, 50%); top: var(--ry, 50%);
  width: 0; height: 0; border-radius: 50%;
  background: rgba(255,190,120,.4);
  transform: translate(-50%, -50%); opacity: 0;
}
.btn.rippling::after { animation: ripple .55s ease-out; }
@keyframes ripple { from { width: 0; height: 0; opacity: .8; } to { width: 320px; height: 320px; opacity: 0; } }

/* ============================ Ossature ============================ */

#app { position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  background: rgba(6,5,10,.8);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--line-soft);
  animation: slideDown .45s var(--ease) both;
}

.balance-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px 7px 14px;
  background: var(--grad-soft);
  border: 1px solid rgba(255,107,26,.3);
  border-radius: 100px;
}
#balance-amount { font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }

/* Avatar : anneau du Sharingan, rotation lente au repos. */
.avatar {
  position: relative;
  width: 38px; height: 38px; flex: 0 0 38px;
  border: 0; border-radius: 50%;
  background: var(--grad); color: #fff;
  font: inherit; font-weight: 800; font-size: 14px;
  cursor: pointer; display: grid; place-items: center;
  transition: transform .18s var(--ease);
  box-shadow: 0 4px 16px rgba(224,30,55,.45);
}
.avatar::before {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--crimson), var(--orange), var(--violet), var(--crimson));
  z-index: -1; animation: spin 7s linear infinite;
}
.avatar:active { transform: scale(.92); }

.menu {
  position: absolute; top: calc(100% + 8px); right: 16px;
  min-width: 216px; padding: 7px;
  background: rgba(20,16,29,.97); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: 0 20px 54px rgba(0,0,0,.7);
  backdrop-filter: blur(16px);
  animation: popIn .26s var(--ease) both; transform-origin: top right;
}
.menu button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 13px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; font-weight: 550; text-align: left; cursor: pointer;
  transition: background .16s, padding-left .16s;
}
.menu button:hover { background: var(--surface-2); padding-left: 17px; }
.menu button.accent { color: var(--orange); }
.menu button.leave  { color: #ff8f9b; }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 4px; }
.menu .who { padding: 9px 13px 11px; }

main { position: relative; padding: 18px 16px 96px; max-width: 640px; margin: 0 auto; }

/* ============================ Barre d'onglets ============================ */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; gap: 2px; padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: rgba(12,9,18,.92);
  backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--line-soft);
}
.tabbtn {
  flex: 1; padding: 9px 3px 8px; border: 0; border-radius: 12px;
  background: transparent; color: var(--dim);
  font: inherit; font-size: 11px; font-weight: 650; cursor: pointer;
  display: grid; gap: 3px; justify-items: center;
  transition: color .22s, background .28s var(--ease);
}
.tabbtn svg { width: 21px; height: 21px; stroke-width: 1.9; transition: transform .28s var(--ease); }
.tabbtn.active {
  color: var(--text);
  background: var(--grad-soft);
  border: 1px solid rgba(255,107,26,.22);
}
.tabbtn.active svg { transform: translateY(-2px) scale(1.08); stroke: var(--orange); }
.tabbtn:active svg { transform: scale(.9); }

/* ============================ Blocs ============================ */

h2 { font-size: 21px; font-weight: 750; letter-spacing: -.5px; }
.section { margin-bottom: 18px; }
.section h2 + p { margin-top: 3px; }

.card {
  background: rgba(20,16,29,.82);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 17px;
  margin-bottom: 11px;
  backdrop-filter: blur(9px);
  transition: border-color .25s, transform .25s var(--ease), box-shadow .25s;
}
.card.tappable { cursor: pointer; }
.card.tappable:hover {
  border-color: rgba(255,107,26,.42); transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
}

.hero {
  position: relative; overflow: hidden;
  background: var(--grad-soft);
  border: 1px solid rgba(255,107,26,.28);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 16px;
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 190px; height: 190px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(224,30,55,.2), transparent 60%);
  animation: spin 20s linear infinite;
}
.hero .amount {
  position: relative; z-index: 1;
  font-size: 38px; font-weight: 800; letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.row   { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 13px; }

.offer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-top: 1px solid var(--line-soft);
  animation: fadeUp .35s var(--ease) both;
}
.offer:first-of-type { border-top: 0; }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 100px;
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .4px;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok   { background: rgba(61,220,132,.14); color: var(--ok); }
.badge.wait { background: rgba(255,183,3,.14);  color: var(--gold); }
.badge.bad  { background: rgba(255,77,94,.14);  color: var(--danger); }
.badge.wait::before {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 6px;
  border-radius: 50%; background: currentColor; vertical-align: 1px;
  animation: blink 1.4s ease-in-out infinite;
}

.price { font-size: 19px; font-weight: 750; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.mono  { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* Location en cours : la carte respire tant que le SMS n'est pas arrivé. */
.live {
  border-color: rgba(255,107,26,.5);
  animation: emberRing 2.4s ease-out infinite;
}

.phone-line {
  font-family: ui-monospace, monospace; font-size: 25px; font-weight: 700;
  letter-spacing: 1px; margin: 14px 0;
  background: linear-gradient(135deg, #fff, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.code-box {
  background: linear-gradient(135deg, rgba(255,107,26,.14), rgba(224,30,55,.1));
  border: 1px dashed rgba(255,107,26,.55);
  border-radius: var(--r); padding: 18px; text-align: center;
  font-size: 30px; font-weight: 800; letter-spacing: 7px;
  font-family: ui-monospace, monospace; color: var(--orange);
  animation: popIn .5s var(--ease) both, sealGlow 2.4s ease-in-out infinite;
}

.empty { text-align: center; color: var(--muted); padding: 52px 20px; animation: fadeIn .4s ease both; }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .55; }

.skel {
  height: 74px; border-radius: var(--r); margin-bottom: 11px;
  background: linear-gradient(90deg, rgba(20,16,29,.8) 25%, rgba(46,35,64,.85) 50%, rgba(20,16,29,.8) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel.sm { height: 44px; }

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--orange);
  animation: spin .7s linear infinite;
  display: inline-block; vertical-align: -3px;
}

.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 100; max-width: 90vw;
  padding: 13px 19px; border-radius: 12px;
  background: rgba(30,23,41,.97); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
  box-shadow: 0 14px 44px rgba(0,0,0,.7);
  backdrop-filter: blur(12px);
  animation: toastIn .38s var(--ease) both;
}
.toast.ok  { border-color: rgba(61,220,132,.5); background: linear-gradient(135deg, rgba(61,220,132,.16), rgba(30,23,41,.97)); }
.toast.bad { border-color: rgba(255,77,94,.5);  background: linear-gradient(135deg, rgba(255,77,94,.16), rgba(30,23,41,.97)); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 11px; }
.stat {
  background: rgba(20,16,29,.82); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 15px; backdrop-filter: blur(9px);
}
.stat .v {
  font-size: 24px; font-weight: 780; letter-spacing: -.6px; font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }

@media (min-width: 560px) {
  main { padding: 24px 20px 100px; }
  .hero .amount { font-size: 44px; }
}
