@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #15102a;
  --bg-2: #1e1740;
  --bg-3: #2a2154;
  --ink: #f3eefb;
  --muted: #b7acd6;
  --gold: #d9b45a;
  --gold-2: #f0d48a;
  --rose: #e88ea2;
  --ok: #7ad3a0;
  --danger: #ff7b7b;
  --bubble-me: #4b3a8f;
  --bubble-her: #2b2350;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 80% -10%, #3a2a7a 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 100%, #4a2458 0%, transparent 55%),
              var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--gold-2); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0 0 .4em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; }
h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; gap: 12px; }
.brand { font-family: var(--display); font-size: 1.5rem; color: var(--gold-2); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand .moon { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2c2, var(--gold) 60%, #8a6d2a); box-shadow: 0 0 18px rgba(217, 180, 90, .6); }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 22px; font: 600 15px var(--font); cursor: pointer; text-decoration: none; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1d08; box-shadow: 0 6px 24px rgba(217, 180, 90, .35); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: rgba(255, 255, 255, .07); color: var(--ink); border: 1px solid rgba(255, 255, 255, .14); }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.btn-danger { background: rgba(255, 123, 123, .12); color: var(--danger); border: 1px solid rgba(255, 123, 123, .3); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Cards / panels */
.panel { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09); border-radius: var(--radius); padding: 22px; backdrop-filter: blur(8px); }
.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-2 { grid-template-columns: repeat(2, 1fr); } }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
input, textarea, select { width: 100%; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .14); color: var(--ink); padding: 12px 14px; border-radius: 12px; font: 15px var(--font); outline: none; }
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 180, 90, .18); }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin-top: 8px; }
.ok { color: var(--ok); }

/* Hero */
.hero { display: grid; gap: 28px; padding: 30px 0 50px; align-items: center; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.1fr .9fr; } }
.avatar-big { width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #6a52c9, #2d2160 70%); border: 3px solid var(--gold); box-shadow: 0 0 40px rgba(106, 82, 201, .5); display: grid; place-items: center; font-family: var(--display); font-size: 64px; color: var(--gold-2); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(122, 211, 160, .12); color: var(--ok); font-size: 13px; font-weight: 500; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.price { font-family: var(--display); font-size: 2.4rem; color: var(--gold-2); line-height: 1; }
.price small { font-size: 1rem; color: var(--muted); font-family: var(--font); }
.badge { position: absolute; top: -10px; right: 16px; background: var(--rose); color: #2a0c14; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pack { position: relative; }
.pack.consigliato { border-color: rgba(232, 142, 162, .5); }

footer { padding: 30px 0 40px; color: var(--muted); font-size: 13px; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 40px; }
footer p { margin: 0 0 6px; }

/* ----- CHAT ----- */
.chat-page { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: rgba(0, 0, 0, .25); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.chat-head .avatar { width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #6a52c9, #2d2160 70%); border: 2px solid var(--gold); display: grid; place-items: center; font-family: var(--display); font-size: 22px; color: var(--gold-2); position: relative; }
.chat-head .avatar::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--bg); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-family: var(--display); font-size: 20px; font-weight: 600; }
.chat-head .who span { font-size: 12px; color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); }
.timer.low { background: rgba(255, 123, 123, .15); color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

.chat-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 15.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; animation: pop .18s ease-out; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.msg.her { align-self: flex-start; background: var(--bubble-her); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--bubble-me); border-bottom-right-radius: 6px; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12.5px; text-align: center; box-shadow: none; max-width: 90%; }
.msg + .msg.her, .msg + .msg.me { margin-top: -2px; }
.typing { align-self: flex-start; background: var(--bubble-her); border-radius: 18px; border-bottom-left-radius: 6px; padding: 12px 16px; display: flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.cards { align-self: flex-start; display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 4px; max-width: 100%; }
.card { width: 92px; perspective: 600px; text-align: center; font-size: 11px; color: var(--muted); }
.card .face { position: relative; width: 92px; height: 148px; border-radius: 9px; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.4, .1, .2, 1); }
.card.flipped .face { transform: rotateY(180deg); }
.card .side { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 9px; border: 2px solid var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; }
.card .back { background: repeating-linear-gradient(45deg, #2a1f5e 0 6px, #352a70 6px 12px); }
.card .back::after { content: '✦'; color: var(--gold); font-size: 28px; }
.card .front { background: linear-gradient(170deg, #fdf6e3, #e8d9b5); color: #2a1d08; transform: rotateY(180deg); font-family: var(--display); }
.card .front .num { font-size: 12px; letter-spacing: .1em; }
.card .front .sym { font-size: 34px; margin: 4px 0; }
.card .front .nome { font-size: 13px; font-weight: 600; line-height: 1.1; }
.card.rev .front .inner { transform: rotate(180deg); }
.card .pos { margin-top: 6px; font-family: var(--font); line-height: 1.2; }
.card .pos b { display: block; color: var(--gold-2); font-weight: 500; }

.chat-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(0, 0, 0, .25); border-top: 1px solid rgba(255, 255, 255, .08); display: flex; gap: 8px; align-items: flex-end; }
.chat-foot textarea { flex: 1; resize: none; max-height: 120px; border-radius: 20px; padding: 11px 16px; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1d08; font-size: 20px; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.send[disabled] { opacity: .45; cursor: not-allowed; }

.overlay { position: fixed; inset: 0; background: rgba(10, 6, 24, .8); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.overlay.show { display: flex; }
.overlay .panel { max-width: 420px; width: 100%; text-align: center; }

/* Admin */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid rgba(255, 255, 255, .08); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 2rem; color: var(--gold-2); }
pre.tr { white-space: pre-wrap; font: 13px/1.5 var(--font); background: rgba(0, 0, 0, .25); padding: 14px; border-radius: 12px; max-height: 60vh; overflow: auto; }
