/* DIALOG V4 — standalone modal design system. No gameplay/layout changes. */
.modal{
  z-index:80;padding:clamp(14px,3vw,28px);
  background:rgba(10,4,24,.56);
  -webkit-backdrop-filter:blur(3px) saturate(.83);
  backdrop-filter:blur(3px) saturate(.83);
  animation:dialogBackdrop .24s ease-out both;
  overscroll-behavior:contain;
}
.sheet{
  position:relative;isolation:isolate;
  width:min(610px,100%);max-height:min(90dvh,850px);
  overflow-y:auto;overflow-x:hidden;
  padding:clamp(20px,3.1vw,29px);
  border:1.5px solid #e4b76c;border-radius:26px;
  background:
    radial-gradient(ellipse 100% 44% at 50% -9%,rgba(231,135,195,.25),transparent 73%),
    radial-gradient(ellipse 85% 70% at 110% 105%,rgba(103,49,136,.36),transparent 70%),
    linear-gradient(155deg,#472040 0%,#2b1438 48%,#1c102d 100%);
  box-shadow:0 0 0 5px rgba(65,28,64,.79),0 0 0 6px rgba(244,196,107,.22),
    0 24px 85px rgba(6,2,19,.72),0 0 54px rgba(243,173,89,.15),
    inset 0 1px 0 rgba(255,248,218,.3),inset 0 -5px 18px rgba(0,0,0,.26);
  animation:dialogArrival .3s cubic-bezier(.22,1.25,.38,1) both;
  scrollbar-color:#a8758e #21102e;
  scrollbar-width:thin;
}
.sheet::before{
  content:"";position:absolute;inset:0 0 auto;height:2px;
  background:linear-gradient(90deg,transparent 4%,#ffe2a2 33%,#fff8ce 50%,#ffe0a0 67%,transparent 96%);
  opacity:.85;pointer-events:none;
}
.sheet::after{
  content:"";position:absolute;inset:0 0 auto;height:70px;pointer-events:none;
  background:radial-gradient(ellipse at 50% 0,rgba(255,218,136,.14),transparent 70%);
}
.dialog-body,.dialog-chrome{position:relative;z-index:1}
.dialog-chrome{display:flex;justify-content:space-between;align-items:center;gap:10px;
  margin-bottom:15px;padding-bottom:12px;border-bottom:1px solid rgba(244,202,144,.21)}
.dialog-overline{display:inline-flex;align-items:center;gap:8px;min-width:0;
  color:#e3b983;font:800 10px/1.4 var(--fx-body);letter-spacing:.13em;text-transform:uppercase}
.dialog-overline .overline-star{font-size:16px;color:#ffe39c;line-height:1;filter:drop-shadow(0 0 6px #f6b85b)}
.dialog-badge{padding:5px 11px;border:1px solid rgba(255,220,143,.46);border-radius:99px;
  color:#ffe6af;background:rgba(234,171,96,.13);
  font:800 10px/1.2 var(--fx-body);letter-spacing:.08em;white-space:nowrap}
.dialog-seal{display:flex;align-items:center;justify-content:center;width:58px;height:58px;
  margin:0 0 12px;border-radius:19px;border:1px solid #f4c786;
  background:linear-gradient(148deg,#8a4866,#5f2a59 60%,#432243);
  box-shadow:inset 0 1px rgba(255,249,224,.24),0 6px 18px #10051f99,0 0 20px #eaa55431;
  color:#ffe5a2}
.dialog-seal svg{width:29px;height:29px;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.8;fill:none}
.sheet h3{
  margin:0 0 11px;color:#ffe9ad;font-family:var(--fx-body)!important;
  font-weight:900;font-size:clamp(24px,3.1vw,30px);line-height:1.26;
  letter-spacing:-.028em;text-transform:none;text-wrap:balance;
  text-shadow:0 2px 12px rgba(251,175,91,.14);
}
.sheet p{font-size:13.5px;line-height:1.72;color:#ead8e3;margin:0 0 13px}
.sheet p b,.sheet p strong{color:#ffe3a1}
.sheet .btns{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;
  margin-top:20px;align-items:stretch;
}
.sheet .btns:has(> :only-child){grid-template-columns:1fr}
.sheet .btns button{
  box-sizing:border-box;display:flex;align-items:center;justify-content:center;text-align:center;
  width:100%;min-width:0;min-height:53px;margin:0;padding:12px 14px;
  font-family:var(--fx-body)!important;font-size:clamp(12.5px,1.6vw,15px)!important;
  font-weight:900!important;letter-spacing:0!important;line-height:1.4;
  border-radius:14px;white-space:normal;text-wrap:balance;
  animation:none!important;transition:transform .15s,filter .15s,box-shadow .15s,border-color .15s;
}
.sheet .btns .ghost{
  color:#ffecdf;background:linear-gradient(180deg,#674069 0%,#3b234c 75%,#2e193c 100%);
  border:1.5px solid #ac7e9c;
  box-shadow:inset 0 1px 0 #edbbdf4a,0 4px 0 #1b0d28,0 10px 18px #09031b77;
  text-shadow:none;
}
.sheet .btns .cta{
  color:#3b1b2e;text-shadow:0 1px #fff5c3;
  background:linear-gradient(180deg,#fff0b3 0%,#ffd976 33%,#efaa40 72%,#d2872e 100%);
  border:1.5px solid #fff1b9;
  box-shadow:inset 0 2px 0 #fff9d1b6,0 4px 0 #8b4a1f,0 10px 21px #0e061b75;
}
.sheet .btns .solve{
  color:#123a36;text-shadow:0 1px #d5fff0;
  background:linear-gradient(180deg,#a6fff0,#43ddcb 58%,#1fa99e);
  border:1.5px solid #b8fff0;
  box-shadow:inset 0 2px 0 #efffffb5,0 4px 0 #147c75,0 10px 20px #0a061c70;
}
.sheet .btns button:hover:not(:disabled){filter:brightness(1.1);transform:translateY(-2px)}
.sheet .btns button:active:not(:disabled){transform:translateY(3px);filter:brightness(.96)}
/* Confirmations: a focused, centered presentation with a clear safe action. */
.sheet[data-dialog="home"],.sheet[data-dialog="exit"]{width:min(490px,100%)}
.sheet[data-dialog="home"] .dialog-seal,.sheet[data-dialog="exit"] .dialog-seal{
  margin:0 auto 14px;width:68px;height:68px;border-radius:22px;
}
.sheet[data-dialog="home"] .dialog-seal svg,.sheet[data-dialog="exit"] .dialog-seal svg{width:34px;height:34px}
.sheet[data-dialog="home"] h3,.sheet[data-dialog="exit"] h3{text-align:center}
.sheet[data-dialog="home"] .dialog-body>p,.sheet[data-dialog="exit"] .dialog-body>p{text-align:center;max-width:42ch;margin:0 auto 8px}
.sheet[data-dialog="exit"] .dialog-seal{color:#ffd5c9;border-color:#f3a298;background:linear-gradient(140deg,#8b3d57,#522240)}
.sheet[data-dialog="exit"] .dialog-badge{color:#ffc1bd;border-color:#de8a87;background:#a0475530}
.sheet[data-dialog="exit"] .btns .cta{
  color:#fff5f1;text-shadow:0 1px #5b132c;
  background:linear-gradient(180deg,#f47f83,#dc536a 60%,#b93e55);
  border-color:#ffa7a0;box-shadow:inset 0 2px 0 #ffd5c280,0 4px 0 #73253a,0 10px 20px #0b051b80;
}
/* Complex sheets use a compact seal, well-separated information, and legible inputs. */
.sheet[data-dialog="solve"]{width:min(630px,100%)}
.sheet[data-dialog="solve"] .dialog-seal{width:51px;height:51px;border-radius:17px}
.sheet[data-dialog="solve"] .dialog-seal svg{width:27px;height:27px}
.sheet .qq{
  background:linear-gradient(100deg,rgba(255,223,159,.14),rgba(174,108,171,.11));
  border:1px solid rgba(254,217,159,.26);border-left:3px solid #ffd37d;
  border-radius:12px;padding:13px 15px;margin-bottom:13px;
  color:#fff7ee;font-size:clamp(13px,1.5vw,15px);font-weight:800;line-height:1.6;
}
.sheet .guessinput{
  display:block;margin:7px 0 13px;width:100%;min-height:62px;padding:14px 17px;
  border:1.8px solid #d6aa81;border-radius:14px;
  background:rgba(15,8,30,.76);box-shadow:inset 0 2px 9px #040211,0 0 0 3px #d9ae6b10;
  color:#fffaf1;font-family:var(--fx-body)!important;font-size:clamp(17px,2vw,20px);
  font-weight:800;letter-spacing:0;line-height:1.5;text-align:center;
}
.sheet .guessinput::placeholder{color:#b4a0b5;opacity:1;font-weight:600;font-size:clamp(14px,2vw,16px)}
.sheet .guessinput:focus{outline:0;border-color:#ffe3a0;box-shadow:0 0 0 3px #ffcf7452,inset 0 2px 9px #040211}
.dialog-input-label{display:block;margin-top:17px;color:#e9c58e;font-size:10px;font-weight:900;letter-spacing:.13em}
.sheet .solve-count{display:flex;gap:6px;align-items:center;flex-wrap:wrap;color:#dac7d6;font-size:12.5px;margin-bottom:11px}
.sheet .warn{border:1px solid #b65e6d;background:linear-gradient(110deg,#68283e8c,#4a233a99);color:#ffdfde;
  border-radius:12px;padding:12px 14px;margin:12px 0;font-size:12px;line-height:1.7}
.sheet .warn b{color:#ffefbc}
.sheet .solvehint{font-size:13px;border-radius:12px}
.sheet .tipvn{color:#d4c2d3;font-size:12px;line-height:1.6;margin:10px 0 12px}
.sheet .tipvn b{color:#ffe5ac}
.sheet .dialog-tips{margin:10px 0 0;color:#d9c9dc;font-size:12px;line-height:1.7;
  border-top:1px solid #ad806d42;padding-top:12px}
.sheet .dialog-tips summary{cursor:pointer;list-style:none;font-weight:800;color:#eacb9e}
.sheet .dialog-tips summary::before{content:"ⓘ";margin-right:8px;color:#82e8d5}
.sheet .dialog-tips[open] summary{margin-bottom:7px}
.sheet .dialog-tips p{font-size:12px;margin-bottom:0}
.sheet .reveal{font-family:var(--fx-body)!important;font-weight:900;letter-spacing:.02em;
  border-radius:14px;background:linear-gradient(110deg,#e6b35a33,#ffeab017);border-color:#f4c576;color:#ffefc5}
.sheet ul{color:#e5d4e2;line-height:1.8}
.sheet li{margin-bottom:6px}
.sheet .sharebox{border-radius:13px;border-color:#ad866d;background:#170e2b;color:#fbefe0}
.sheet .newrec{font-family:var(--fx-body)!important;font-weight:900}
.sheet .rank div{background:#79476335;border-color:#b8878c60}
.sheet .rank div.first{background:#e6b85e27;border-color:#e9bb78}
.sheet .qbar{margin-top:9px;height:9px;background:#150b26;border:1px solid #966c87}
.sheet .qopt{min-height:48px;border-radius:13px;background:linear-gradient(150deg,#693960aa,#322042a8);border-color:#b78b92;
  color:#fff4e8;font-family:var(--fx-body);font-weight:800;box-shadow:inset 0 1px #f0c8d329}
.sheet .qopt:hover:not(:disabled){border-color:#ffe3a0;background:#754467}
.sheet .gbox{border-radius:18px;background:linear-gradient(155deg,#9b5276,#552a60 72%,#371b47);border-color:#f7cb8b;
  box-shadow:inset 0 3px 0 #fff0d635,0 10px 20px #0c061dbb}
.sheet .gbox.curse{background:linear-gradient(155deg,#af605e,#6c293e 70%,#36192d);border-color:#ed9b78}
@keyframes dialogBackdrop{from{opacity:0}to{opacity:1}}
@keyframes dialogArrival{from{opacity:0;transform:translateY(14px) scale(.955)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(max-width:540px){
  .modal{padding:12px;align-items:center}
  .sheet{max-height:min(91dvh,850px);padding:19px 17px 20px;border-radius:22px}
  .dialog-chrome{margin-bottom:12px;padding-bottom:10px}
  .dialog-seal{width:48px;height:48px;border-radius:15px;margin-bottom:10px}
  .dialog-seal svg{width:26px;height:26px}
  .sheet h3{font-size:clamp(21px,5.4vw,26px);margin-bottom:8px}
  .sheet p{font-size:12.5px}
  .sheet .btns{gap:9px;margin-top:16px}
  .sheet .btns button{font-size:12.5px!important;padding:11px 9px;min-height:51px}
  .sheet .qq{font-size:13px;padding:10px 11px}
  .dialog-overline{font-size:9px;letter-spacing:.09em}
  .dialog-badge{font-size:9px;padding:5px 8px}
  .sheet .boxrow,.sheet .gbox{height:117px}
  .sheet .gbox{padding:5px}.sheet .gbox .face{font-size:11px}
}
@media(max-width:350px){.sheet .btns{gap:7px}.sheet .btns button{font-size:11.5px!important;padding:9px 7px}}
@media(prefers-reduced-motion:reduce){.modal,.sheet{animation:none!important}}
