:root{
  --bg:#efe5ff;
  --bg2:#f8f4ff;
  --panel:#ffffff;
  --panelSoft:rgba(255,255,255,.82);
  --ink:#2f2450;
  --muted:#786b9f;
  --primary:#6f42dc;
  --primary2:#915df6;
  --primary3:#b592ff;
  --line:#ded3f4;
  --shadow:0 24px 60px rgba(67,38,130,.16);
  --shadowSoft:0 10px 26px rgba(67,38,130,.09);
  --cell:56px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden}
body{
  font-family:"Nunito",ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.95) 0, rgba(255,255,255,.55) 10%, rgba(255,255,255,0) 26%),
    radial-gradient(circle at 78% 18%, rgba(255,255,255,.78) 0, rgba(255,255,255,.35) 12%, rgba(255,255,255,0) 25%),
    radial-gradient(circle at 50% -12%, #fefcff 0, #f6efff 36%, #e9dcff 100%);
}
button{font:inherit}
img{display:block;max-width:100%}
h1,h2,h3,.btn,.title-stack,strong,.pill,.rule-strip span{font-family:"Baloo 2","Nunito",sans-serif}
.app-shell{height:100vh;position:relative;overflow:hidden}
.screen{display:none;height:100vh;position:relative;overflow:hidden}
.screen.active{display:flex;align-items:center;justify-content:center;padding:24px}
#home{background:linear-gradient(rgba(241,231,255,.40),rgba(245,238,255,.64)),url("../img/hero-vaffandoku.webp") center/cover fixed no-repeat}
#game{background:linear-gradient(rgba(247,242,255,.38),rgba(239,229,255,.52)),url("../img/bg-pastel.webp") center/cover fixed no-repeat}
.home-decor{position:absolute;border-radius:999px;filter:blur(18px);opacity:.6;pointer-events:none}
.home-decor-a{width:320px;height:320px;left:-90px;top:60px;background:radial-gradient(circle,#ffe8b8 0,#ffd2ff 50%,transparent 72%)}
.home-decor-b{width:380px;height:380px;right:-120px;bottom:10px;background:radial-gradient(circle,#d4c3ff 0,#ffd6ec 48%,transparent 72%)}
.hero-card{
  width:min(1160px,96vw);
  max-height:min(94vh,820px);
  background:rgba(255,255,255,.84);
  backdrop-filter:blur(18px);
  border:1px solid rgba(233,224,252,.92);
  border-radius:34px;
  box-shadow:var(--shadow);
  display:grid;
  grid-template-columns:minmax(300px,.86fr) minmax(0,1.28fr);
  overflow:hidden;
  position:relative;
  z-index:1;
}
.hero-card:before{content:"";position:absolute;inset:0;background:linear-gradient(135deg,rgba(255,255,255,.26),rgba(255,255,255,0));pointer-events:none}
.hero-rabbit{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100%;
  padding:40px 24px 58px;
  background:radial-gradient(circle at 50% 28%, rgba(255,255,255,.26) 0, rgba(255,255,255,0) 36%), linear-gradient(160deg,#6f42dc 0,#8f63ef 58%,#c0a2ff 100%);
}
.hero-rabbit-glow{position:absolute;width:300px;height:300px;border-radius:50%;background:radial-gradient(circle, rgba(255,255,255,.32) 0, rgba(255,255,255,.08) 48%, rgba(255,255,255,0) 72%)}
.hero-rabbit img{width:min(86%,360px);filter:drop-shadow(0 24px 30px rgba(0,0,0,.18));position:relative;z-index:1}
.hero-badge{position:absolute;left:24px;top:24px;padding:10px 16px;border-radius:999px;font-size:12px;font-weight:900;letter-spacing:.12em;color:#fff;background:rgba(255,255,255,.18);border:1px solid rgba(255,255,255,.28);box-shadow:0 10px 26px rgba(24,14,53,.18)}
.hero-copy{padding:42px 48px;display:flex;flex-direction:column;justify-content:center;position:relative;z-index:1;overflow:auto}
.eyebrow{font-size:12px;letter-spacing:.18em;font-weight:900;color:var(--primary)}
h1{font-size:clamp(48px,7vw,96px);line-height:.88;margin:10px 0 14px;letter-spacing:-.045em;color:transparent;-webkit-text-stroke:1px rgba(72,33,160,.12);background:linear-gradient(180deg,#8d63ef 0,#6f42dc 56%,#4d24bc 100%);-webkit-background-clip:text;background-clip:text;text-shadow:0 10px 18px rgba(111,66,220,.12)}
.tagline{font-size:20px;line-height:1.45;color:#4f4568;margin:0 0 22px;max-width:640px}
.rules-mini{display:grid;gap:10px;margin:4px 0 22px}
.rules-mini div{display:flex;align-items:center;gap:12px;background:#faf7ff;border:1px solid #eadff9;border-radius:18px;padding:11px 13px;box-shadow:var(--shadowSoft)}
.rules-mini b{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(180deg,#fff8ff,#efe4ff);color:var(--primary);font-size:16px}
.rules-mini span{font-weight:850}
.home-actions{display:flex;gap:12px;flex-wrap:wrap}
.btn{border:0;border-radius:999px;padding:13px 20px;font-weight:800;cursor:pointer;transition:transform .15s ease, box-shadow .15s ease, filter .15s ease;background:#fff;border:1px solid var(--line);color:var(--ink);box-shadow:0 6px 16px rgba(40,25,80,.07)}
.btn:hover{transform:translateY(-1px);box-shadow:0 10px 20px rgba(40,25,80,.1)}
.btn:active{transform:translateY(0) scale(.98)}
.btn.primary{background:linear-gradient(135deg,var(--primary),var(--primary2));color:#fff;border-color:transparent;box-shadow:0 14px 28px rgba(111,66,220,.28)}
.btn.ghost{background:#faf8ff}
.btn.accent{background:linear-gradient(135deg,#8757ee,#6f42dc);color:#fff;border-color:transparent;box-shadow:0 14px 26px rgba(111,66,220,.24)}
.btn.small{padding:10px 18px;font-size:16px}
.microcopy{font-size:14px;color:var(--muted);margin:16px 0 0;max-width:700px;line-height:1.45}
#game.screen.active{display:block;padding:0}
.topbar{height:72px;padding:10px 20px;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;border-bottom:1px solid rgba(225,216,245,.88);background:rgba(248,243,255,.74);backdrop-filter:blur(14px);position:sticky;top:0;z-index:12}
.title-stack{text-align:center}
.title-stack strong{display:block;font-size:28px;line-height:1;color:var(--primary);text-shadow:0 2px 0 rgba(255,255,255,.85)}
.title-stack span{font-size:15px;color:var(--muted);font-weight:800}
.top-actions{justify-self:end;display:flex;gap:10px}
.icon-btn{width:48px;height:48px;border-radius:50%;border:1px solid #ded5ee;background:#fff;box-shadow:0 7px 18px rgba(40,25,80,.08);font-size:23px;font-weight:900;cursor:pointer;color:#3f2693;transition:transform .15s ease, box-shadow .15s ease}
.icon-btn:hover{transform:translateY(-1px);box-shadow:0 11px 22px rgba(40,25,80,.13)}
.game-layout{height:calc(100vh - 72px);display:grid;grid-template-columns:minmax(180px,250px) minmax(0,1fr) minmax(170px,220px);gap:16px;align-items:center;padding:12px 16px}
.side-panel{display:flex;flex-direction:column;gap:12px}
.mascot-panel{align-items:center;justify-content:center;position:relative}
.mascot-cloud{position:absolute;width:220px;height:220px;border-radius:50%;background:radial-gradient(circle,rgba(255,255,255,.7) 0, rgba(255,255,255,.18) 50%, transparent 72%);filter:blur(6px)}
.mascot-hero{width:min(230px,100%);filter:drop-shadow(0 18px 24px rgba(0,0,0,.12));position:relative;z-index:1}
.speech-card,.help-card,.tip-card{background:rgba(255,255,255,.84);backdrop-filter:blur(12px);border:1px solid rgba(226,216,245,.95);border-radius:22px;padding:16px 16px 14px;box-shadow:var(--shadowSoft)}
.speech-card strong,.help-card h3,.tip-card h3{display:block;margin:0 0 5px;font-size:22px;color:#4f26c2}
.speech-card p,.help-card p,.tip-card p{margin:0;font-size:14px;line-height:1.4;color:#574e72}
.help-card .help-icon{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(180deg,#fff,#f1e8ff);font-size:22px;margin-bottom:8px;box-shadow:0 8px 16px rgba(111,66,220,.12)}
.help-card p + p,.tip-card p + p{margin-top:7px}
.game-panel{width:min(920px,100%);margin:0 auto;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2px 4px;height:100%}
.title-banner{text-align:center;margin-bottom:2px}
.title-banner h2{margin:0;font-size:clamp(42px,6vw,78px);line-height:.88;color:transparent;background:linear-gradient(180deg,#8557ef 0,#6838d9 56%,#4c20bc 100%);-webkit-background-clip:text;background-clip:text;text-shadow:0 10px 24px rgba(111,66,220,.12)}
.title-banner p{margin:0;font-size:13px;font-weight:800;color:var(--muted)}
.status-row{display:flex;gap:10px;justify-content:center;margin-bottom:8px;flex-wrap:wrap}
.pill{background:rgba(255,255,255,.9);border:1px solid #ded5ee;border-radius:999px;padding:9px 16px;font-weight:900;font-size:16px;color:#39238b;box-shadow:0 8px 18px rgba(40,25,80,.07)}
.pill-timer::before{content:"⏱ ";font-size:.95em}
.pill-fire::before{content:"🔥 ";font-size:.95em}
.rabbit-pill{color:#5632bd}
.rule-strip{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-bottom:8px}
.rule-strip span{background:rgba(255,255,255,.88);border:1px solid #e2daef;border-radius:16px;padding:7px 13px;font-size:14px;font-weight:800;color:#5e5571;box-shadow:0 6px 14px rgba(40,25,80,.06)}
.board-wrap{max-width:94vw;max-height:calc(100vh - 250px);overflow:hidden;padding:6px}
.board{--n:5;display:grid;grid-template-columns:repeat(var(--n),var(--cell));grid-template-rows:repeat(var(--n),var(--cell));border:7px solid rgba(255,255,255,.98);border-radius:24px;overflow:hidden;box-shadow:0 16px 40px rgba(48,32,79,.14),0 0 0 1px rgba(98,75,153,.14), inset 0 0 0 3px rgba(255,255,255,.35);touch-action:none;background:#fff}
.cell{position:relative;width:var(--cell);height:var(--cell);border-right:1px solid rgba(65,53,83,.16);border-bottom:1px solid rgba(65,53,83,.16);display:grid;place-items:center;user-select:none;cursor:pointer;transition:filter .12s ease,transform .08s ease, box-shadow .12s ease;appearance:none;-webkit-tap-highlight-color:transparent}
.cell:hover{filter:brightness(.985)}
.cell:active{transform:scale(.985)}
.cell .mark{font-weight:950;font-size:clamp(18px,calc(var(--cell)*.38),30px);color:rgba(48,42,66,.68);line-height:1}
.cell .rabbit{width:80%;height:80%;object-fit:contain;filter:drop-shadow(0 3px 3px rgba(0,0,0,.18));pointer-events:none}
.cell.error{animation:shake .18s linear 2;outline:3px solid #e33e73;outline-offset:-3px;z-index:2;box-shadow:inset 0 0 0 2px rgba(255,255,255,.4)}
.cell.hint{animation:pulse 1s ease 2;z-index:2}
.cell.boundary-top{border-top:3px solid rgba(70,57,104,.34)}
.cell.boundary-left{border-left:3px solid rgba(70,57,104,.34)}
.cell.boundary-right{border-right:3px solid rgba(70,57,104,.34)}
.cell.boundary-bottom{border-bottom:3px solid rgba(70,57,104,.34)}

.cell.fixed-rabbit{box-shadow:inset 0 0 0 3px rgba(255,255,255,.72), inset 0 0 0 6px rgba(116,70,224,.18)}
.cell.fixed-rabbit:after{content:"★";position:absolute;right:3px;top:1px;font-size:clamp(8px,calc(var(--cell)*.18),12px);color:#7142db;text-shadow:0 1px 0 #fff;pointer-events:none}
body.dragging-x,body.dragging-x *{cursor:crosshair!important;user-select:none!important}
body.dragging-x .cell{filter:saturate(.95)}
.controls{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:10px}
.message{min-height:24px;margin-top:8px;text-align:center;font-size:14px;font-weight:900;color:#6f42dc;padding:2px 10px}
.modal{border:0;background:transparent;padding:0;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:visible}
.modal::backdrop{background:rgba(28,20,45,.52);backdrop-filter:blur(5px)}
.modal-card{width:min(560px,92vw);max-height:min(88vh,700px);background:#fff;border-radius:28px;padding:24px 24px 22px;box-shadow:var(--shadow);position:relative;border:1px solid rgba(226,216,245,.9);overflow:hidden}
.modal-card h2{margin:0;font-size:clamp(28px,4vw,42px);color:#4f26c2;line-height:1.05}
.modal-card p{line-height:1.5;color:#5f5672;font-size:15px}
.modal-close{position:absolute;right:14px;top:14px;width:36px;height:36px;border-radius:50%;border:1px solid #ddd3ec;background:#fff;font-size:24px;cursor:pointer;color:#4727a8}.modal-close:hover{transform:translateY(-1px)}
.win-card{text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px}
.win-rabbit{width:clamp(92px,16vh,150px);margin:0 auto 4px;filter:drop-shadow(0 12px 18px rgba(65,35,130,.18))}
.win-card .eyebrow{font-size:11px}
.win-card p{margin:0;max-width:460px}
.win-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:8px 0 10px;width:100%}
.win-stats div{background:#f7f3ff;border-radius:16px;padding:12px 8px}.win-stats b{display:block;font-size:20px;color:#4b22ba;line-height:1.1}.win-stats span{font-size:11px;color:var(--muted);font-weight:900;text-transform:uppercase;letter-spacing:.08em}.win-card .btn{width:100%;margin-top:0}
@keyframes shake{25%{transform:translateX(-3px)}75%{transform:translateX(3px)}}
@keyframes pulse{50%{box-shadow:inset 0 0 0 5px rgba(255,255,255,.85),0 0 0 5px #8e62f0}}
@media(max-width:1460px), (max-height:850px){
  .game-layout{grid-template-columns:1fr;gap:10px;padding:10px 12px}
  .side-panel{display:none}
  .game-panel{width:min(960px,100%)}
  .board-wrap{max-height:calc(100vh - 230px)}
}
@media(max-width:760px){
  #home{overflow-y:auto;-webkit-overflow-scrolling:touch}
  #home.screen.active{align-items:flex-start;padding:12px}
  .screen.active{padding:12px}
  .hero-card{grid-template-columns:1fr;max-height:none;min-height:calc(100vh - 24px);height:auto;border-radius:26px;overflow:visible}
  .hero-rabbit{position:absolute;top:14px;right:14px;left:auto;min-height:0;width:118px;height:118px;padding:0;background:none;z-index:3}
  .hero-rabbit img{width:118px}
  .hero-rabbit-glow{width:124px;height:124px}
  .hero-badge{top:14px;left:14px;padding:8px 12px;font-size:10px;max-width:170px}
  .hero-copy{padding:86px 18px 20px;overflow:visible}
  .hero-copy .eyebrow{display:block;max-width:170px;font-size:10px;letter-spacing:.14em;margin-bottom:4px}
  h1{font-size:44px;line-height:.92;margin:4px 0 10px;max-width:calc(100% - 112px)}
  .tagline{font-size:15px;line-height:1.38;margin:0 0 14px;color:#544b6d}
  .rules-mini{gap:8px;margin:4px 0 14px}
  .rules-mini div{padding:8px 10px;border-radius:16px;gap:10px;align-items:flex-start}
  .rules-mini b{width:26px;height:26px;font-size:15px;flex:0 0 26px}
  .rules-mini span{font-size:13px;line-height:1.22}
  .home-actions{gap:10px}
  .home-actions .btn{width:100%;justify-content:center}
  .microcopy{display:none}
  .topbar{height:62px;padding:8px 10px}
  .title-stack strong{font-size:21px}
  .title-stack span{font-size:12px}
  .icon-btn{width:42px;height:42px;font-size:20px}
  .game-layout{height:calc(100vh - 62px);padding:8px}
  .title-banner h2{font-size:44px}
  .title-banner p{font-size:12px}
  .status-row{gap:8px;margin-bottom:7px}
  .pill{padding:7px 10px;font-size:13px}
  .rule-strip{gap:6px;margin-bottom:7px}
  .rule-strip span{font-size:11px;padding:6px 8px}
  .board-wrap{max-height:calc(100vh - 220px);padding:4px}
  .controls{margin-top:8px;gap:8px}
  .btn.small{padding:8px 13px;font-size:14px}
  .message{font-size:12px;min-height:20px;margin-top:6px}
  .modal-card{padding:20px 16px 18px;max-height:min(90vh,620px)}
  .modal-card p{font-size:14px}
  .win-stats{gap:8px}
  .win-stats div{padding:10px 6px}
  .win-stats b{font-size:18px}
}
@media(max-width:420px){
  .hero-rabbit{width:104px;height:104px;top:16px;right:12px}
  .hero-rabbit img{width:104px}
  .hero-rabbit-glow{width:110px;height:110px}
  .hero-copy{padding:82px 16px 18px}
  h1{font-size:40px;max-width:calc(100% - 98px)}
  .tagline{font-size:14px}
  .rules-mini span{font-size:12px}
  .hero-badge{font-size:9px;max-width:150px}
}
@media(max-height:720px) and (min-width:761px){
  .topbar{height:66px}
  .game-layout{height:calc(100vh - 66px);padding:8px 10px}
  .title-banner h2{font-size:50px}
  .status-row,.rule-strip{margin-bottom:6px}
  .pill{padding:7px 12px;font-size:14px}
  .board-wrap{max-height:calc(100vh - 205px)}
  .controls{margin-top:8px}
  .modal-card{padding:18px 20px 18px;max-height:min(88vh,560px)}
  .win-rabbit{width:110px}
}

/* Errori e vite */
.pill-error{color:#a22a4a}
.pill-error.danger{background:#fff1f4;border-color:#f2b2c2;color:#d01f4b;animation:errorPulse .9s ease-in-out infinite alternate}
.wrong-mark{color:#e12643!important;text-shadow:0 2px 0 rgba(255,255,255,.75),0 0 12px rgba(225,38,67,.18);font-size:clamp(22px,calc(var(--cell)*.46),36px)!important}
.error-card{text-align:center;display:flex;flex-direction:column;align-items:center;gap:8px;border:2px solid rgba(232,48,83,.16);background:linear-gradient(180deg,#fff 0,#fff8fa 100%)}
.error-rabbit{width:clamp(90px,16vh,145px);filter:drop-shadow(0 12px 18px rgba(177,29,66,.16));margin:0 auto}
.error-card .eyebrow{color:#d42b55}
.error-card h2{color:#c91f49}
.error-card p{margin:0;max-width:450px}
.error-counter{width:min(260px,100%);display:flex;align-items:center;justify-content:space-between;padding:9px 14px;border-radius:16px;background:#fff0f4;border:1px solid #f4c1ce;color:#9e2845;font-weight:900}
.error-counter strong{font-size:22px;color:#d51e4c}
.error-card .btn{width:100%;margin-top:4px;background:linear-gradient(135deg,#e83d68,#ba1e49);box-shadow:0 12px 24px rgba(194,31,74,.22)}
@keyframes errorPulse{from{box-shadow:0 8px 18px rgba(211,34,76,.08)}to{box-shadow:0 8px 24px rgba(211,34,76,.2)}}
