:root{
    --bg-a:#ffd9e8;
    --bg-b:#ffe9d6;
    --bg-c:#dff1ff;
    --panel:#ffffffb8;
    --panel-border:#ffffffd0;
    --text:#4a3357;
    --text-soft:#8c7a9c;
    --accent:#ff5fa2;
    --accent-2:#8a5cff;
    --tile-bg:#ffffffa8;
    --tile-border:#ffffffe0;
    --shadow:0 10px 26px rgba(150,90,150,0.16), 0 2px 6px rgba(150,90,150,0.10);
    --shadow-soft:0 4px 14px rgba(150,90,150,0.12);
    --success:#3ecf8e;
    --danger:#ff6b6b;
    --cell: clamp(26px, calc((100vw - 96px) / 8), 50px);
    --c0:#ff8fab; --c1:#ff7a7a; --c2:#c98a5c; --c3:#ffb15e; --c4:#ffd166; --c5:#b98af0;
  }
  *{box-sizing:border-box;}
  html,body{
    margin:0; padding:0; min-height:100%;
    color:var(--text);
    overflow-x:hidden;
  }
  body{
    position:relative;
    display:flex; flex-direction:column; align-items:center;
    padding:20px 14px 44px; min-height:100vh;
    font-family:'Nunito','Segoe UI',system-ui,-apple-system,sans-serif;
    background:
      radial-gradient(ellipse 60% 40% at 15% 10%, var(--bg-a), transparent 60%),
      radial-gradient(ellipse 60% 45% at 90% 15%, var(--bg-c), transparent 60%),
      radial-gradient(ellipse 70% 50% at 50% 100%, var(--bg-b), transparent 60%),
      linear-gradient(160deg, var(--bg-a), var(--bg-c));
    background-attachment:fixed;
  }
  body::before, body::after{
    content:''; position:fixed; border-radius:50%; filter:blur(50px); opacity:0.5; z-index:-1; pointer-events:none;
  }
  body::before{ width:260px; height:260px; top:-60px; left:-60px; background:var(--accent); opacity:0.18; }
  body::after{ width:300px; height:300px; bottom:-80px; right:-60px; background:var(--accent-2); opacity:0.16; }

  h1{
    font-family:'Fredoka','Nunito',sans-serif;
    font-size:clamp(26px,6vw,36px);
    margin:4px 0 2px;
    background:linear-gradient(90deg,var(--accent),var(--accent-2));
    -webkit-background-clip:text; background-clip:text; color:transparent;
    font-weight:700; letter-spacing:0.3px;
  }
  .subtitle{ color:var(--text-soft); font-size:13.5px; margin-bottom:14px; text-align:center; max-width:340px; line-height:1.5; }

  .topbar{ display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap; justify-content:center; }
  .icon-btn{
    position:relative; overflow:hidden;
    background:linear-gradient(160deg, color-mix(in srgb, var(--accent-2) 55%, white), var(--accent-2));
    border:2.5px solid color-mix(in srgb, var(--accent-2) 65%, black);
    border-radius:999px; padding:8px 16px; font-size:13px; font-weight:800;
    font-family:'Nunito',sans-serif;
    color:#fff; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; justify-content:center;
    text-shadow:0 1px 2px rgba(0,0,0,0.25);
    box-shadow:
      0 4px 0 color-mix(in srgb, var(--accent-2) 65%, black),
      0 7px 12px rgba(90,50,140,0.3);
    transition:transform .12s cubic-bezier(.34,1.56,.64,1), box-shadow .12s ease;
  }
  .icon-btn::before{
    content:''; position:absolute; top:10%; left:14%; width:45%; height:32%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.8), transparent 70%);
    border-radius:50%; pointer-events:none;
  }
  .icon-btn:hover{
    transform:translateY(-1px);
    box-shadow:0 5px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 9px 14px rgba(90,50,140,0.34);
  }
  .icon-btn:active{
    transform:translateY(3px) scale(0.98);
    box-shadow:0 1px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 2px 4px rgba(90,50,140,0.24);
  }
  select.icon-btn{ -webkit-appearance:none; appearance:none; }

  .lives-bar{
    position:relative; overflow:hidden;
    display:flex; align-items:center; gap:8px; justify-content:center;
    width:fit-content; flex:none;
    background:linear-gradient(160deg, #ffffff, var(--tile-bg));
    border:2.5px solid color-mix(in srgb, var(--accent-2) 35%, white); border-radius:999px;
    padding:7px 16px;
    box-shadow:
      0 4px 0 color-mix(in srgb, var(--accent-2) 45%, #8a7a98),
      0 7px 12px rgba(120,90,140,0.2);
    font-size:13px; font-weight:700;
  }
  .lives-bar::before{
    content:''; position:absolute; top:10%; left:12%; width:35%; height:35%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.85), transparent 70%);
    border-radius:50%; pointer-events:none;
  }
  #livesHearts{ font-size:14px; position:relative; z-index:1; }
  .lives-timer{ color:var(--text-soft); font-weight:600; font-size:11.5px; position:relative; z-index:1; }

  .bonus-lives-row{
    display:flex; align-items:center; justify-content:center; gap:12px;
    flex-wrap:wrap; margin-bottom:14px;
  }

  .hud{ width:100%; max-width:440px; display:flex; justify-content:center; gap:16px; margin-bottom:16px; }
  .hud-card{
    position:relative;
    flex:none; width:62px; height:40px; border-radius:16%;
    background:linear-gradient(160deg, color-mix(in srgb, var(--accent-2) 50%, white), var(--accent-2));
    border:2px solid color-mix(in srgb, var(--accent-2) 65%, black);
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    padding:2px; text-align:center;
    box-shadow:
      0 3px 0 color-mix(in srgb, var(--accent-2) 65%, black),
      0 5px 9px rgba(90,50,140,0.3);
  }
  .hud-card::before{
    content:''; position:absolute; top:10%; left:16%; width:34%; height:24%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.8), transparent 70%);
    border-radius:50%; pointer-events:none;
  }
  .hud-label{
    font-size:6.5px; text-transform:uppercase; letter-spacing:0.3px; font-weight:700;
    color:rgba(255,255,255,0.85); position:relative; z-index:1;
  }
  .hud-value{
    font-family:'Fredoka',sans-serif; font-size:13px; font-weight:700;
    color:#fff; text-shadow:0 1px 2px rgba(0,0,0,0.25);
    white-space:normal; position:relative; z-index:1; line-height:1.05; padding:0 1px;
  }

  .progress-wrap{
    width:100%; max-width:440px; background:var(--tile-bg); border:1px solid var(--panel-border);
    border-radius:999px; height:14px; overflow:hidden; margin-bottom:18px; box-shadow:inset 0 2px 4px rgba(0,0,0,0.08);
  }
  .progress-bar{
    height:100%; width:0%; border-radius:999px;
    background:linear-gradient(90deg,var(--accent),var(--accent-2));
    box-shadow:0 0 10px rgba(255,95,162,0.5);
    transition:width .4s cubic-bezier(.34,1.2,.64,1);
  }

  .board-wrap{ max-width:96vw; overflow-x:auto; }
  #board{
    display:grid; gap:6px;
    grid-template-columns: repeat(8, var(--cell));
    background:linear-gradient(160deg, var(--panel), var(--tile-bg));
    border:1px solid var(--panel-border);
    border-radius:24px; padding:12px; box-shadow:var(--shadow);
    backdrop-filter:blur(10px);
    touch-action:manipulation; user-select:none;
    position:relative;
  }
  .cell{
    width:var(--cell); height:var(--cell);
    border-radius:16px;
    display:flex; align-items:center; justify-content:center;
    font-size:calc(var(--cell) * 0.72);
    line-height:1;
    cursor:pointer; position:relative;
    background:
      radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--candy) 55%, white) 0%, var(--candy) 55%, color-mix(in srgb, var(--candy) 75%, black) 100%);
    box-shadow:
      0 4px 0 color-mix(in srgb, var(--candy) 70%, black),
      0 6px 12px color-mix(in srgb, var(--candy) 55%, transparent),
      inset 0 2px 3px rgba(255,255,255,0.5);
    transition:transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, filter .16s ease;
  }
  .cell::after{
    content:'';
    position:absolute; top:12%; left:16%; width:40%; height:30%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.75), transparent 70%);
    border-radius:50%;
    pointer-events:none;
  }
  .candy-icon{ width:56%; height:56%; position:relative; z-index:1; filter:drop-shadow(0 1px 2px rgba(0,0,0,0.25)); pointer-events:none; }
  .special-badge{
    position:absolute; top:1px; right:1px; width:16px; height:16px; border-radius:50%;
    background:rgba(255,255,255,0.9); color:var(--accent-2); font-size:10px; font-weight:800;
    display:flex; align-items:center; justify-content:center; z-index:2; pointer-events:none;
  }
  .cell:active{ transform:scale(0.88) translateY(2px); box-shadow:0 1px 0 color-mix(in srgb, var(--candy) 70%, black), inset 0 2px 3px rgba(255,255,255,0.4); }
  .cell.selected{
    transform:scale(0.92) translateY(1px);
    filter:brightness(1.08) saturate(1.15);
    box-shadow:0 0 0 3px var(--accent), 0 3px 0 color-mix(in srgb, var(--candy) 70%, black), 0 8px 18px rgba(255,95,162,0.35);
  }
  .cell.real-candy{
    background-size:cover; background-position:center; background-repeat:no-repeat;
    box-shadow:0 4px 8px rgba(90,50,110,0.25), inset 0 1px 1px rgba(255,255,255,0.3);
  }
  .cell.real-candy::after{ display:none; }
  .cell.real-candy:active{ box-shadow:0 2px 4px rgba(90,50,110,0.2); }
  .cell.real-candy.selected{ box-shadow:0 0 0 3px var(--accent), 0 8px 18px rgba(255,95,162,0.35); }
  .cell.matched{ animation:pop .3s cubic-bezier(.34,1.56,.64,1) forwards; }
  .cell.new{ animation:dropIn .32s cubic-bezier(.34,1.2,.64,1); }
  .cell.special-row, .cell.special-col{ box-shadow:0 0 0 2px var(--accent-2), 0 4px 0 color-mix(in srgb, var(--candy) 70%, black); }
  .cell.special-bomb{
    animation:pulse 1.1s ease-in-out infinite;
    box-shadow:0 0 0 2px gold, 0 4px 0 color-mix(in srgb, var(--candy) 70%, black);
  }
  .cell.special-areabomb{
    animation:pulseRed 0.9s ease-in-out infinite;
    box-shadow:0 0 0 3px #ff4d4d, 0 4px 0 color-mix(in srgb, var(--candy) 70%, black);
    cursor:pointer;
  }
  @keyframes pulseRed{ 0%,100%{ filter:brightness(1); } 50%{ filter:brightness(1.4) saturate(1.3); } }
  @keyframes pop{ 0%{ transform:scale(1); opacity:1; } 60%{ transform:scale(1.15); } 100%{ transform:scale(0.15) rotate(20deg); opacity:0; } }
  @keyframes dropIn{ 0%{ transform:translateY(-42px) scale(0.8); opacity:0.4; } 70%{ transform:translateY(4px) scale(1.03); opacity:1;} 100%{ transform:translateY(0) scale(1); opacity:1; } }
  @keyframes pulse{ 0%,100%{ filter:brightness(1); } 50%{ filter:brightness(1.3) saturate(1.2); } }
  .bird-strike{
    position:absolute; display:flex; align-items:center; justify-content:center;
    font-size:1.6em; z-index:20; pointer-events:none;
    animation: birdSwoop .5s ease-out forwards;
    filter:drop-shadow(0 3px 4px rgba(0,0,0,0.35));
  }
  @keyframes birdSwoop{
    0%{ transform:scale(0.3) rotate(-25deg) translate(-40px,-40px); opacity:0; }
    30%{ transform:scale(1.35) rotate(10deg) translate(0,0); opacity:1; }
    75%{ transform:scale(1.1) rotate(0deg); opacity:1; }
    100%{ transform:scale(0.9) rotate(0deg); opacity:0; }
  }

  .controls{ display:flex; gap:12px; margin-top:18px; flex-wrap:wrap; justify-content:center; }
  .controls-row5{
    flex-wrap:nowrap; gap:6px; width:100%; max-width:440px;
  }
  .controls-row5 button{
    flex:1 1 0; min-width:0;
    padding:8px 6px; font-size:11.5px;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  button{
    position:relative; overflow:hidden;
    font-family:'Fredoka','Nunito',sans-serif; font-weight:700; font-size:14px;
    border:2.5px solid #a12864; border-radius:999px;
    padding:12px 22px; cursor:pointer; color:white;
    text-shadow:0 1px 2px rgba(0,0,0,0.25);
    background:linear-gradient(160deg, color-mix(in srgb, var(--accent) 55%, white), var(--accent));
    box-shadow:
      0 4px 0 #a12864,
      0 8px 16px rgba(255,95,162,0.35);
    transition:transform .12s cubic-bezier(.34,1.56,.64,1), box-shadow .12s ease;
  }
  button::before{
    content:''; position:absolute; top:10%; left:14%; width:45%; height:32%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.8), transparent 70%);
    border-radius:50%; pointer-events:none;
  }
  button:hover{
    transform:translateY(-2px);
    box-shadow:0 6px 0 #a12864, 0 10px 20px rgba(255,95,162,0.42);
  }
  button:active{
    transform:translateY(3px) scale(0.98);
    box-shadow:0 1px 0 #a12864, 0 2px 6px rgba(255,95,162,0.3);
  }
  button.secondary{
    background:linear-gradient(160deg, color-mix(in srgb, var(--accent-2) 55%, white), var(--accent-2));
    color:#fff; border:2.5px solid color-mix(in srgb, var(--accent-2) 65%, black);
    box-shadow:
      0 4px 0 color-mix(in srgb, var(--accent-2) 65%, black),
      0 7px 12px rgba(90,50,140,0.3);
  }
  button.secondary:hover{
    box-shadow:0 6px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 10px 16px rgba(90,50,140,0.34);
  }
  button.secondary:active{
    box-shadow:0 1px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 2px 4px rgba(90,50,140,0.24);
  }

  .overlay{
    position:fixed; inset:0; background:rgba(60,30,70,0.45); backdrop-filter:blur(3px);
    display:none; align-items:center; justify-content:center; z-index:10; padding:20px;
  }
  .overlay.show{ display:flex; }
  .modal{
    background:linear-gradient(160deg, var(--panel), var(--tile-bg));
    border:1px solid var(--panel-border); border-radius:24px;
    padding:26px; text-align:center; max-width:320px; box-shadow:var(--shadow); backdrop-filter:blur(12px);
    max-height:80vh; overflow-y:auto;
    animation:dropIn .3s cubic-bezier(.34,1.2,.64,1);
  }
  .modal h2{ font-family:'Fredoka',sans-serif; margin:0 0 8px; color:var(--accent); font-weight:600; }
  .modal p{ color:var(--text-soft); font-size:14px; margin:4px 0 18px; line-height:1.5; }


  .bonus-bar{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }
  .bonus-btn{
    position:relative; width:52px; height:52px; border-radius:18px;
    background:linear-gradient(160deg, color-mix(in srgb, var(--accent-2) 55%, white), var(--accent-2));
    border:2.5px solid color-mix(in srgb, var(--accent-2) 65%, black);
    display:flex; align-items:center; justify-content:center; font-size:22px;
    cursor:pointer;
    box-shadow:
      0 4px 0 color-mix(in srgb, var(--accent-2) 65%, black),
      0 7px 12px rgba(90,50,140,0.3);
    transition:transform .12s cubic-bezier(.34,1.56,.64,1), box-shadow .12s ease, opacity .16s ease;
  }
  .bonus-btn::before{
    content:''; position:absolute; top:8%; left:14%; width:45%; height:30%;
    background:radial-gradient(ellipse, rgba(255,255,255,0.8), transparent 70%);
    border-radius:50%; pointer-events:none;
  }
  .bonus-btn:hover{ transform:translateY(-2px); box-shadow:0 6px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 10px 14px rgba(90,50,140,0.34); }
  .bonus-btn:active{
    transform:translateY(3px);
    box-shadow:0 1px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 2px 4px rgba(90,50,140,0.24);
  }
  .bonus-btn.disabled{ opacity:0.4; cursor:not-allowed; filter:grayscale(0.4); }
  .bonus-btn.disabled:hover{ transform:none; box-shadow:0 4px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 7px 12px rgba(90,50,140,0.3); }
  .bonus-btn.armed{
    box-shadow:0 0 0 3px #fff, 0 0 0 6px var(--accent), 0 4px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 7px 12px rgba(90,50,140,0.3);
    transform:translateY(-2px);
  }
  .bonus-btn .badge-count{
    position:absolute; bottom:-5px; right:-5px; background:linear-gradient(135deg,var(--accent),var(--accent-2));
    color:#fff; font-size:10px; font-weight:800; border-radius:999px; padding:2px 6px;
    box-shadow:0 2px 0 rgba(120,20,80,0.35), 0 3px 5px rgba(0,0,0,0.2);
    font-family:'Fredoka',sans-serif;
  }

  .armed-banner{
    display:none; align-items:center; gap:10px; margin:10px 0 4px;
    background:var(--panel); border:1px solid var(--panel-border); border-radius:999px;
    padding:8px 8px 8px 16px; box-shadow:var(--shadow-soft); font-size:13px; font-weight:700;
    backdrop-filter:blur(8px);
  }
  .armed-banner.show{ display:flex; }
  button.tiny{ padding:6px 14px; font-size:12px; box-shadow:none; border-width:1.5px; }

  .modal-stars{ display:flex; justify-content:center; gap:6px; margin:6px 0 10px; font-size:28px; }

  .share-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0 18px; }
  .share-opt{
    display:flex; flex-direction:column; align-items:center; gap:4px;
    background:var(--tile-bg); color:var(--text); border:1px solid var(--panel-border);
    border-radius:14px; padding:12px 8px; font-size:12px; font-weight:700;
    box-shadow:var(--shadow-soft);
    text-decoration:none; cursor:pointer;
  }
  .share-opt span{ font-size:22px; }
  .share-opt:hover{ transform:translateY(-2px); }
  .modal-stars .star{ filter:grayscale(1) opacity(0.35); }
  .modal-stars .star.earned{ filter:none; animation:starPop .4s cubic-bezier(.34,1.56,.64,1) backwards; }
  .modal-stars .star.earned:nth-child(1){ animation-delay:.05s; }
  .modal-stars .star.earned:nth-child(2){ animation-delay:.18s; }
  .modal-stars .star.earned:nth-child(3){ animation-delay:.31s; }
  @keyframes starPop{ 0%{ transform:scale(0) rotate(-30deg); opacity:0; } 70%{ transform:scale(1.25) rotate(8deg); } 100%{ transform:scale(1) rotate(0); opacity:1; } }

  #screenMap{ width:100%; max-width:900px; }
  #screenGame{ width:100%; max-width:460px; display:flex; flex-direction:column; align-items:center; }
  .game-sidebar{ display:contents; }
  #screenGame .hud{ order:1; }
  #screenGame .bonus-lives-row{ order:2; }
  #screenGame .progress-wrap{ order:3; }
  #screenGame .board-wrap{ order:4; }
  #screenGame .armed-banner{ order:5; }
  #screenGame .controls{ order:6; }
  #screenGame .hint{ order:7; }

  /* Landscape phones: put the board and controls side-by-side instead of one long
     vertical stack, and size the board by available HEIGHT instead of width. */
  
  .game-topbar{ display:flex; align-items:center; gap:10px; margin-bottom:14px; width:100%; }
  .game-topbar .subtitle{ margin:0; text-align:left; flex:1; font-size:12.5px; }

  .stage-block{ position:relative; width:calc(100% + 28px); margin-left:-14px; aspect-ratio:1/1; overflow:hidden; box-shadow:var(--shadow); margin-bottom:18px; background:#e9e3f0; }
  @media (min-width:520px){
    .stage-block{ width:100%; margin-left:0; border-radius:26px; }
  }
  .stage-block > img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; }
  .stage-node-layer{ position:absolute; inset:0; }
  .img-node{
    position:absolute; width:12.5%; aspect-ratio:1/1; transform:translate(-50%,-50%);
    border-radius:50%; cursor:pointer; z-index:1;
    display:flex; align-items:center; justify-content:center;
    transition:transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .15s ease;
  }
  .img-node:hover{ transform:translate(-50%,-50%) scale(1.08); }
  .img-node:active{ transform:translate(-50%,-50%) scale(0.92); }
  .img-node.locked{
    background:rgba(25,15,35,0.62); backdrop-filter:blur(1px);
    box-shadow:inset 0 0 0 2px rgba(255,255,255,0.35);
    cursor:not-allowed;
  }
  .img-node.locked:hover{ transform:translate(-50%,-50%); }
  .img-node.locked .node-lock{ font-size:19px; filter:drop-shadow(0 1px 1px rgba(0,0,0,0.4)); }
  .img-node.current{ box-shadow:0 0 0 3px #fff, 0 0 0 6px var(--accent); animation:nodeGlow 1.6s ease-in-out infinite; }
  @keyframes nodeGlow{ 0%,100%{ filter:brightness(1); } 50%{ filter:brightness(1.15); } }
  .img-node .node-stars-float{
    position:absolute; top:100%; left:50%; transform:translateX(-50%); margin-top:3px;
    font-size:17px; white-space:nowrap; letter-spacing:1px; line-height:1;
    filter:drop-shadow(0 1px 2px rgba(0,0,0,0.6));
    pointer-events:none; z-index:0;
  }
  .img-node .node-stars-float .star{ opacity:0.4; filter:grayscale(1); }
  .img-node .node-stars-float .star.earned{ opacity:1; filter:none; }

  .hint{ margin-top:12px; font-size:12.5px; color:var(--text-soft); text-align:center; max-width:360px; line-height:1.6; }

  #combo-toast{
    position:fixed; top:16px; left:50%; transform:translateX(-50%) translateY(-24px) scale(0.9);
    background:linear-gradient(135deg,var(--accent),var(--accent-2)); color:#fff; font-weight:700;
    font-family:'Fredoka',sans-serif;
    font-size:14px; padding:9px 20px; border-radius:999px; opacity:0;
    box-shadow:0 8px 20px rgba(255,95,162,0.4);
    transition:opacity .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
    pointer-events:none; z-index:20;
    text-align:center; max-width:80vw;
  }
  #combo-toast.show{ opacity:1; transform:translateX(-50%) translateY(0) scale(1); }
/* Social + CS icons (map / landing screen only) */
.social-bar{
  position:fixed; right:12px; bottom:12px; z-index:50;
  display:flex; gap:8px; padding:6px 8px; border-radius:999px;
  background:rgba(255,255,255,.85); box-shadow:0 3px 12px rgba(0,0,0,.25);
}
.social-ico{
  width:30px; height:30px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  border:2px solid #fff; box-shadow:0 2px 4px rgba(0,0,0,.3);
}
.social-ico svg{ width:17px; height:17px; display:block; }
.social-ico:active{ transform:translateY(1px); }

/* Fit-to-screen fixes */
.board-wrap{ max-width:100%; overflow:visible; }

/* Phones (portrait): small controls, BIG board */
@media (max-width:600px){
  body{ padding:6px 6px 14px; }
  h1{ font-size:20px; margin:0 0 4px; }
  #screenGame{ max-width:100%; }
  #board{ --cell: clamp(30px, calc((100vw - 46px) / 8), 64px); gap:3px; padding:6px; border-radius:18px; }
  .cell{ border-radius:12px; }
  .hud{ gap:8px; margin-bottom:6px; }
  .hud-card{ width:52px; height:32px; }
  .hud-label{ font-size:6px; }
  .hud-value{ font-size:11px; }
  .bonus-lives-row{ gap:6px; margin-bottom:6px; flex-wrap:nowrap; }
  .bonus-bar{ gap:5px; flex-wrap:nowrap; }
  .bonus-btn{ width:34px; height:34px; border-radius:12px; font-size:16px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 4px 8px rgba(90,50,140,.25); }
  .bonus-btn .badge-count{ font-size:8px; padding:1px 4px; bottom:-4px; right:-4px; }
  .lives-bar{ padding:4px 9px; font-size:11px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 45%, #8a7a98); }
  #livesHearts{ font-size:11px; }
  .lives-timer{ font-size:9px; }
  .progress-wrap{ height:8px; margin-bottom:8px; }
  .controls{ margin-top:10px; }
  .controls-row5{ gap:4px; }
  .controls-row5 button{ padding:5px 4px; font-size:10px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
  .hint{ display:none; }
}

/* Landscape phones: everything must fit in one screen height */


/* Phone portrait: use the full screen height (spread content, no empty gap at the bottom) */
@media (max-width:600px) and (orientation:portrait){
  html,body{ min-height:100vh; min-height:100dvh; }
  body{ justify-content:flex-start; }
  #screenGame{ min-height:calc(100vh - 62px); min-height:calc(100dvh - 62px); justify-content:space-evenly; }
  #screenGame .hud, #screenGame .bonus-lives-row, #screenGame .progress-wrap, #screenGame .controls{ margin-top:0; margin-bottom:0; }
  .hud-card{ width:58px; height:36px; }
  .bonus-btn{ width:38px; height:38px; }
}

/* Landscape phones: keep the SAME stacked layout as portrait (top: info/bonus, middle: board, bottom: buttons) */


/* Phone portrait: even smaller info/bonus icons */
@media (max-width:600px) and (orientation:portrait){
  h1{ font-size:17px; }
  .hud{ gap:6px; }
  .hud-card{ width:46px; height:27px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
  .hud-label{ font-size:5px; }
  .hud-value{ font-size:9.5px; }
  .bonus-lives-row{ gap:5px; }
  .bonus-bar{ gap:4px; }
  .bonus-btn{ width:28px; height:28px; border-radius:10px; font-size:13px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
  .bonus-btn .badge-count{ font-size:7px; padding:0 3px; bottom:-3px; right:-3px; }
  .lives-bar{ padding:3px 7px; font-size:9.5px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 45%, #8a7a98); }
  #livesHearts{ font-size:9.5px; }
  .lives-timer{ font-size:8px; }
  .controls-row5 button{ padding:4px 3px; font-size:9px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
}

/* ===== Portrait-only: on touch phones held sideways the game stays a centered portrait-shaped screen ===== */
html.fp{ overflow:hidden; height:100%; }
html.fp body{ position:fixed; top:0; width:var(--pw); height:var(--ph); min-height:0; overflow-y:auto; overflow-x:hidden; left:50%; transform:translateX(-50%); box-shadow:0 0 0 1px rgba(0,0,0,.08), 0 0 40px rgba(60,30,90,.25); }
html.fp body{ padding:6px 6px 14px; }
html.fp h1{ font-size:20px; margin:0 0 4px; }
html.fp #screenGame{ max-width:100%; }
html.fp #board{ --cell: clamp(30px, calc((var(--pw) - 38px) / 8), 64px); gap:3px; padding:6px; border-radius:18px; }
html.fp .cell{ border-radius:12px; }
html.fp .hud{ gap:8px; margin-bottom:6px; }
html.fp .hud-card{ width:52px; height:32px; }
html.fp .hud-label{ font-size:6px; }
html.fp .hud-value{ font-size:11px; }
html.fp .bonus-lives-row{ gap:6px; margin-bottom:6px; flex-wrap:nowrap; }
html.fp .bonus-bar{ gap:5px; flex-wrap:nowrap; }
html.fp .bonus-btn{ width:34px; height:34px; border-radius:12px; font-size:16px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 65%, black), 0 4px 8px rgba(90,50,140,.25); }
html.fp .bonus-btn .badge-count{ font-size:8px; padding:1px 4px; bottom:-4px; right:-4px; }
html.fp .lives-bar{ padding:4px 9px; font-size:11px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 45%, #8a7a98); }
html.fp #livesHearts{ font-size:11px; }
html.fp .lives-timer{ font-size:9px; }
html.fp .progress-wrap{ height:8px; margin-bottom:8px; }
html.fp .controls{ margin-top:10px; }
html.fp .controls-row5{ gap:4px; }
html.fp .controls-row5 button{ padding:5px 4px; font-size:10px; border-width:2px; box-shadow:0 3px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
html.fp .hint{ display:none; }
html.fp body{ justify-content:flex-start; }
html.fp #screenGame{ min-height:calc(var(--ph) - 62px); min-height:calc(var(--ph) - 62px); justify-content:space-evenly; }
html.fp #screenGame .hud, html.fp #screenGame .bonus-lives-row, html.fp #screenGame .progress-wrap, html.fp #screenGame .controls{ margin-top:0; margin-bottom:0; }
html.fp .hud-card{ width:58px; height:36px; }
html.fp .bonus-btn{ width:38px; height:38px; }
html.fp h1{ font-size:17px; }
html.fp .hud{ gap:6px; }
html.fp .hud-card{ width:46px; height:27px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
html.fp .hud-label{ font-size:5px; }
html.fp .hud-value{ font-size:9.5px; }
html.fp .bonus-lives-row{ gap:5px; }
html.fp .bonus-bar{ gap:4px; }
html.fp .bonus-btn{ width:28px; height:28px; border-radius:10px; font-size:13px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
html.fp .bonus-btn .badge-count{ font-size:7px; padding:0 3px; bottom:-3px; right:-3px; }
html.fp .lives-bar{ padding:3px 7px; font-size:9.5px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 45%, #8a7a98); }
html.fp #livesHearts{ font-size:9.5px; }
html.fp .lives-timer{ font-size:8px; }
html.fp .controls-row5 button{ padding:4px 3px; font-size:9px; border-width:1.5px; box-shadow:0 2px 0 color-mix(in srgb, var(--accent-2) 65%, black); }
html.fp #board{ --cell: clamp(14px, calc((var(--pw) - 52px) / 8), 64px); }
html.fp{ background:#2b1d3a; }
html.fp .bonus-lives-row{ flex-wrap:wrap; justify-content:center; }

/* Install (PWA) button */
button.social-ico{ padding:0; margin:0; cursor:pointer; background:linear-gradient(160deg,#4cd98a,#16a35a); border:2px solid #fff; }
button.social-ico::before{ display:none; }
button.social-ico:hover{ transform:none; }
.install-ico{ animation:instPulse 2.2s ease-in-out infinite; }
@keyframes instPulse{ 0%,100%{ box-shadow:0 2px 4px rgba(0,0,0,.3); } 50%{ box-shadow:0 0 0 4px rgba(76,217,138,.45), 0 2px 4px rgba(0,0,0,.3); } }
.install-ico[hidden]{ display:none; }

/* ===== Image-based icons ===== */
.ico{ width:1.35em; height:1.35em; vertical-align:-0.3em; object-fit:contain; pointer-events:none; }
#livesHearts .ico{ width:1.5em; height:1.5em; vertical-align:-0.38em; }
.ico-star{ width:1.1em; height:1.1em; display:block; object-fit:contain; pointer-events:none; }
.star{ display:inline-flex; align-items:center; justify-content:center; }
.img-node .node-stars-float .star{ width:17px; height:17px; }
.modal-stars .star{ width:34px; height:34px; }
.ico-lock{ width:24px; height:24px; display:block; object-fit:contain; filter:drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.img-node.locked .node-lock{ display:flex; align-items:center; justify-content:center; }
.bonus-img{ width:78%; height:78%; object-fit:contain; position:relative; z-index:1; pointer-events:none; filter:drop-shadow(0 1px 2px rgba(60,20,90,.35)); }
.bonus-btn.disabled .bonus-img{ filter:grayscale(.6) opacity(.7); }

/* ===== Image-based buttons (9-slice) ===== */
button#preLevelStartBtn, button#modalBtn, button#reviveWatchBtn, button.secondary, button.icon-btn{
  background:none !important; box-shadow:none !important; border-radius:0 !important;
  border-style:solid !important; border-color:transparent !important;
  border-width:14px 15px 15px 15px !important;
  border-image:url(images/ui/ui-violet.png) 50 55 55 55 fill / 14px 15px 15px 15px stretch !important;
  padding:0 8px !important; line-height:1.15; overflow:visible;
  filter:drop-shadow(0 3px 3px rgba(80,30,110,.28));
}
button#preLevelStartBtn, button#modalBtn, button#reviveWatchBtn{
  border-image-source:url(images/ui/ui-pink.png) !important;
}
button.tiny, .controls-row5 button.icon-btn{
  border-width:9px 10px 10px 10px !important;
  border-image-width:9px 10px 10px 10px !important;
}
button#preLevelStartBtn::before, button#modalBtn::before, button#reviveWatchBtn::before, button.secondary::before, button.icon-btn::before{ display:none; }
button#preLevelStartBtn:hover, button#modalBtn:hover, button.secondary:hover, button.icon-btn:hover{ transform:translateY(-1px); }
button#preLevelStartBtn:active, button#modalBtn:active, button#reviveWatchBtn:active, button.secondary:active, button.icon-btn:active{ transform:translateY(2px); filter:drop-shadow(0 1px 1px rgba(80,30,110,.3)); }

/* ===== Icon-only controls (no button chrome) ===== */
.controls-row5{ justify-content:center; gap:22px; }
.controls-row5 button.icon-btn{ background:none !important; border:0 !important; border-image:none !important; box-shadow:none !important; padding:2px !important; min-width:0; width:auto; height:auto; filter:drop-shadow(0 3px 3px rgba(80,30,110,.35)); }
.controls-row5 button.icon-btn .ico{ width:44px; height:44px; display:block; }
.controls-row5 button.icon-btn .ico-emoji{ font-size:36px; line-height:44px; display:block; width:44px; text-align:center; }
.controls-row5 button.icon-btn:active{ transform:scale(.9); }
.bonus-btn{ background:none !important; border:0 !important; box-shadow:none !important; overflow:visible; }
.bonus-btn::before{ display:none !important; }
.bonus-btn .bonus-img{ width:100%; height:100%; filter:drop-shadow(0 3px 3px rgba(80,30,110,.4)); }
.bonus-btn.armed{ animation:none; filter:drop-shadow(0 0 6px #ffd54a) drop-shadow(0 0 10px #ff8ad8); transform:scale(1.12); }
.bonus-btn .badge-count{ background:#ff4f9a; color:#fff; border:1.5px solid #fff; border-radius:999px; }
.bonus-btn.disabled .bonus-img{ filter:grayscale(.8) opacity(.55); }
@media (max-width:600px){ .controls-row5 button.icon-btn .ico{ width:38px; height:38px; } .controls-row5 button.icon-btn .ico-emoji{ font-size:30px; line-height:38px; width:38px; } }
html.fp .controls-row5 button.icon-btn .ico{ width:38px; height:38px; }

/* settings gear */
#screenGame{ position:relative; }
.gear-btn{ position:absolute; top:2px; right:6px; z-index:5; background:none; border:0; font-size:26px; line-height:1; padding:4px; cursor:pointer; filter:drop-shadow(0 2px 2px rgba(80,30,110,.35)); }
.gear-btn:active{ transform:scale(.9); }
#settingsOverlay .controls-row5{ margin:14px 0 18px; }
button.gear-btn{ background:none !important; border:0 !important; border-image:none !important; box-shadow:none !important; width:auto !important; min-width:0 !important; height:auto !important; border-radius:0 !important; }
button.gear-btn::before{ display:none !important; }

/* score bar with stars */
.progress-wrap, html.fp .progress-wrap{ position:relative; width:100% !important; max-width:420px; height:auto !important; overflow:visible !important; background:none !important; border:0 !important; box-shadow:none !important; padding:22px 12px 0; margin:0 0 8px !important; box-sizing:border-box; }
.score-track{ position:relative; height:22px; border-radius:999px; background:var(--tile-bg,#fff); border:1.5px solid var(--panel-border,#e5d9f5); overflow:hidden; box-shadow:inset 0 2px 4px rgba(0,0,0,.08); }
.score-track .progress-bar{ position:absolute; left:0; top:0; height:100%; }
.score-text{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-family:'Fredoka',sans-serif; font-weight:700; font-size:13px; color:#4b2a7a; text-shadow:0 1px 0 rgba(255,255,255,.9),0 0 3px rgba(255,255,255,.8); letter-spacing:.3px; }
.score-stars{ position:absolute; left:12px; right:12px; top:0; height:22px; }
.score-stars .sm{ position:absolute; top:0; transform:translateX(-50%); width:22px; height:22px; transition:transform .3s; }
.score-stars .sm img{ width:100%; height:100%; object-fit:contain; display:block; opacity:.8; }
.score-stars .sm.on{ transform:translateX(-50%) scale(1.25); }
.score-stars .sm.on img{ opacity:1; filter:drop-shadow(0 0 4px #ffd54a); }

/* stars inside bar */
.progress-wrap, html.fp .progress-wrap{ padding:0 8px !important; }
.score-track{ height:28px; overflow:hidden; }
.score-text{ justify-content:flex-start; padding-left:12px; z-index:2; }
.score-stars{ position:absolute; inset:0; left:0; right:0; top:0; height:100%; z-index:1; }
.score-stars .sm{ top:50%; margin-top:-12px; width:24px; height:24px; transform:translateX(-50%); }
.score-stars .sm img{ opacity:.55; filter:grayscale(.35) saturate(.9) drop-shadow(0 1px 1px rgba(90,40,120,.35)); }
.score-stars .sm.on{ transform:translateX(-50%) scale(1.2); }
.score-stars .sm.on img{ opacity:1; filter:drop-shadow(0 0 4px #ffd54a); }
.bonus-btn .bonus-img[src*="hammer"]{ width:100%; height:100%; }

/* plain HUD (no card) */
.hud-card, html.fp .hud-card{ width:auto !important; height:auto !important; min-width:64px; background:none !important; border:0 !important; border-image:none !important; box-shadow:none !important; filter:none !important; padding:0 6px !important; display:flex; flex-direction:column; align-items:center; gap:0; }
.hud-card::before{ display:none !important; }
.hud-label, html.fp .hud-label{ font-size:11px !important; font-weight:700; letter-spacing:.5px; color:#8a5cff !important; text-shadow:none !important; text-transform:uppercase; }
.hud-ico{ font-size:13px; margin-right:3px; }
.hud-value, html.fp .hud-value{ font-family:'Fredoka',sans-serif; font-size:26px !important; font-weight:700; line-height:1.05; color:#e0287f !important; text-shadow:0 2px 0 #fff, 0 0 6px rgba(255,255,255,.8) !important; }
.hud{ gap:34px !important; }
/* bigger touch-friendly sizes for phones */
@media (max-width:600px){
  html .bonus-btn{ width:48px !important; height:48px !important; font-size:30px !important; }
  html .bonus-btn .badge-count{ font-size:11px !important; padding:1px 6px !important; bottom:-6px !important; right:-6px !important; }
  html .bonus-bar{ gap:12px !important; }
  html .bonus-lives-row{ gap:14px !important; margin-bottom:10px !important; }
  html .lives-bar{ transform:scale(1.1); transform-origin:center; }
  html .score-track{ height:34px; }
  html .score-text{ font-size:16px; }
  html .score-stars .sm{ width:28px; height:28px; margin-top:-14px; }
  html .hud-value{ font-size:32px !important; }
  html .hud-label{ font-size:12px !important; }
  html .gear-btn{ font-size:32px; }
}
html.fp .bonus-btn{ width:48px !important; height:48px !important; font-size:30px !important; }
html.fp .score-track{ height:34px; } html.fp .score-text{ font-size:16px; }
html.fp .score-stars .sm{ width:28px; height:28px; margin-top:-14px; }
html.fp .hud-value{ font-size:32px !important; }

/* ===== Universal fit: everything scales with --u (set by JS from screen size) ===== */
html.fit body #screenGame{ width:100% !important; max-width:none !important; min-height:calc(100dvh - 110px) !important; justify-content:space-evenly !important; }
html.fit body h1{ font-size:calc(var(--u)*24px) !important; margin:0 !important; }
html.fit body #board{ --cell:calc(var(--u)*44px) !important; gap:calc(var(--u)*3px) !important; padding:calc(var(--u)*7px) !important; border-radius:calc(var(--u)*20px) !important; grid-template-columns:repeat(8,var(--cell)) !important; }
html.fit body .cell{ border-radius:calc(var(--u)*12px) !important; }
html.fit body .hud{ gap:calc(var(--u)*40px) !important; margin:0 !important; }
html.fit body .hud-label{ font-size:calc(var(--u)*12px) !important; }
html.fit body .hud-ico{ font-size:calc(var(--u)*14px) !important; }
html.fit body .hud-value{ font-size:calc(var(--u)*32px) !important; }
html.fit body .bonus-lives-row{ gap:calc(var(--u)*12px) !important; margin:0 !important; flex-wrap:nowrap !important; justify-content:center !important; }
html.fit body .bonus-bar{ gap:calc(var(--u)*12px) !important; flex-wrap:nowrap !important; }
html.fit body .bonus-btn{ width:calc(var(--u)*46px) !important; height:calc(var(--u)*46px) !important; font-size:calc(var(--u)*28px) !important; }
html.fit body .bonus-btn .badge-count{ font-size:calc(var(--u)*11px) !important; padding:0 calc(var(--u)*6px) !important; bottom:calc(var(--u)*-6px) !important; right:calc(var(--u)*-6px) !important; }
html.fit body .lives-bar{ transform:none !important; padding:calc(var(--u)*5px) calc(var(--u)*10px) !important; font-size:calc(var(--u)*14px) !important; }
html.fit body .lives-timer{ font-size:calc(var(--u)*11px) !important; }
html.fit body .progress-wrap{ width:calc(var(--u)*370px) !important; max-width:100% !important; padding:0 !important; margin:0 !important; }
html.fit body .score-track{ height:calc(var(--u)*34px) !important; }
html.fit body .score-text{ font-size:calc(var(--u)*16px) !important; padding-left:calc(var(--u)*12px) !important; }
html.fit body .score-stars .sm{ width:calc(var(--u)*28px) !important; height:calc(var(--u)*28px) !important; margin-top:calc(var(--u)*-14px) !important; }
html.fit body .gear-btn{ font-size:calc(var(--u)*30px) !important; top:calc(var(--u)*4px) !important; right:calc(var(--u)*10px) !important; }
/* tidy top area: Level/Moves, hearts row, bonus row spread evenly */
html.fit body .bonus-lives-row{ flex-direction:column !important; align-items:center !important; width:100% !important; gap:calc(var(--u)*14px) !important; }
html.fit body .lives-bar{ order:-1; }
html.fit body .bonus-bar{ width:calc(var(--u)*370px) !important; max-width:100% !important; justify-content:space-between !important; }
html.fit body .hud{ width:calc(var(--u)*370px) !important; max-width:100% !important; justify-content:space-around !important; gap:0 !important; }
html.fit body{ padding-top:10px !important; padding-bottom:6px !important; }
html.fit body #screenGame{ min-height:calc(100dvh - 62px) !important; }

/* compact top: [Level] [hearts] [Moves] / bonus row */
html.fit body .hud{ width:calc(var(--u)*380px) !important; max-width:100% !important; justify-content:space-between !important; align-items:center !important; gap:calc(var(--u)*6px) !important; }
html.fit body .hud .lives-bar{ order:0 !important; margin:0 !important; }
html.fit body .hud-card{ min-width:calc(var(--u)*70px) !important; }
html.fit body .bonus-lives-row{ gap:0 !important; }
html.fit body .bonus-bar{ width:calc(var(--u)*370px) !important; justify-content:space-around !important; }
html.fit body .lives-timer{ display:none !important; }
html.fit body #screenGame{ gap:0 !important; }
html.fit body .gear-btn{ top:calc(var(--u)*-36px) !important; right:calc(var(--u)*6px) !important; font-size:calc(var(--u)*26px) !important; }
html.fit body #screenGame{ min-height:0 !important; justify-content:flex-start !important; gap:calc(var(--u)*12px) !important; padding-top:calc(var(--u)*6px); }
html.fit body .bonus-btn{ margin-bottom:calc(var(--u)*6px); }
/* bonus icons live at the bottom, under the board */
#screenGame .bonus-lives-row{ order:6 !important; }
#screenGame .controls{ order:7; }
html.fit body .score-stars .sm{ width:calc(var(--u)*18px) !important; height:calc(var(--u)*18px) !important; margin-top:calc(var(--u)*-9px) !important; }
html.fit body .score-stars .sm.on{ transform:translateX(-50%) scale(1.15); }
html.fit body .score-track{ height:calc(var(--u)*28px) !important; }
html.fit body .score-text{ font-size:calc(var(--u)*14px) !important; }
html.fit body .bonus-lives-row{ margin-top:calc(var(--u)*6px) !important; }
/* bonus icons: smaller, inside one shared pill */
html.fit body .bonus-bar{ width:calc(var(--u)*330px) !important; max-width:100% !important; justify-content:space-around !important; align-items:center !important; padding:calc(var(--u)*8px) calc(var(--u)*10px) calc(var(--u)*12px) !important; background:linear-gradient(180deg,rgba(255,255,255,.85),rgba(245,235,255,.8)) !important; border:calc(var(--u)*2px) solid #fff !important; border-radius:calc(var(--u)*22px) !important; box-shadow:0 calc(var(--u)*3px) 0 #d9c6f5, 0 calc(var(--u)*6px) calc(var(--u)*12px) rgba(120,60,170,.18) !important; gap:0 !important; }
html.fit body .bonus-btn{ width:calc(var(--u)*34px) !important; height:calc(var(--u)*34px) !important; font-size:calc(var(--u)*22px) !important; margin-bottom:0 !important; }
html.fit body .bonus-btn .badge-count{ font-size:calc(var(--u)*9px) !important; padding:0 calc(var(--u)*5px) !important; bottom:calc(var(--u)*-8px) !important; right:calc(var(--u)*-5px) !important; }
html.fit body .bonus-bar{ background:linear-gradient(180deg,#a77bff 0%,#7a45e6 100%) !important; border:calc(var(--u)*3px) solid #fff !important; box-shadow:0 calc(var(--u)*4px) 0 #5a2ab8, 0 calc(var(--u)*8px) calc(var(--u)*14px) rgba(90,40,170,.35) !important; }
html.fit body .bonus-btn .bonus-img{ filter:drop-shadow(0 2px 2px rgba(40,10,90,.45)) !important; }
html.fit body .bonus-btn.disabled, html.fit body .bonus-btn:disabled{ opacity:.8 !important; }
html.fit body .bonus-btn.disabled .bonus-img{ filter:grayscale(.5) opacity(.7) !important; }
html.fit body .bonus-bar{ background:linear-gradient(180deg,#fff3d9 0%,#ffd08e 100%) !important; border:calc(var(--u)*3px) solid #fff !important; box-shadow:0 calc(var(--u)*4px) 0 #e0a257, 0 calc(var(--u)*8px) calc(var(--u)*14px) rgba(200,120,40,.30) !important; }
html.fit body .bonus-btn .bonus-img{ filter:drop-shadow(0 2px 2px rgba(120,60,10,.35)) !important; }
.stage-block > img{ aspect-ratio:1/1; height:auto; }

/* bonus tray from image (9-slice) */
html.fit body .bonus-bar{ background:none !important; box-shadow:none !important; border-style:solid !important; border-width:calc(var(--u)*17px) !important; border-image:url(images/ui/tray.png) 74 fill / calc(var(--u)*17px) stretch !important; border-radius:0 !important; padding:0 calc(var(--u)*6px) !important; width:calc(var(--u)*350px) !important; min-height:calc(var(--u)*42px) !important; box-sizing:border-box; }
html.fit body .bonus-btn{ width:calc(var(--u)*40px) !important; height:calc(var(--u)*40px) !important; margin:calc(var(--u)*-6px) 0 !important; }
html.fit body .bonus-btn .bonus-img{ filter:drop-shadow(0 2px 2px rgba(120,60,10,.35)) !important; }
html.fit body .bonus-btn{ width:calc(var(--u)*30px) !important; height:calc(var(--u)*30px) !important; margin:calc(var(--u)*-4px) 0 !important; }
html.fit body .bonus-btn .badge-count{ font-size:calc(var(--u)*8px) !important; padding:0 calc(var(--u)*4px) !important; bottom:calc(var(--u)*-6px) !important; right:calc(var(--u)*-4px) !important; }
html.fit body .bonus-bar{ min-height:calc(var(--u)*34px) !important; width:calc(var(--u)*320px) !important; }
/* smaller bonus icons (game + desktop) */
html.fit body .bonus-btn{ width:calc(var(--u)*24px) !important; height:calc(var(--u)*24px) !important; margin:calc(var(--u)*-3px) 0 !important; }
html.fit body .bonus-btn .badge-count{ font-size:calc(var(--u)*7px) !important; padding:0 calc(var(--u)*3px) !important; bottom:calc(var(--u)*-5px) !important; right:calc(var(--u)*-4px) !important; }
html.fit body .bonus-bar{ min-height:calc(var(--u)*26px) !important; width:calc(var(--u)*300px) !important; border-width:calc(var(--u)*14px) !important; border-image-width:calc(var(--u)*14px) !important; }
html:not(.fit) .bonus-btn{ width:36px !important; height:36px !important; }
/* pre-level popup: compact bonus row */
html body #preLevelOverlay .bonus-btn{ width:30px !important; height:30px !important; margin:0 !important; }
html body #preLevelOverlay .bonus-btn .bonus-img{ width:100% !important; height:100% !important; }
html body #preLevelOverlay .bonus-bar{ width:auto !important; max-width:100% !important; min-height:0 !important; gap:6px; }
/* shaped boards */
.cell.hole{ visibility:hidden !important; pointer-events:none !important; box-shadow:none !important; background:none !important; }
html body #board.shaped{ background:transparent !important; border-color:transparent !important; box-shadow:none !important; backdrop-filter:none !important; }
html body #board.shaped .cell:not(.hole){ box-shadow:0 2px 6px rgba(120,70,150,.28) !important; background-color:#fff; }
/* smooth motion */
.cell{ will-change:transform; }
.cell.matched{ animation:pop .26s ease-in forwards !important; }
@keyframes pop{ 0%{transform:scale(1);opacity:1} 40%{transform:scale(1.18);opacity:1} 100%{transform:scale(0);opacity:0} }
/* reserve map height before JS renders the stage blocks (prevents layout shift) */
#worldContainer:empty{ min-height:calc(2 * (min(100vw, 900px) + 18px)); }
/* stable title height so the web-font swap does not shift the page */
h1{ line-height:1.2 !important; min-height:1.2em; }
h1{ white-space:nowrap; }
/* swipe: stop the browser from scrolling/zooming while dragging candies */
#board, #board .cell{ touch-action:none; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
/* fallback if the 9-slice button art cannot be loaded: keep the buttons coloured */
html.no-btn-img button#preLevelStartBtn, html.no-btn-img button#modalBtn, html.no-btn-img button#reviveWatchBtn{
  border-image:none !important; border:0 !important; border-radius:999px !important; padding:12px 26px !important;
  background:linear-gradient(180deg,#ff7ab8,#ff3f8e) !important; color:#fff !important; box-shadow:0 3px 0 #c42a6c !important; }
html.no-btn-img button.secondary, html.no-btn-img button.icon-btn{
  border-image:none !important; border:0 !important; border-radius:999px !important; padding:10px 22px !important;
  background:linear-gradient(180deg,#a98bff,#7a4dff) !important; color:#fff !important; box-shadow:0 3px 0 #5632b8 !important; }
/* no instruction banner under the board when a bonus is armed (tap the bonus again to cancel) */
.armed-banner, .armed-banner.show{ display:none !important; }
