:root{
  --bg:#10131a;
  --panel:#171b24;
  --panel2:#1d2230;
  --line:#2b3342;
  --text:#f5f7fb;
  --muted:#8f9aab;
  --cyan:#7ce7ff;
  --violet:#a896ff;
  --pink:#ff9dcc;
  --good:#9df0c7;
  --shadow:0 22px 70px rgba(0,0,0,.34)
}
*{box-sizing:border-box}
html,body{width:100%;overflow-x:hidden}
body{
  margin:0;min-height:100vh;color:var(--text);
  background:
    radial-gradient(800px 480px at 10% -10%,rgba(124,231,255,.08),transparent 60%),
    radial-gradient(700px 460px at 100% 15%,rgba(168,150,255,.08),transparent 60%),
    var(--bg);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif
}
a{color:inherit;text-decoration:none}
button{font:inherit}
.page-shell{width:min(1510px,100%);margin:auto;padding:12px}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:9px}
.brand{display:flex;align-items:center;gap:10px}
.mark{
  width:38px;height:38px;border-radius:12px;
  background:linear-gradient(145deg,var(--cyan),var(--violet));
  color:#11151d;display:grid;place-items:center;font-weight:950;
  box-shadow:0 8px 30px rgba(124,231,255,.13)
}
.name{font-size:17px;font-weight:900;letter-spacing:.4px}
.tagline{font-size:10px;color:var(--muted);margin-top:2px}
.top-actions{display:flex;gap:7px}
.btn{
  border:1px solid var(--line);background:var(--panel);color:var(--text);
  border-radius:9px;padding:8px 11px;font-size:11px;font-weight:750;cursor:pointer
}
.btn:hover{background:var(--panel2)}
.btn.primary{
  background:linear-gradient(135deg,var(--cyan),#b8f6ff);
  color:#10141b;border-color:transparent
}
.btn.home{background:#202635}

.ad-slot{
  position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;
  background:rgba(23,27,36,.52);border:1px solid rgba(124,231,255,.08);border-radius:10px
}
.ad-slot:not(.has-ad)::before{
  content:"ADVERTISEMENT";position:absolute;inset:0;display:grid;place-items:center;
  color:rgba(162,178,197,.35);font-size:9px;letter-spacing:1.1px;font-weight:800
}
.ad-slot.has-ad{background:transparent;border-color:transparent}
.ad-slot.has-ad::before{display:none}
.top-ad,.bottom-ad{min-height:90px}
.top-ad{margin-bottom:9px}.bottom-ad{margin-top:9px}
.side-ad{min-height:600px}

.play-layout{display:grid;grid-template-columns:170px minmax(0,1fr) 170px;gap:9px}
.game-column{min-width:0;width:100%}
.game-card{
  width:100%;background:rgba(23,27,36,.94);border:1px solid var(--line);
  border-radius:18px;overflow:hidden;box-shadow:var(--shadow)
}
.hud{
  min-height:70px;display:grid;
  grid-template-columns:1.25fr 1fr 1fr 1fr auto;
  gap:11px;align-items:center;padding:10px 13px;border-bottom:1px solid var(--line)
}
.stat small{display:block;color:var(--muted);font-size:9px;text-transform:uppercase;letter-spacing:.75px}
.stat strong{font-size:16px;font-variant-numeric:tabular-nums}
.progress{height:7px;background:#0e1117;border-radius:99px;overflow:hidden;margin-top:6px}
.progress span{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--pink),var(--cyan))}
.mode-pill{
  min-width:84px;text-align:center;border:1px solid var(--line);
  background:#11151d;border-radius:10px;padding:8px 10px
}
.mode-pill small{display:block;font-size:8px;color:var(--muted);text-transform:uppercase}
.mode-pill strong{font-size:12px}

.board-wrap{
  position:relative;width:100%;aspect-ratio:16/10;min-height:490px;
  touch-action:none;background:
    linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.018) 1px,transparent 1px),
    radial-gradient(circle at 50% 45%,#191e29,#10131a 70%);
  background-size:28px 28px,28px 28px,auto
}
canvas{width:100%;height:100%;display:block}
.overlay{
  position:absolute;inset:0;z-index:5;display:grid;place-items:center;padding:16px;
  background:rgba(11,14,20,.72);backdrop-filter:blur(7px)
}
.overlay.hidden{display:none}
.modal{
  width:min(530px,94%);background:#151a23;border:1px solid #30394a;
  border-radius:20px;padding:24px;text-align:center;box-shadow:0 30px 80px rgba(0,0,0,.45)
}
.eyebrow{color:var(--cyan);font-size:9px;letter-spacing:1.2px;text-transform:uppercase;font-weight:850}
.modal h1{font-size:30px;letter-spacing:-1px;margin:7px 0}
.modal p{margin:0;color:var(--muted);font-size:12px;line-height:1.55}
.modes{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:18px}
.mode{
  border:1px solid var(--line);background:#11151d;color:var(--text);
  border-radius:14px;padding:15px;text-align:left;cursor:pointer
}
.mode.selected{
  background:linear-gradient(145deg,rgba(124,231,255,.16),rgba(168,150,255,.14));
  border-color:#5c7185
}
.mode small{display:block;color:var(--cyan);font-size:9px;text-transform:uppercase}
.mode b{display:block;font-size:19px;margin:5px 0}
.mode span{font-size:10px;color:var(--muted)}
.modal-actions{display:flex;justify-content:center;gap:8px;flex-wrap:wrap;margin-top:17px}
.count{font-size:80px;font-weight:950;color:var(--cyan);text-shadow:0 10px 32px rgba(124,231,255,.2)}
.finish-time{font-size:49px;font-weight:950;color:var(--good);margin:5px 0 7px;font-variant-numeric:tabular-nums}
.results{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:15px}
.results div{background:#11151d;border:1px solid var(--line);border-radius:11px;padding:10px}
.results small{display:block;color:var(--muted);font-size:8px;text-transform:uppercase}
.results strong{font-size:13px}
.save-score{margin-top:14px;padding:13px;background:#111b1b;border:1px solid #264b43;border-radius:12px}
.save-score strong{display:block;font-size:13px}
.save-score span{display:block;color:#92aaa4;font-size:10px;margin:4px 0 10px}

.game-foot{
  display:flex;justify-content:space-between;gap:12px;padding:8px 12px;
  border-top:1px solid var(--line);color:var(--muted);font-size:10px
}
.below{display:grid;grid-template-columns:1.15fr .85fr;gap:9px;margin-top:9px}
.panel{
  background:rgba(23,27,36,.94);border:1px solid var(--line);border-radius:14px;
  padding:13px;box-shadow:0 8px 28px rgba(0,0,0,.12)
}
.panel-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px}
.panel h3{margin:0;font-size:13px}
.tabs{display:flex;gap:5px}
.tab{
  border:1px solid var(--line);background:#11151d;color:var(--muted);
  border-radius:8px;padding:5px 8px;font-size:9px;cursor:pointer
}
.tab.active{background:#22303b;color:var(--cyan);border-color:#3d5968}
.leader-row{
  display:grid;grid-template-columns:31px 1fr auto;gap:8px;
  padding:7px 0;border-top:1px solid #252c39;font-size:11px
}
.leader-row:first-child{border-top:0}
.leader-row span:first-child{color:var(--muted)}
.leader-row b{font-variant-numeric:tabular-nums}
.account-panel{display:flex;justify-content:space-between;align-items:center;gap:12px}
.account-panel strong{display:block;font-size:12px}
.account-panel span{display:block;color:var(--muted);font-size:10px;margin-top:3px}
.notice{margin-top:9px;padding:11px 13px;border:1px solid #2d6757;background:#10201c;border-radius:11px;color:var(--good);font-size:11px}
.notice.hidden{display:none}
.game-footer{
  margin-top:10px;padding:14px 3px 4px;display:flex;justify-content:space-between;
  gap:15px;flex-wrap:wrap;color:#7f8998;font-size:10px
}
.game-footer .links{display:flex;gap:12px;flex-wrap:wrap}

@media(max-width:1279px){
  .side-ad{display:none!important}
  .play-layout{display:block}
  .hud{grid-template-columns:1.25fr 1fr 1fr auto}
  .best-stat{display:none}
}
@media(max-width:720px){
  .page-shell{padding:8px}.tagline{display:none}.top-ad{display:none!important}
  .hud{grid-template-columns:1.25fr 1fr auto;padding:9px}
  .actions-stat,.best-stat{display:none}
  .board-wrap{aspect-ratio:9/12;min-height:540px}
  .below{grid-template-columns:1fr}
  .modes{grid-template-columns:1fr}
  .bottom-ad{min-height:50px}
}

/* === V1.1 DESKTOP WIDTH FIX === */
@media (min-width:1024px){
  .play-layout{
    display:flex !important;
    width:100% !important;
    max-width:none !important;
    gap:9px !important;
    align-items:flex-start !important;
  }

  .play-layout > .side-ad{
    display:flex !important;
    flex:0 0 170px !important;
    width:170px !important;
    min-width:170px !important;
    max-width:170px !important;
    min-height:600px !important;
  }

  .play-layout > .game-column{
    display:block !important;
    flex:1 1 auto !important;
    width:auto !important;
    min-width:0 !important;
    max-width:none !important;
  }

  .game-card,
  .board-wrap,
  .below,
  .game-footer{
    width:100% !important;
    max-width:none !important;
  }
}

@media (min-width:1024px) and (max-width:1279px){
  .play-layout > .side-ad{
    flex-basis:140px !important;
    width:140px !important;
    min-width:140px !important;
    max-width:140px !important;
  }
}

@media (max-width:1023px){
  .play-layout{
    display:block !important;
    width:100% !important;
  }

  .play-layout > .side-ad{
    display:none !important;
  }

  .play-layout > .game-column{
    width:100% !important;
    max-width:none !important;
  }
}

/* Mobile gameplay guard */
.board-wrap,
.board-wrap canvas{
  touch-action:none !important;
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
}

@media (pointer:coarse) and (max-width:1023px){
  /* Gesture-safe gutters prevent node dragging from beginning at system back edges. */
  .board-wrap{
    width:calc(100% - 48px) !important;
    margin-left:auto !important;
    margin-right:auto !important;
  }
}

@media (pointer:coarse) and (max-width:420px){
  .board-wrap{
    width:calc(100% - 40px) !important;
  }
}

/* UNTANGLE mobile viewport-fit correction */
html,body{
  overflow-x:hidden;
  overflow-y:auto;
}

.board-wrap,
.board-wrap canvas{
  touch-action:none !important;
}

.board-wrap{
  overscroll-behavior:contain;
}

@media (pointer:coarse), (max-height:900px){
  .board-wrap{
    max-height:calc(100dvh - 245px) !important;
    min-height:280px !important;
    height:calc(100dvh - 245px) !important;
  }

  .board-wrap canvas{
    max-height:100% !important;
    height:100% !important;
  }
}

@media (max-height:760px){
  .top-ad,
  .topad{
    display:none !important;
  }

  .board-wrap{
    max-height:calc(100dvh - 170px) !important;
    height:calc(100dvh - 170px) !important;
  }
}

@media (max-height:650px){
  .board-wrap{
    max-height:calc(100dvh - 145px) !important;
    height:calc(100dvh - 145px) !important;
    min-height:220px !important;
  }
}

@supports not (height:100dvh){
  @media (pointer:coarse), (max-height:900px){
    .board-wrap{
      max-height:calc(100vh - 245px) !important;
      height:calc(100vh - 245px) !important;
    }
  }
  @media (max-height:760px){
    .board-wrap{
      max-height:calc(100vh - 170px) !important;
      height:calc(100vh - 170px) !important;
    }
  }
}


/* FULL-VIEW PLAY AREA */
.stage,.game-stage,.playfield,.boardwrap{max-height:calc(100svh - 180px)!important}
@media(max-width:760px){.stage,.game-stage,.playfield,.boardwrap{max-height:calc(100svh - 165px)!important}}
