/* Selected concept: centered rhythm. Shared geometry for every popup state. */
#how-dialog.balanced-popup,#result.balanced-popup{
  --popup-pad:38px;--popup-head:54px;--popup-action:62px;
  box-sizing:border-box;width:660px;height:476px;min-width:0;max-width:calc(100vw - 32px);
  max-height:calc(100dvh - 32px);padding:var(--popup-pad);overflow:auto;
  border:2px solid #408fc0;border-radius:28px;background:#16456d;
  color:#f7faff;box-shadow:0 16px 50px #071b3033;clip-path:none;backdrop-filter:none;
  font-family:'Poppins',sans-serif;
}
#how-dialog[open],#result.balanced-popup:not([hidden]){display:grid;grid-template-rows:var(--popup-head) minmax(0,1fr) var(--popup-action);gap:22px}
#result.balanced-popup{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);z-index:21}
#result.balanced-popup[hidden],#result [hidden]{display:none!important}
.balanced-header{position:relative;display:flex;justify-content:center;align-items:center;padding:0 36px;min-width:0}
#how-dialog .balanced-header h2,#result #result-title{margin:0;font:600 40px/1.25 'Poppins',sans-serif;letter-spacing:-1px;text-align:center;color:#fff}
#how-dialog .balanced-close,#result .balanced-close{position:absolute;right:-14px;top:-8px;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:12px;background:transparent;color:#f7faff;box-shadow:none;clip-path:none;transform:none}
.balanced-close .material-symbols-rounded{font-size:34px;font-variation-settings:'FILL' 1,'wght' 500}
#how-dialog .balanced-close:hover,#result .balanced-close:hover{background:#ffffff12;box-shadow:none;transform:none}
.balanced-content{min-width:0;min-height:0;display:flex;align-items:center;justify-content:center}
#how-dialog .help-steps{width:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;list-style:none;padding:0;margin:0}
#how-dialog .help-steps li{display:flex;flex-direction:column;align-items:center;gap:20px;min-width:0;margin:0;padding:0}
.help-art{position:relative;height:132px;width:100%;overflow:hidden;container-type:size}
/* Normalize the visible ball, not the differently padded 1254px illustrations.
   Each image uses its measured ball diameter and centre as the layout anchor. */
.help-art img{--ball-size:min(80px,40cqw,62cqh);--art-scale:1.974803;--ball-x:.803937;--ball-y:1.047244;position:absolute;left:calc(50% - var(--ball-size)*var(--ball-x));top:calc(50% - var(--ball-size)*var(--ball-y));transform:none;display:block;width:calc(var(--ball-size)*var(--art-scale));height:auto;max-width:none;object-fit:contain}
.help-steps li:first-child .help-art img{--art-scale:2.799107;--ball-x:1.399554;--ball-y:1.420759}
.help-steps li:last-child .help-art img{--art-scale:1.863299;--ball-x:.817236;--ball-y:.849183}
#how-dialog .help-steps p{margin:0;color:#bdd6ee;font:500 22px/1.5 'Poppins',sans-serif;white-space:nowrap;letter-spacing:-.5px;text-align:center}
#how-dialog.balanced-popup{height:510px}
.help-content{flex-direction:column;gap:22px;transform:none}
#how-dialog .help-reward{box-sizing:border-box;display:flex;align-items:center;justify-content:center;gap:12px;width:324px;max-width:100%;min-height:52px;padding:10px 16px;margin:0;flex-shrink:0;border:1px solid #82b8df26;border-radius:14px;background:#0d3455;color:#e7f2fc;font:500 19px/1.4 'Poppins',sans-serif;white-space:nowrap}
#how-dialog .help-reward-copy{display:inline-flex;align-items:baseline;gap:.4em;line-height:1;transform:translateY(.1em)}
#how-dialog .help-reward-equals{color:#86abc8;margin:0}
#how-dialog .help-reward strong{color:#ffcf53;font-weight:600}
#how-dialog .help-reward img{display:block;width:30px;height:30px;flex-shrink:0;filter:drop-shadow(0 2px 2px #051e3d40)}
.result-content{flex-direction:column;gap:20px}
.result-art{display:block;width:276px;height:212px;max-height:100%;object-fit:contain}
#result[data-outcome=complete] .result-art{width:170px;height:175px}
#result #result-stars{display:flex;align-items:center;justify-content:center;margin:0;gap:26px;transform:translateY(-20px)}
#result #result-stars .rating-star{width:120px;height:120px;object-fit:contain}
#result #result-description{display:flex;align-items:center;justify-content:center;gap:12px;margin:0;color:#fff;font:600 30px/1.2 'Poppins',sans-serif}
#result #result-description .rating-star{width:38px;height:38px}
.balanced-actions,#result .balanced-actions{display:flex;align-items:center;justify-content:center;gap:0;margin:0;padding:0}
#how-dialog .dialog-play,#result .result-actions button{display:flex;align-items:center;justify-content:center;width:324px;max-width:100%;height:var(--popup-action);min-height:0;margin:0;padding:0 24px;border:3px solid #ffc03b;border-radius:17px;background:linear-gradient(180deg,#ffad2b 0%,#ff8f1d 78%,#ed6812 100%);color:#fff;box-shadow:none;clip-path:none;text-shadow:none;font:600 26px/1.2 'Poppins',sans-serif;letter-spacing:-.5px;transition:background .15s}
#how-dialog .dialog-play:hover,#result .result-actions button:hover{background:linear-gradient(180deg,#ffb43b,#ff9526 78%,#ed6812);transform:none;box-shadow:none}
#how-dialog button:focus-visible,#result button:focus-visible{outline:3px solid #fff;outline-offset:4px}
@media(max-width:600px){
  #how-dialog.balanced-popup,#result.balanced-popup{--popup-pad:24px;--popup-head:42px;--popup-action:54px;height:410px;border-radius:24px}
  #how-dialog[open],#result.balanced-popup:not([hidden]){gap:20px}
  #how-dialog .balanced-header h2,#result #result-title{font-size:24px;letter-spacing:-.6px}
  .balanced-header{padding:0 22px}
  #how-dialog .balanced-close,#result .balanced-close{right:-14px;top:-12px;width:40px;height:40px}
  .balanced-close .material-symbols-rounded{font-size:26px}
  #how-dialog .help-steps{gap:8px}
  #how-dialog .help-steps li{gap:20px}
  .help-art{height:100px}
  #how-dialog .help-steps p{font-size:14px;letter-spacing:-.4px}
  #result #result-stars{gap:12px}
  #result #result-stars .rating-star{width:70px;height:70px}
  .result-art{width:210px;height:165px}
  #result[data-outcome=complete] .result-art{width:128px;height:130px}
  #result #result-description{font-size:22px}
  #how-dialog .dialog-play,#result .result-actions button{width:260px;font-size:20px;border-radius:15px}
}
@media(max-height:540px){
  #how-dialog.balanced-popup,#result.balanced-popup{--popup-pad:22px;--popup-head:38px;--popup-action:48px;height:calc(100dvh - 24px);max-height:none;max-width:calc(100vw - 32px)}
  #how-dialog[open],#result.balanced-popup:not([hidden]){gap:12px}
  #how-dialog .balanced-header h2,#result #result-title{font-size:25px}
  .help-art{height:90px}
  #how-dialog .help-steps li{gap:12px}
  #how-dialog .help-steps p{font-size:16px}
  .result-art{height:125px;width:190px}
  #result[data-outcome=complete] .result-art{height:95px;width:105px}
  .result-content{gap:10px}
  #result #result-stars .rating-star{width:76px;height:76px}
  #result #result-description{font-size:20px}
  #how-dialog .dialog-play,#result .result-actions button{font-size:20px}
}

/* In-game outcomes stay compact so the street remains visible around them. */
#result.balanced-popup{
  --popup-pad:26px;--popup-head:40px;--popup-action:50px;
  width:440px;height:min(340px,calc(100dvh - 32px));max-height:calc(100dvh - 32px);border-radius:24px;
}
#result.balanced-popup:not([hidden]){gap:14px}
#result #result-title{font-size:28px;letter-spacing:-.7px}
#result .balanced-header{padding:0 24px}
#result .balanced-close{right:-16px;top:-12px;width:40px;height:40px}
#result .balanced-close .material-symbols-rounded{font-size:26px}
#result .result-content{gap:10px}
#result .result-art{width:196px;height:150px}
#result[data-outcome=complete] .result-art{width:118px;height:116px}
#result #result-stars{gap:18px;transform:none}
#result #result-stars .rating-star{width:80px;height:80px}
#result #result-description{font-size:23px;gap:8px}
#result #result-description .rating-star{width:30px;height:30px}
#result .result-actions button{width:252px;font-size:20px;border-radius:14px}
/* Replay and advance share one row, keeping the compact result height. */
#result .result-actions{flex-direction:row;gap:12px;width:100%;max-width:324px;margin-inline:auto}
#result .result-actions:has(#next-stage-button:not([hidden])) button{flex:1;min-width:0;width:auto;padding-inline:12px}
#result .result-actions button.secondary-action{border:2px solid #689cc4;background:#22577f;color:#eef7ff}
#result .result-actions button.secondary-action:hover{background:#2b6895;border-color:#9bc7e8}
@media(max-width:480px){
  #result.balanced-popup{--popup-pad:22px;height:min(324px,calc(100dvh - 32px))}
  #result #result-title{font-size:24px}
  #result #result-stars{gap:12px}
  #result #result-stars .rating-star{width:72px;height:72px}
}
