/* Il gioco di Camilla — stile.
   Base neutra; ogni schermata cambia clima tramite body[data-theme]. */

:root {
  --bg: #f4f2ee;
  --ink: #1d1a22;
  --muted: #6d6875;
  --line: #ddd8e2;
  --card: #ffffff;
  --accent: #7b4dff;
  --accent-ink: #ffffff;
  --danger: #d64545;
  --ok: #2e9e6a;
  --hud: #16131c;
  --hud-ink: #f3eefe;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Cinzel', Georgia, serif;
  --type: 'Special Elite', 'Courier New', monospace;
  --r: 14px;
  --shadow: 0 10px 30px rgba(20, 10, 40, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background .5s;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 16px 40px; width: 100%; }
.boot { margin: auto; font-size: 40px; color: var(--accent); animation: pulse 1.2s infinite; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.hint-small { font-size: 13px; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* ----------------------------------------------------------------- bottoni */
.btn {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 11px 20px; font-weight: 600; font-size: 15px; transition: transform .1s, background .2s, box-shadow .2s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------------------------------------------------------------------- HUD */
.hud {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  background: var(--hud); color: var(--hud-ink);
  padding: 10px 16px; border-bottom: 3px solid #000;
  box-shadow: inset 0 -3px 0 rgba(255,255,255,.06), 0 4px 18px rgba(0,0,0,.25);
  font-family: var(--pixel);
}
.hud-min { display: flex; justify-content: center; }
.hud-logo { font-size: 11px; letter-spacing: 1px; color: #c9a8ff; text-shadow: 2px 2px 0 #000; }
.hud-level { font-size: 9px; color: #8f86a3; margin-top: 6px; }
.hud-center { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.hud-row { display: flex; align-items: center; gap: 8px; }
.hud-tag { font-size: 7px; color: #8f86a3; width: 64px; text-align: right; }
.hud-num { font-size: 9px; color: #ff6b8b; min-width: 30px; }
.hud-inf { font-size: 16px; color: #ffd36b; }
.hud-lives { display: flex; gap: 3px; flex-wrap: wrap; }
.heart {
  width: 14px; height: 13px; display: inline-block; position: relative;
  background: #3a3346;
  clip-path: polygon(50% 100%, 0 45%, 0 20%, 18% 0, 38% 0, 50% 14%, 62% 0, 82% 0, 100% 20%, 100% 45%);
}
.heart.on { background: linear-gradient(#ff6b8b, #e0245e); }
.hud-attempts { display: flex; gap: 5px; }
.pip { width: 12px; height: 12px; transform: rotate(45deg); background: #3a3346; border: 2px solid #000; }
.pip.on { background: #6be0ff; box-shadow: 0 0 8px #6be0ff88; }
.hud-right { display: flex; gap: 6px; }
.hud-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid #000;
  background: #2a2434; font-size: 18px; position: relative;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.08);
}
.hud-btn:hover { background: #3a3248; }
.hud-btn.glow { animation: glow 1.8s ease-in-out infinite; }
.badge {
  position: absolute; top: -6px; right: -6px; font-style: normal; font-family: var(--pixel); font-size: 8px;
  background: #ffd36b; color: #000; border-radius: 99px; padding: 3px 5px; border: 2px solid #000;
}
@keyframes glow { 50% { box-shadow: 0 0 14px #c9a8ff, inset 0 -3px 0 rgba(0,0,0,.4); } }

@media (max-width: 640px) {
  .hud { grid-template-columns: 1fr auto; padding: 8px 10px; gap: 8px; }
  .hud-center { grid-column: 1 / -1; grid-row: 2; }
  .hud-logo { font-size: 9px; }
  .hud-btn { width: 34px; height: 34px; font-size: 15px; }
  .heart { width: 12px; height: 11px; }
  .hud-tag { width: auto; }
}

.footer {
  background: var(--hud); color: #8f86a3; text-align: center; font-size: 12px; padding: 12px 16px;
  border-top: 3px solid #000; letter-spacing: .3px;
}

/* ------------------------------------------------------------------- modale */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: rgba(12, 8, 20, .62); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .18s;
}
.modal-wrap.closing { animation: fade .18s reverse forwards; }
.modal-box {
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 26px 24px 22px; width: min(560px, 100%);
  max-height: calc(100dvh - 32px); overflow: auto; position: relative; box-shadow: var(--shadow); animation: pop .22s;
}
.modal-box.full { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; display: flex; flex-direction: column; }
.modal-wrap:has(.modal-box.full) { padding: 0; }
.modal-box.full .modal-body { flex: 1; overflow: auto; max-width: 760px; margin: 0 auto; width: 100%; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--muted); }
.modal-title { margin: 0 30px 14px 0; font-size: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal-box.extra { background: radial-gradient(circle at 50% 0, #3b2a63, #120d1d); color: #f3eefe; }
.modal-box.extra .modal-body { font-size: 18px; line-height: 1.7; padding: 30px 0; }
.modal-box.extra .modal-title { text-align: center; font-size: 46px; margin: 10px 0 0; }
.refuse-modal { text-align: center; }
.refuse-msg { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 10px 0; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.inv-item { border: 2px solid var(--line); border-radius: 12px; padding: 14px 8px; text-align: center; background: #faf8ff; }
.inv-icon { font-family: var(--pixel); font-size: 30px; color: var(--accent); margin-bottom: 10px; }
.inv-name { font-size: 13px; font-weight: 600; }

/* ------------------------------------------------------------------- avvisi */
.toasts { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast {
  background: #1d1a22; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow);
  animation: rise .25s; max-width: 520px; text-align: center; transition: opacity .4s, transform .4s;
}
.toast.out { opacity: 0; transform: translateY(8px); }
.toast.bad { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.almost { background: #f2a93b; color: #1d1a22; font-family: var(--pixel); font-size: 14px; padding: 14px 22px; }
.toast.item { background: #ffd36b; color: #1d1a22; }
.toast.magic { background: #5a3dbf; }

/* --------------------------------------------------------------- animazioni */
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
body.shake .stage { animation: shake .45s; }
body.shake-hard .app { animation: shake .6s 2; }
.loss-fx { position: fixed; inset: 0; z-index: 150; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.loss-fx.attempt { background: radial-gradient(circle, transparent 40%, rgba(214, 69, 69, .25)); animation: fade .2s; }
.loss-fx.life { background: radial-gradient(circle, rgba(120, 0, 30, .15) 20%, rgba(150, 0, 30, .55)); animation: fade .15s; }
.loss-icon { font-size: 64px; color: #fff; text-shadow: 0 4px 0 #8a0f2d; animation: lossIcon .9s cubic-bezier(.2, 1.6, .4, 1); }
.loss-fx.life .loss-icon { font-size: 110px; animation: heartBreak 1.2s ease-out; }
.loss-label { font-family: var(--pixel); font-size: 16px; color: #fff; margin-top: 18px; text-shadow: 3px 3px 0 #000; animation: rise .3s .15s backwards; }
.loss-fx.life .loss-label { font-size: 22px; }
@keyframes lossIcon { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } }
@keyframes heartBreak { 0% { transform: scale(.2); } 30% { transform: scale(1.3); } 45% { transform: scale(1) rotate(-6deg); } 60% { transform: rotate(6deg); } 100% { transform: translateY(40px) scale(.9); opacity: .2; } }
.win-fx { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(255, 230, 140, .5), rgba(20, 10, 40, .75)); animation: fade .3s; }
.win-fx.out { animation: fade .35s reverse forwards; }
.win-stars { font-size: 40px; color: #ffd36b; animation: spin 1.6s linear; }
.win-label { font-family: var(--pixel); color: #fff; font-size: clamp(16px, 4vw, 28px); margin-top: 16px; text-shadow: 3px 3px 0 #5a3dbf; text-align: center; padding: 0 16px; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes spin { to { transform: rotate(360deg); } }
.nope { animation: shake .4s; }

/* -------------------------------------------------------------------- login */
body[data-theme='login'] { background: radial-gradient(ellipse at 50% 30%, #2a1f45, #0c0913 70%); color: #efe9ff; }
.login { width: min(520px, 100%); text-align: center; }
.login-eye { font-size: 54px; color: #b48cff; animation: blink 5s infinite; margin-bottom: 18px; text-shadow: 0 0 30px #7b4dff; }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
.login-n { font-family: var(--pixel); font-size: 9px; color: #6f6390; letter-spacing: 2px; margin-bottom: 18px; }
.login-q { font-family: var(--serif); font-weight: 400; font-size: clamp(22px, 5vw, 32px); line-height: 1.3; margin: 0 0 28px; }
.login-form { display: flex; gap: 10px; }
.login-input {
  flex: 1; min-width: 0; padding: 14px 18px; border-radius: 999px; border: 1.5px solid #3e3260; background: rgba(255,255,255,.06);
  color: #fff; font-size: 17px; outline: none; text-align: center;
}
.login-input:focus { border-color: #b48cff; box-shadow: 0 0 0 4px #7b4dff33; }
.login-msg { min-height: 1.5em; margin-top: 22px; font-family: var(--serif); font-size: 18px; }
.login-msg.err { color: #ff8fa3; }
body[data-theme='login'] .footer { background: transparent; border-color: transparent; color: #4e4568; }

/* --------------------------------------------------------------- onboarding */
body[data-theme='onboarding'] { background: linear-gradient(160deg, #efe9ff, #f8f4ec); }
.onb { width: min(560px, 100%); text-align: center; }
.onb-card { background: var(--card); border-radius: 22px; padding: 36px 28px; box-shadow: var(--shadow); animation: rise .35s; min-height: 330px; }
.onb-icon { font-size: 64px; margin-bottom: 12px; }
.onb-title { font-family: var(--serif); font-size: 26px; margin: 0 0 14px; }
.onb-text p { line-height: 1.65; font-size: 16px; margin: 0; }
.onb-dots { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.dot { width: 9px; height: 9px; border-radius: 99px; background: #d4cce6; transition: .3s; }
.dot.on { width: 26px; background: var(--accent); }
.onb-nav { display: flex; justify-content: space-between; gap: 10px; }
.onb-modal .onb-card { box-shadow: none; border: 1px solid var(--line); }

/* -------------------------------------------------------------------- patto */
body[data-theme='patto'] { background: #2b1d14 radial-gradient(circle at 50% 20%, #4a3020, #1d130d); }
.patto {
  width: min(720px, 100%); background: #f2e3c4; color: #3b2614; padding: clamp(26px, 6vw, 56px);
  border-radius: 6px; box-shadow: 0 30px 60px rgba(0,0,0,.5), inset 0 0 80px rgba(120, 72, 20, .35);
  font-family: var(--serif); line-height: 1.75; font-size: clamp(14px, 2.2vw, 16px); position: relative;
  background-image: radial-gradient(circle at 10% 10%, rgba(255,255,255,.35), transparent 40%), radial-gradient(circle at 90% 85%, rgba(140, 90, 30, .2), transparent 45%);
}
.patto::before { content: ''; position: absolute; inset: 12px; border: 2px double #8b5a2b; pointer-events: none; border-radius: 3px; }
.patto-head { text-align: center; margin-bottom: 18px; }
.patto-orn { color: #8b5a2b; letter-spacing: 8px; }
.patto h1 { font-size: clamp(26px, 6vw, 40px); margin: 6px 0 0; letter-spacing: 3px; color: #5a1a10; }
.patto p { margin: 0 0 14px; }
.patto ul, .patto ol { margin: 0 0 16px; padding-left: 26px; }
.patto-sub { font-weight: 700; text-transform: uppercase; letter-spacing: 2px; font-size: .9em; }
.patto-final { border-top: 1px solid #b08a5a; padding-top: 16px; }
.patto-sign { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; margin: 28px 0 10px; }
.sign-line { border-top: 1.5px solid #3b2614; text-align: center; font-size: 12px; padding-top: 6px; }
.sign-line.mago { position: relative; }
.firma { font-style: italic; }
.patto-seal svg { width: 84px; height: 84px; transform: rotate(-12deg); filter: drop-shadow(0 4px 4px rgba(0,0,0,.3)); }
.patto-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.btn.refuse { background: transparent; border: 2px solid #5a1a10; color: #5a1a10; font-family: var(--serif); font-weight: 700; letter-spacing: 1px; }
.btn.accept { background: #5a1a10; border: 2px solid #5a1a10; color: #f2e3c4; font-family: var(--serif); font-weight: 700; letter-spacing: 1px; }
body[data-theme='patto'] .footer { background: #1d130d; border-color: #000; }

body[data-theme='accepted'] { background: radial-gradient(circle at 50% 40%, #5a1a10, #12080a 75%); color: #f2e3c4; }
.accepted { text-align: center; font-family: var(--serif); }
.accepted-seal svg { width: 160px; height: 160px; animation: stamp .9s cubic-bezier(.2, 1.4, .4, 1); filter: drop-shadow(0 10px 18px rgba(0,0,0,.5)); }
@keyframes stamp { 0% { transform: scale(3) rotate(-30deg); opacity: 0; } 60% { transform: scale(.92) rotate(-8deg); opacity: 1; } 100% { transform: scale(1) rotate(-12deg); } }
.accepted-title { font-size: clamp(30px, 7vw, 52px); letter-spacing: 4px; margin: 26px 0 8px; animation: rise .6s .6s backwards; }
.accepted-text { margin: 6px 0; font-size: 18px; animation: rise .6s 1s backwards; }
.accepted-text.dim { opacity: .7; animation-delay: 1.4s; }
.accepted-go { margin-top: 30px; background: #f2e3c4; color: #5a1a10; border-color: #f2e3c4; animation: rise .6s 1.9s backwards; }
body[data-theme='accepted'] .footer { background: transparent; border-color: transparent; color: #7a4a3a; }

/* ----------------------------------------------------------- enigma: comune */
.enigma { width: min(820px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; }
.enigma-head { text-align: center; }
.enigma-n { font-family: var(--pixel); font-size: 9px; letter-spacing: 2px; opacity: .6; }
.enigma-head h1 { margin: 10px 0 6px; font-size: clamp(24px, 5vw, 36px); }
.enigma-guide { margin: 0; font-size: 17px; opacity: .85; }
.answer-form { display: flex; gap: 10px; width: min(520px, 100%); }
.answer-input {
  flex: 1; min-width: 0; padding: 14px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-size: 17px; outline: none;
}
.answer-input.upper { text-transform: uppercase; letter-spacing: 2px; }
.answer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px #7b4dff22; }
.big-number {
  font-family: var(--pixel); font-size: clamp(70px, 18vw, 140px); line-height: 1; border: 0; background: none; color: #ffd36b;
  text-shadow: 6px 6px 0 #5a3dbf, 0 0 40px #ffd36b88; animation: bigPop .8s cubic-bezier(.2, 1.6, .4, 1), float 2.4s 1s ease-in-out infinite; padding: 10px 20px;
}
.big-number:hover { transform: scale(1.06); }
@keyframes bigPop { from { transform: scale(0) rotate(-30deg); } }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ------------------------------------------------------------------- 1. luci */
body[data-theme='enigma-luci'] { background: radial-gradient(circle at 50% 30%, #1a1d33, #07080f 80%); color: #e7e9ff; }
.luci-wrap { display: flex; flex-direction: column; align-items: center; }
.luci-board {
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: clamp(6px, 2vw, 12px); padding: clamp(12px, 3vw, 22px);
  background: #10121f; border-radius: 22px; border: 2px solid #23263f; box-shadow: inset 0 0 30px #000, 0 20px 50px #0008;
  width: min(440px, 92vw);
}
.bulb { aspect-ratio: 1; border: 0; background: none; padding: 0; position: relative; display: flex; flex-direction: column; align-items: center; }
.bulb-glass { width: 72%; aspect-ratio: 1; border-radius: 50% 50% 46% 46%; background: #2a2d45; box-shadow: inset -4px -6px 0 rgba(0,0,0,.35); transition: background .2s, box-shadow .3s; }
.bulb-base { width: 34%; height: 16%; background: repeating-linear-gradient(#777 0 3px, #555 3px 6px); border-radius: 0 0 4px 4px; margin-top: -2px; }
.bulb.on .bulb-glass { background: radial-gradient(circle at 40% 35%, #fffbe0, #ffd84d 60%, #f0a500); box-shadow: 0 0 22px #ffd84daa, 0 0 50px #ffb30055; }
.luci-board.all-on { animation: allOn .7s; }
@keyframes allOn { 50% { box-shadow: 0 0 80px #ffd84d, inset 0 0 30px #000; } }
.luci-bar { display: flex; gap: 16px; align-items: center; margin-top: 16px; font-family: var(--pixel); font-size: 10px; }
body[data-theme='enigma-luci'] .btn.ghost { color: #e7e9ff; border-color: #34385a; font-family: var(--sans); }

/* ----------------------------------------------------------------- 2. colore */
body[data-theme='enigma-colore'] { background: #f7f3ea; background-image: radial-gradient(circle at 15% 20%, #e9dcf7 0, transparent 30%), radial-gradient(circle at 85% 75%, #f3dfe8 0, transparent 30%); }
.colore-wrap { width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.colore-pair { display: flex; gap: clamp(20px, 8vw, 60px); }
.swatch, .bowl { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.swatch-disc { width: clamp(110px, 32vw, 160px); aspect-ratio: 1; border-radius: 50%; box-shadow: 0 10px 30px rgba(60, 20, 90, .3), inset 0 -10px 20px rgba(0,0,0,.15); margin-bottom: 10px; }
.bowl-disc { width: clamp(110px, 32vw, 160px); aspect-ratio: 1; border-radius: 50%; background: #fff; border: 8px solid #e8e1d6; box-shadow: inset 0 8px 18px rgba(0,0,0,.12); margin-bottom: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bowl-fill { width: 100%; height: 100%; transition: background .4s; }
.bowl-fill.empty { background: repeating-linear-gradient(45deg, #fff 0 8px, #f4f0ea 8px 16px) !important; }
.meter { width: 100%; }
.meter-track { height: 16px; border-radius: 99px; background: #e9e3d9; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.1); }
.meter-fill { height: 100%; width: 0; transition: width .5s, background .5s; border-radius: 99px; }
.meter-label { text-align: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.meter-label b { color: var(--ink); font-size: 18px; }
.drops { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.drop { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; position: relative; padding: 4px; }
.drop-shape { width: 46px; height: 46px; border-radius: 50% 0 50% 50%; transform: rotate(-45deg); box-shadow: inset -5px -5px 0 rgba(0,0,0,.18), 0 6px 12px rgba(0,0,0,.15); border: 2px solid rgba(0,0,0,.08); }
.drop-bianco .drop-shape { border-color: #ddd; }
.drop.drip .drop-shape { animation: drip .4s; }
@keyframes drip { 50% { transform: rotate(-45deg) translate(6px, -6px) scale(.85); } }
.drop-count { position: absolute; top: -4px; right: -4px; font-size: 11px; font-weight: 800; color: var(--muted); }
.colore-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ----------------------------------------------------------------- 3. bumbum */
body[data-theme='enigma-bumbum'] { background: radial-gradient(circle at 50% 110%, #3d1d5c, #0b0717 70%); color: #fdf3ff; }
.bb-wrap { display: flex; flex-direction: column; align-items: center; gap: 26px; width: min(560px, 100%); }
.bb-sky { font-size: 26px; letter-spacing: 12px; color: #ff9ad5; animation: pulse 2s infinite; }
.bb-slots { display: flex; gap: 14px; }
.bb-slot {
  width: clamp(80px, 24vw, 120px); aspect-ratio: 1; border-radius: 20px; border: 3px dashed #6d4b96; background: rgba(255,255,255,.04);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; transition: .2s;
}
.bb-slot.ready { border-color: #ffd36b; background: rgba(255, 211, 107, .08); animation: pulse 1.2s infinite; }
.bb-slot.full { border-style: solid; border-color: #6be0a0; background: rgba(107, 224, 160, .1); }
.bb-pos { font-family: var(--pixel); font-size: 10px; color: #b9a3d8; }
.bb-in { font-size: clamp(34px, 9vw, 52px); min-height: 1.2em; }
.bb-tray { display: flex; gap: 14px; }
.bb-emoji { font-size: clamp(38px, 10vw, 56px); border: 0; background: rgba(255,255,255,.08); border-radius: 18px; padding: 10px 14px; transition: .15s; }
.bb-emoji.sel { background: #ffd36b33; outline: 3px solid #ffd36b; transform: translateY(-6px); }
.bb-emoji.used { opacity: .15; }
body[data-theme='enigma-bumbum'] .hint-small { color: #a593c4; }

/* ------------------------------------------------------------- 4. indovinelli */
body[data-theme='enigma-indovinello'] { background: #e9e0cf; background-image: radial-gradient(circle at 50% 0, #f6efe0, #d8cbb2 90%); }
.riddle-wrap { display: flex; flex-direction: column; align-items: center; gap: 26px; width: 100%; }
.parchment {
  width: min(520px, 100%); background: #fbf5e6; padding: 36px 30px 22px; border-radius: 4px; text-align: center;
  box-shadow: 0 16px 40px rgba(80, 50, 10, .25), inset 0 0 50px rgba(160, 120, 60, .25); position: relative;
}
.riddle-text { font-family: var(--serif); font-size: clamp(18px, 4vw, 22px); line-height: 1.8; color: #3b2614; }
.riddle-text p { margin: 0; }
.riddle-flourish { font-size: 28px; color: #a07a4a; margin-top: 12px; }
body[data-theme='enigma-indovinello'] .enigma-head h1 { font-family: var(--serif); color: #3b2614; }

/* -------------------------------------------------------------- 5. anagramma */
body[data-theme='enigma-anagramma'] { background: #fbf7f0; }
.ana-wrap { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ana-art { width: 100%; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.storia-svg { display: block; width: 100%; height: auto; }
.zona { cursor: pointer; transition: filter .2s, opacity .2s; outline: none; }
.zona:hover, .zona:focus-visible { filter: brightness(1.15) drop-shadow(0 0 8px #fff8); }
.zona.seen { filter: saturate(1.2); }
.ana-bubbles { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.bubble { margin: 0; background: #fff; border: 2px solid #e8dfd0; border-radius: 16px 16px 16px 4px; padding: 12px 16px; font-family: var(--type); font-size: 16px; line-height: 1.5; animation: rise .3s; opacity: .7; }
.bubble.now { opacity: 1; border-color: #7b4dff; }
.ana-question {
  font-family: var(--type); font-size: clamp(20px, 5vw, 28px); text-align: center; margin: 14px 0 4px; padding: 14px 20px;
  background: #1d1a22; color: #f6ecd4; border-radius: 10px; letter-spacing: 1px; transform: rotate(-1deg);
}
.ana-reward { display: flex; flex-direction: column; align-items: center; animation: fade .6s; }
.ana-elefante { width: min(340px, 80vw); animation: bigPop 1s cubic-bezier(.2, 1.4, .4, 1); }
.elefante-svg { width: 100%; height: auto; }

/* --------------------------------------------------------------- 6. pomodori */
body[data-theme='enigma-pomodori'] { background: linear-gradient(#bfe3a8, #7fb069); }
.orto-wrap { width: min(720px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.orto-count { font-family: var(--pixel); font-size: 11px; color: #1f4d1a; min-height: 1em; }
.orto {
  position: relative; width: 100%; height: min(60dvh, 460px); border-radius: 20px; overflow: hidden;
  background: repeating-linear-gradient(90deg, #6b8f3f 0 38px, #5e8236 38px 76px); border: 6px solid #4a3220; box-shadow: inset 0 0 40px rgba(0,0,0,.25);
}
.pomodoro { position: absolute; width: 64px; height: 64px; transform: translate(-50%, -50%); border: 0; background: none; padding: 0; animation: sprout .35s cubic-bezier(.2, 1.6, .4, 1); }
.pomodoro svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 4px rgba(0,0,0,.3)); }
.pomodoro.picked { animation: pick .3s forwards; }
@keyframes sprout { from { transform: translate(-50%, -50%) scale(0); } }
@keyframes pick { to { transform: translate(-50%, -150%) scale(.4); opacity: 0; } }
.orto.done { display: flex; align-items: center; justify-content: center; }
.orto-done { text-align: center; }
.orto-done-text { font-family: var(--pixel); color: #fff; font-size: clamp(12px, 3vw, 16px); text-shadow: 3px 3px 0 #1f4d1a; margin-top: 10px; }

/* ----------------------------------------------------------------- 7. catena */
body[data-theme='enigma-catena'] { background: linear-gradient(135deg, #dfe3e8, #b9c0c9); }
.chain-wrap { width: min(460px, 100%); }
.chain-form { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.chain { display: flex; flex-direction: column; align-items: center; }
.ring {
  border: 8px solid #7d8794; border-radius: 999px; padding: 16px 28px; min-width: 240px; text-align: center; background: #eef1f4;
  box-shadow: inset 0 4px 8px rgba(0,0,0,.15), 0 4px 0 #5d6670; position: relative; margin-top: -4px;
}
.ring:not(:first-child)::before { content: ''; position: absolute; top: -26px; left: 50%; width: 22px; height: 30px; border: 6px solid #6b7480; border-radius: 99px; transform: translateX(-50%); z-index: -1; }
.ring.solved { border-color: #a58a3b; background: #fbf3d9; box-shadow: inset 0 4px 8px rgba(0,0,0,.1), 0 4px 0 #7a6528; }
.ring-word { font-family: var(--pixel); font-size: clamp(14px, 4vw, 18px); letter-spacing: 2px; }
.ring-input { border: 0; background: transparent; font-family: var(--pixel); font-size: clamp(14px, 4vw, 18px); letter-spacing: 3px; text-transform: uppercase; text-align: center; width: calc(var(--len) * 1.4em); max-width: 100%; outline: none; }
.ring-input::placeholder { color: #9aa3ad; }
.ring-len { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ----------------------------------------------------------------- 8. parola */
body[data-theme='enigma-parola'] { background: #1b1426; color: #f3eefe; }
.tiles-form { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.tiles-label { position: relative; cursor: text; }
.tiles { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 10px; }
.tile {
  width: clamp(50px, 15vw, 70px); aspect-ratio: 1; border: 3px solid #3d2f57; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel); font-size: clamp(20px, 6vw, 30px); background: #251b35; transition: .15s;
}
.tile.full { border-color: #b48cff; background: #33244d; animation: pop .15s; }
.tile.cur { border-color: #ffd36b; }
.tiles-input { position: absolute; inset: 0; opacity: 0; width: 100%; font-size: 16px; }

/* -------------------------------------------------------------- 9. talismano */
body[data-theme='enigma-talismano'] { background: radial-gradient(circle at 50% 45%, #2b1f4a, #0a0714 70%); color: #efe6ff; }
.tali-circle { --R: min(38vw, 170px); position: relative; width: calc(var(--R) * 2 + 80px); aspect-ratio: 1; }
.tali-circle.swap { animation: spin .8s ease-in-out; }
.tali-item {
  position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px; border-radius: 50%; border: 2px solid #5b46a0;
  background: radial-gradient(circle at 35% 30%, #4a3a7a, #1e1636); font-size: 30px;
  transform: rotate(calc(360deg / var(--n) * var(--i))) translateY(calc(var(--R) * -1)) rotate(calc(-360deg / var(--n) * var(--i)));
  transition: box-shadow .2s, opacity .3s; box-shadow: 0 0 12px #7b4dff55;
}
.tali-item:hover:not(:disabled) { box-shadow: 0 0 24px #c9a8ff; }
.tali-item.wrong { opacity: .25; filter: grayscale(1); }
.tali-eye { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 44px; animation: pulse 3s infinite; }

/* ---------------------------------------------------------- 10. combinazione */
body[data-theme='enigma-combinazione'] { background: linear-gradient(#3b4048, #1c1f24); color: #e7eaee; }
.safe {
  background: linear-gradient(145deg, #6c737d, #3e444c); border-radius: 22px; padding: 28px 30px; box-shadow: 0 30px 60px #0009, inset 0 2px 0 #fff3, inset 0 -6px 0 #0005;
  display: flex; flex-direction: column; align-items: center; gap: 18px; border: 3px solid #23272d;
}
.safe-bolts { letter-spacing: 30px; color: #9aa3ad; font-size: 10px; }
.safe-wheels { display: flex; gap: 12px; }
.wheel { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wheel-btn { border: 0; background: #2a2f36; color: #cfd5dc; width: 56px; height: 34px; border-radius: 8px; }
.wheel-digit { width: 56px; height: 84px; background: linear-gradient(#111 0, #2a2a2a 30%, #2a2a2a 70%, #111); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--pixel); box-shadow: inset 0 0 12px #000; overflow: hidden; }
.wd-prev, .wd-next { font-size: 12px; color: #555; }
.wd-cur { font-size: 28px; color: #ffd36b; margin: 4px 0; }
.safe-handle { width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, #9aa3ad 20%, #4a5058 22%, #6c737d 60%); box-shadow: 0 4px 8px #0008; transition: transform .5s; position: relative; }
.safe-handle::after { content: ''; position: absolute; left: 50%; top: 8px; width: 8px; height: 54px; margin-left: -4px; background: #2a2f36; border-radius: 4px; }
.safe-handle.turn { transform: rotate(90deg); }

/* ------------------------------------------------------------- enigma in arrivo */
.arrivo { text-align: center; }
.arrivo h1 { font-family: var(--pixel); font-size: clamp(16px, 4vw, 24px); color: var(--muted); }
.arrivo-dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.arrivo-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
.arrivo-dots span:nth-child(2) { animation-delay: .2s; }
.arrivo-dots span:nth-child(3) { animation-delay: .4s; }

/* ------------------------------------------------------------- cose brutte */
body[data-theme='bad'] { background: radial-gradient(circle at 50% 30%, #3a0d1a, #0b0507 75%); color: #ffe9ee; }
body[data-theme='bad'] .footer, body[data-theme='tomb'] .footer { background: transparent; border-color: transparent; color: #6b4a52; }
.roulette { width: min(640px, 100%); text-align: center; }
.bad-h { font-family: var(--pixel); font-size: clamp(14px, 4vw, 22px); color: #ff6b8b; margin: 0 0 10px; text-shadow: 3px 3px 0 #000; }
.bad-sub { opacity: .75; margin: 0 0 30px; }
.reel { position: relative; }
.reel-window { overflow: hidden; border-radius: 16px; background: #1a0a10; border: 3px solid #5a1a2a; box-shadow: inset 0 0 30px #000; padding: 14px 0; mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); }
.reel-strip { display: flex; will-change: transform; }
.reel-item { flex: 0 0 90px; font-size: 52px; text-align: center; }
.reel-item.picked { animation: bigPop .6s; filter: drop-shadow(0 0 16px #ff6b8b); }
.reel-marker { position: absolute; left: 50%; top: -12px; bottom: -12px; width: 96px; margin-left: -48px; border: 3px solid #ffd36b; border-radius: 14px; pointer-events: none; box-shadow: 0 0 20px #ffd36b66; }
.bad-card { margin-top: 30px; background: #1d0b11; border: 2px solid #5a1a2a; border-radius: 18px; padding: 26px; animation: rise .5s; }
.bad-card.hidden { display: none; }
.bad-emoji { font-size: 64px; }
.bad-title { font-family: var(--serif); font-size: clamp(24px, 6vw, 34px); margin: 8px 0 12px; }
.bad-desc p { line-height: 1.7; margin: 0 0 10px; }
.sblocco { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bad-img { max-width: 100%; max-height: 50vh; border-radius: 14px; margin: 10px 0; box-shadow: 0 10px 30px #0008; }
.unlock-timer p { margin: 12px 0 8px; opacity: .8; }
.countdown { display: flex; gap: 10px; justify-content: center; }
.cd-cell { background: #1d0b11; border: 2px solid #5a1a2a; border-radius: 12px; padding: 10px 8px; min-width: 66px; }
.cd-cell b { display: block; font-family: var(--pixel); font-size: 20px; color: #ffd36b; }
.cd-cell span { font-size: 11px; opacity: .7; }
.countdown.big .cd-cell { min-width: 76px; }
.countdown.big .cd-cell b { font-size: 26px; }
.unlock-form { width: 100%; margin-top: 20px; }
.unlock-form.locked { opacity: .45; }
.unlock-label { display: block; margin-bottom: 10px; font-size: 14px; opacity: .8; }
.unlock-row { display: flex; gap: 10px; }
.unlock-input { flex: 1; min-width: 0; padding: 14px 18px; border-radius: 999px; border: 1.5px solid #5a1a2a; background: #1a0a10; color: #fff; font-family: var(--pixel); font-size: 14px; letter-spacing: 3px; text-align: center; text-transform: uppercase; outline: none; }
.unlock-input:focus { border-color: #ff6b8b; }
.unlock-msg { color: #ff8fa3; min-height: 1.4em; }
.mago-link { margin-top: 40px; color: #b88a96; font-size: 14px; }

body[data-theme='tomb'] { background: linear-gradient(#1a1a22, #08080b); color: #e6e3ec; }
.mago-morto, .mago-vivo { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tomb { font-size: 80px; }
.mm-text { line-height: 1.75; font-size: 16px; opacity: .9; }
.mm-over { font-family: var(--serif); font-size: clamp(22px, 5vw, 30px); letter-spacing: 3px; margin: 14px 0 4px; }
.mm-btn { background: #e6e3ec; color: #111; border-color: #e6e3ec; font-family: var(--pixel); font-size: 12px; padding: 16px 26px; }
.back-link { color: #8a8698; margin-top: 30px; font-size: 14px; }
body[data-theme='tomb'] .cd-cell { background: #15151c; border-color: #33323f; }

/* ------------------------------------------------------------- pannello */
body[data-theme='admin'] { background: #f5f3f8; }
body[data-theme='admin'] .stage { display: block; padding: 0; }
.adm { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100dvh - 130px); }
.adm-nav { background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.adm-tab { border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px; font-weight: 600; display: flex; gap: 10px; }
.adm-tab.on { background: #efe9ff; color: #4b2db8; }
.adm-body { padding: 24px clamp(16px, 3vw, 36px); max-width: 1100px; }
.adm-sec h2 { margin: 0 0 14px; }
.adm-sec h3 { margin: 28px 0 10px; font-size: 16px; }
.danger-zone { color: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card-l { font-size: 12px; color: var(--muted); }
.card-v { font-weight: 700; margin-top: 4px; word-break: break-word; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.f { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.inline-form .f { margin: 0; }
.f-l { font-size: 13px; font-weight: 600; }
.f-h { color: var(--muted); font-size: 12px; }
.f input, .f textarea, .f select { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; width: 100%; }
.f input:focus, .f textarea:focus, .f select:focus { border-color: var(--accent); }
.f input[type='number'] { width: 100px; }
.f input[type='file'] { border: 0; padding: 0; }
.emoji-in { font-size: 24px; width: 90px !important; text-align: center; }
.chk { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.form.narrow { max-width: 520px; }
.adm-modal.wide { width: min(760px, 100%); }
textarea.mono { font-size: 13px; }
.tag { display: inline-block; font-size: 11px; border-radius: 99px; padding: 2px 8px; background: #efe9ff; color: #4b2db8; margin: 0 4px 0 0; font-weight: 600; vertical-align: middle; }
.tag.ok { background: #e3f6ec; color: var(--ok); }
.tag.warn { background: #fdeaea; color: var(--danger); }
.cb-list, .en-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cb-item, .en-item { display: flex; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.cb-item.drawn, .cb-item.off, .en-item.off { opacity: .6; }
.cb-emoji { font-size: 32px; width: 48px; text-align: center; }
.cb-main, .en-main { flex: 1; min-width: 0; }
.cb-title, .en-title { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cb-desc { color: var(--muted); font-size: 13px; margin: 3px 0 6px; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cb-act, .en-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cb-preview { max-width: 200px; max-height: 140px; border-radius: 8px; display: block; margin-bottom: 8px; }
.en-n { font-family: var(--pixel); font-size: 12px; width: 30px; text-align: center; color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: #faf8fd; font-size: 12px; color: var(--muted); }
.tbl tr.used { opacity: .55; }
.tbl td.ok { color: var(--ok); }
.tbl td.bad { color: var(--danger); }
.events { list-style: none; padding: 0; font-size: 14px; }
.events li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.adm-hud { grid-template-columns: 1fr auto; }

@media (max-width: 760px) {
  .adm { grid-template-columns: 1fr; }
  .adm-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .adm-tab { white-space: nowrap; }
  .cb-item, .en-item { flex-wrap: wrap; }
  .tbl { display: block; overflow-x: auto; }
}

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