/* 5×5 matrix: fixed corners and central edge ornaments, stretchable flanks. */
:root{--dialog-corner:44px;--dialog-edge-center:64px;}
#command-result[hidden]{display:none;}
#command-result{display:block;width:auto;min-width:78px;min-height:28px;padding:5px 10px;margin:5px auto 0;font-size:11px;white-space:nowrap;}
:is(.modal,.ranking-overlay,.multiplayer-modal){padding:20px;align-items:center;justify-content:center;background:rgba(3,7,11,.88);backdrop-filter:none;}
:is(.modal,.ranking-overlay,.multiplayer-modal) .framed-dialog{position:relative;isolation:isolate;padding:0;border:0;border-radius:0;background:#111720;overflow:visible;width:min(680px,calc(100vw - 40px));max-width:calc(100vw - 40px);max-height:calc(100dvh - 40px);box-shadow:0 26px 90px #000b,0 2px 5px #000;min-height:calc(2 * var(--dialog-corner) + var(--dialog-edge-center));}
.framed-dialog::before,.framed-dialog::after{display:none!important;}
.dialog-frame{position:absolute;inset:0;display:grid;grid-template-columns:var(--dialog-corner) minmax(0,1fr) var(--dialog-edge-center) minmax(0,1fr) var(--dialog-corner);grid-template-rows:var(--dialog-corner) minmax(0,1fr) var(--dialog-edge-center) minmax(0,1fr) var(--dialog-corner);pointer-events:none;z-index:-1;}
.dialog-frame>[data-frame-region]{display:block;background-image:url('../../assets/ui/dialog-frame-17.svg');background-size:500% 500%;background-repeat:no-repeat;}
.dialog-frame>[data-frame-region=center]{background-size:166.666667% 166.666667%;}
.framed-dialog>.dialog-content{box-sizing:border-box;max-height:calc(100dvh - 40px);overflow:auto;overscroll-behavior:contain;padding:40px;scrollbar-width:thin;scrollbar-color:#8c7449 #111820;}
.framed-dialog .dialog-content>h2{margin-top:0;color:#efe3c9;font-family:'Cinzel',serif;}
.framed-dialog .dialog-content>button{min-height:44px;}
.framed-dialog :is(button,a,input,select,summary):focus-visible{outline:2px solid #f5d59b;outline-offset:4px;}
.framed-dialog .ranking-controls{display:flex;flex-wrap:wrap;gap:10px;margin:18px 0;}
.framed-dialog .ranking-list li{display:flex;align-items:center;flex-wrap:wrap;gap:10px;}
.framed-dialog .ranking-list li>strong{flex:1 1 100%;}
.framed-dialog .ranking-details{border-top:1px solid #aa8b5044;padding-top:18px;margin-top:18px;}
.framed-dialog .ranking-details[hidden]{display:none;}
.match-kicker{display:block;color:#bba36e;font:10px/1.4 'Cinzel',serif;letter-spacing:.2em;text-transform:uppercase;}
.match-summary-modal .match-summary-panel{width:min(760px,calc(100vw - 40px));}
.match-summary-header{position:relative;padding-right:75px;border-bottom:1px solid #c1a46a33;padding-bottom:20px;}
.match-summary-header .match-result-seal{position:absolute;right:0;top:0;display:grid;place-items:center;width:62px;height:62px;border:1px solid #b89a59;background:radial-gradient(circle,#69502b33,#141a20 68%);color:#d5b875;font:34px 'Cinzel',serif;box-shadow:inset 0 0 0 5px #121821,inset 0 0 0 6px #806d4555;}
.match-summary-header h2{font:500 clamp(40px,5vw,58px)/1.1 'Cinzel',serif!important;color:#efd89f;margin:12px 0!important;letter-spacing:-.035em;}
.match-summary-modal[data-status=defeat] h2{color:#dd9c88;}
.match-summary-header p{margin:0!important;max-width:53ch;color:#b9bec5!important;font-size:14px!important;line-height:1.6!important;}
.match-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:20px 0;}
.match-metrics>div{border-left:1px solid #b99b574d;padding-left:14px;}
.match-metrics dt{font:10px/1.4 'Cinzel',serif;color:#a8adb4;text-transform:uppercase;letter-spacing:.08em;}
.match-metrics dd{margin:7px 0 0;font:500 24px/1.2 'Cinzel',serif;color:#e9dfcb;font-variant-numeric:tabular-nums;}
.match-comparison{display:grid;grid-template-columns:1fr 1fr;gap:12px;}
.match-player{position:relative;min-width:0;border:1px solid #86909c30;background:linear-gradient(135deg,#27313e55,#10172088);padding:18px;}
.match-player.is-winner{border-color:#b59a5a80;background:linear-gradient(135deg,#68512b33,#111820);}
.match-player-role{font:9px 'Cinzel',serif;letter-spacing:.1em;text-transform:uppercase;color:#a59c86;}
.match-player h3{font:500 16px/1.4 'Cinzel',serif!important;color:#e8dcc4!important;margin:8px 0 3px;overflow-wrap:anywhere;}
.match-player .match-player-house{font:12px/1.5 'Cormorant Garamond',serif!important;color:#b8b9bb!important;margin:0 0 14px;}
.match-material-score{display:block;font:500 30px/1.2 'Cinzel',serif;color:#d7bc7e;font-variant-numeric:tabular-nums;}
.match-player .match-capture-count{font-size:12px!important;color:#bbc1c7!important;margin:8px 0!important;}
.match-player .match-captured-types{display:flex;flex-wrap:wrap;gap:5px;list-style:none;margin:12px 0 0;padding:0;}
.match-player .match-captured-types li{font:11px/1.3 'Cormorant Garamond',serif!important;border:1px solid #c7ad7633;color:#d0cbc1;padding:3px 6px;}
.match-scoring{margin:16px 0;font-size:12px;}
.match-scoring summary{cursor:pointer;color:#b9a376;padding:5px 0;}
.match-scoring p{font-size:12px!important;line-height:1.5!important;color:#aeb4bd!important;}
.match-ad-label{display:block;font:9px 'Cinzel',serif;text-transform:uppercase;letter-spacing:.13em;color:#9299a3;margin-bottom:6px;}
.match-ad-card{display:grid;grid-template-columns:minmax(0,1fr) 42%;position:relative;overflow:hidden;min-height:112px;border:1px solid #bba06b44;background:#080d12;color:#e3d7be;text-decoration:none;}
.match-ad-card>img{position:absolute;right:0;top:0;width:58%;height:100%;object-fit:cover;object-position:72% 48%;opacity:.65;mask-image:linear-gradient(to right,transparent,#000 34%);}
.match-ad-card>div{position:relative;padding:15px 18px;grid-column:1 / 2;z-index:1;}
.match-ad-card strong{display:block;font:500 16px 'Cinzel',serif;color:#e3cd9a;}
.match-ad-card div>span:not(.match-ad-cta){display:block;font:12px/1.5 'Cormorant Garamond',serif;color:#bfc2c6;margin-top:6px;}
.match-ad-cta{display:block;margin-top:10px;color:#d1b475;font:10px 'Cinzel',serif;}
.match-actions{display:grid;grid-template-columns:1fr 1fr 1.25fr;gap:10px;position:sticky;bottom:0;margin:22px 0 0;background:linear-gradient(180deg,#10162000,#101620 30%);padding-top:12px;z-index:2;}
.match-actions button{min-height:44px;font-size:12px;padding:10px;white-space:normal;}
.match-summary-modal[aria-hidden=false] .match-summary-panel{animation:dialog-enter .24s ease-out;}
@keyframes dialog-enter{from{opacity:0;transform:translateY(8px) scale(.99);}to{opacity:1;transform:none;}}
@media(max-width:720px){
 :root{--dialog-corner:32px;--dialog-edge-center:48px;}
 :is(.modal,.ranking-overlay,.multiplayer-modal){padding:10px;}
 :is(.modal,.ranking-overlay,.multiplayer-modal) .framed-dialog{max-width:calc(100vw - 20px);width:min(680px,calc(100vw - 20px));max-height:calc(100dvh - 20px);}
 .framed-dialog>.dialog-content{max-height:calc(100dvh - 20px);padding:28px 22px;}
 .match-summary-header{padding-right:44px;padding-bottom:14px;}.match-summary-header .match-result-seal{width:36px;height:42px;font-size:23px;}.match-summary-header h2{font-size:38px!important;}
 .match-comparison{gap:8px;}.match-player{padding:12px;}.match-material-score{font-size:24px;}.match-player h3{font-size:13px!important;}
 .match-metrics{gap:8px;margin:15px 0;}.match-metrics>div{padding-left:9px;}.match-metrics dd{font-size:20px;}
 .match-ad-card{grid-template-columns:65% 35%;min-height:110px;}.match-ad-card>div{padding:12px;}.match-ad-card strong{font-size:13px;}
 .match-actions{grid-template-columns:1fr 1fr;gap:8px;margin-top:15px;}.match-actions [data-result=restart]{grid-column:1 / -1;}
 #command-result{min-width:62px;font-size:10px;}
}
@media(prefers-reduced-motion:reduce){.match-summary-modal[aria-hidden=false] .match-summary-panel{animation:none;}}

/* Panel frame: the dialog ornament over HUD panels, cards and boxes. */
.panel-frame-host{position:relative;}
.has-panel-frame{--pf-corner:34px;--pf-edge:48px;}
.panel-frame{position:absolute;inset:0;display:grid;pointer-events:none;z-index:4;
  grid-template-columns:var(--pf-corner) minmax(0,1fr) var(--pf-edge) minmax(0,1fr) var(--pf-corner);
  grid-template-rows:var(--pf-corner) minmax(0,1fr) var(--pf-edge) minmax(0,1fr) var(--pf-corner);
  filter:drop-shadow(0 1px 2px #000a);}
.panel-frame[data-frame-size=lg]{--pf-corner:40px;--pf-edge:58px;}
.panel-frame[data-frame-size=md]{--pf-corner:30px;--pf-edge:44px;}
.panel-frame[data-frame-size=sm]{--pf-corner:20px;--pf-edge:30px;}
.panel-frame>[data-frame-region]{display:block;background-image:url('../../assets/ui/panel-frame-17.svg');background-size:500% 500%;background-repeat:no-repeat;}
.has-panel-frame{border-color:transparent!important;border-radius:0!important;}
.has-panel-frame::before,.has-panel-frame::after{border-radius:0!important;}
@media (max-width:720px){.panel-frame[data-frame-size=lg]{--pf-corner:28px;--pf-edge:40px;}.panel-frame[data-frame-size=md]{--pf-corner:24px;--pf-edge:34px;}.panel-frame[data-frame-size=sm]{--pf-corner:16px;--pf-edge:24px;}}
.has-panel-frame>.panel-frame{position:absolute!important;inset:0!important;width:auto!important;height:auto!important;max-width:none!important;margin:0!important;padding:0!important;z-index:5!important;transform:none!important;opacity:1!important;background:none!important;border:0!important;}
.panel-frame[data-frame-size=sm]{--pf-corner:16px;--pf-edge:24px;}
/* Scrolling inner boxes: the same gold-on-iron language as corner brackets
   painted in the box background, so it never scrolls or covers text. */
:is(#turn-strip,#game-tips,#battle-log,.hud input,#player-name){border:1px solid #6f5b38!important;border-radius:2px!important;
  box-shadow:inset 0 0 0 1px #05080c,inset 0 0 0 2px #b2956126,0 1px 3px #0008!important;
  background-image:linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a),
   linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a),linear-gradient(#e6c98a,#e6c98a)!important;
  background-size:10px 1.5px,1.5px 10px,10px 1.5px,1.5px 10px,10px 1.5px,1.5px 10px,10px 1.5px,1.5px 10px!important;
  background-position:3px 3px,3px 3px,calc(100% - 3px) 3px,calc(100% - 3px) 3px,3px calc(100% - 3px),3px calc(100% - 3px),calc(100% - 3px) calc(100% - 3px),calc(100% - 3px) calc(100% - 3px)!important;
  background-repeat:no-repeat!important;background-attachment:local,local,local,local,local,local,local,local;}
:is(#turn-strip,#game-tips,#battle-log){background-color:#120d1ccc!important;background-attachment:scroll!important;}
.hud.hint-card.has-panel-frame{padding-left:max(16px,var(--hud-pad,16px))!important;padding-right:16px!important;padding-top:16px!important;}

/* ---- Sponsor spaces (Adsterra) and support ---- */
.ad-slot{display:flex;flex-direction:column;align-items:center;gap:4px;}
.ad-slot-label{font:9px 'Cinzel',serif;text-transform:uppercase;letter-spacing:.16em;color:#8f8a7d;}
.ad-slot-body{max-width:100%;overflow:hidden;}
.ad-slot-body iframe{display:block;border:0;}
.ad-slot-body.is-house{width:100%;}
.start-ad{position:relative;display:flex;align-items:flex-start;justify-content:center;gap:10px;margin:14px auto 0;max-width:min(860px,100%);padding:10px 12px;border:1px solid #6f5b3866;background:#06090dcc;}
.start-ad[hidden]{display:none!important;}
.start-ad>[data-ad=start]{flex:1 1 auto;min-width:0;}
.start-ad .ad-slot-body.is-house .match-ad-card{min-height:90px;}
.ad-close{flex:0 0 auto;min-height:30px;padding:4px 10px;font:600 11px 'Cinzel',serif;color:#e9d6a8;background:#141821;border:1px solid #8c7449;cursor:pointer;}
.ad-close:disabled{opacity:.6;cursor:default;}
.hud-ad{margin-top:14px;padding-top:10px;border-top:1px solid #6f5b3855;}
.hud-ad .ad-slot-body.is-house .match-ad-card{min-height:96px;grid-template-columns:1fr;}
@media (max-width:1100px){.hud-ad{display:none;}}
.support-pix{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 12px;margin:12px auto 0;padding:10px 14px;border:1px solid #6f5b3866;background:#0a0e14b3;color:#d9cba8;font:14px 'Cormorant Garamond',serif;}
.support-pix strong{font:700 13px 'Cinzel',serif;color:#f0d391;letter-spacing:.06em;}
.support-pix code{font:600 13px ui-monospace,Consolas,monospace;color:#ffe7a3;background:#000a;padding:3px 8px;border:1px solid #8c744966;user-select:all;}
.support-pix button{min-height:30px;padding:4px 12px;font-size:12px;}
.support-pix.is-compact{max-width:min(860px,100%);font-size:13px;}
/* Match-end gate: sponsor first, result after the countdown. */
.match-ad-gate-panel{text-align:center;}
.match-ad-gate-panel h2{margin:4px 0 14px;}
.match-ad-gate-slot{min-height:250px;display:flex;justify-content:center;margin-bottom:16px;}
.match-ad-gate-slot .ad-slot-body.is-house{width:min(520px,100%);}
/* Share card */
.match-share{display:grid;grid-template-columns:150px 1fr;gap:16px;align-items:center;margin:16px 0 8px;padding:12px;border:1px solid #6f5b3866;background:#0a0e14b3;}
.match-share-preview img{display:block;width:150px;aspect-ratio:9/16;object-fit:cover;border:1px solid #8c7449;background:#000;}
.match-share-actions h3{margin:0 0 4px;font:700 15px 'Cinzel',serif;color:#f0d391;}
.match-share-actions p{margin:0 0 10px;color:#cdbf9f;font:14px 'Cormorant Garamond',serif;}
.match-share-buttons{display:flex;flex-wrap:wrap;gap:8px;}
.match-share-buttons button{min-height:36px;}
.match-support .support-pix{margin-top:10px;}
@media (max-width:640px){.match-share{grid-template-columns:96px 1fr;}.match-share-preview img{width:96px;}}
.start-ad{margin-top:10px;padding:6px 8px;gap:8px;align-items:center;}
.start-ad .ad-slot{gap:2px;}
.start-ad .ad-slot-body.is-house{width:min(728px,100%);height:90px;}
.start-ad .match-ad-label{display:none;}
.start-ad .match-ad-card{min-height:90px;height:90px;grid-template-columns:minmax(0,1fr) 46%;}
.start-ad .match-ad-card>div{padding:10px 14px;}
.start-ad .match-ad-card strong{font-size:14px;}
.start-ad .match-ad-card div>span:not(.match-ad-cta){display:none;}
.start-ad .match-ad-cta{margin-top:6px;}
.support-panel{text-align:center;}
.support-panel .support-pix{margin:12px 0 16px;}
.support-btn span{color:#ff8a8a;}
.start-ad{width:min(820px,96%);box-sizing:border-box;}
.start-ad>[data-ad=start]{flex:1 1 728px;max-width:728px;}
.start-ad .ad-slot-body.is-house{width:100%;}
