/* AC140 (build 56 feedback): Settings legal links and the in-app legal pages
   (legal-ui.js, docs/LEGAL_IN_GAME.md). The links are plain underlined text, one
   at each side of a row under the Settings menu, each a 44px touch target. A page
   scrolls only its text box; the title, draft tag and Back stay fixed. */
/* AC155: the card and its existing Close keep their parchment frame; the legal
   links follow on the dim backdrop, inside the dialog's top-layer hit testing. */
#modal.settings-backdrop-links{padding:0;border:0;background:transparent;box-shadow:none;overflow:visible;max-height:calc(100dvh - var(--safe-top,env(safe-area-inset-top,0px)) - var(--safe-bottom,env(safe-area-inset-bottom,0px)) - 24px)}
#modal .settings-modal-card{padding:16px;border:4px solid #c4a268;border-radius:24px;background:linear-gradient(var(--cream-250),#eed7aa);box-shadow:0 20px 60px #0006}
#modal .settings-modal-card>.secondary[data-action=dismiss]{width:100%;margin:8px 0 0}
#modal .settings-legal{display:flex;justify-content:space-between;gap:12px;margin:8px 8px 0}
#modal .settings-legal .legal-link{all:unset;box-sizing:border-box;display:flex;align-items:center;min-height:44px;min-width:44px;padding:0;cursor:pointer;color:#fff;font:700 14px/1.2 system-ui;-webkit-tap-highlight-color:transparent}
#modal .settings-legal .legal-link>span{padding-bottom:3px;background:linear-gradient(currentColor,currentColor) 0 100%/100% 1.5px no-repeat}
#modal .settings-legal .legal-link:last-child{text-align:right;justify-content:flex-end}
#modal .settings-legal .legal-link:active>span{color:var(--gold-100)}
:root[data-input-modality=keyboard] #modal .settings-legal .legal-link:focus-visible{outline:2px solid #fff;outline-offset:2px;border-radius:8px}
@media(max-height:700px){#modal .settings-modal-card{padding:12px 14px}}
#modal:has(.legal-panel){width:min(410px,calc(100vw - 28px));padding:16px;max-height:calc(100dvh - var(--safe-top,env(safe-area-inset-top,0px)) - var(--safe-bottom,env(safe-area-inset-bottom,0px)) - 24px)}
#modal .legal-panel{display:flex;flex-direction:column;min-height:0}
#modal .legal-panel>h1{margin:0 0 4px}
#modal .legal-panel>.legal-draft{align-self:flex-start;margin:0 0 8px;padding:2px 10px;border-radius:8px;background:#b8731c;color:#fff;font:800 12px/1.45 system-ui;letter-spacing:.04em;text-transform:uppercase}
/* CJK copy is never letter-spaced (game/locales/GLOSSARY.md). */
:is(:lang(ja),:lang(ko),:lang(zh-Hans),:lang(zh-Hant)) #modal .legal-panel>.legal-draft{letter-spacing:0}
/* A real border, not an inset shadow: the scroll box clips its text inside the frame,
   so a line scrolled past the top never paints over the frame. */
#modal .legal-text{max-height:calc(100dvh - var(--safe-top,env(safe-area-inset-top,0px)) - var(--safe-bottom,env(safe-area-inset-bottom,0px)) - 236px);overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;touch-action:pan-y;padding:8px 10px;border:2px solid #e3cf9f;border-radius:14px;background:var(--cream-50);text-align:left;color:#2c3445;outline-offset:2px}
:root:not([data-input-modality=keyboard]) #modal .legal-text:focus{outline:none}
:root[data-input-modality=keyboard] #modal .legal-text:focus-visible{outline:2px solid #b67939}
#modal .legal-text p{margin:0;font:14px/1.42 system-ui;overflow-wrap:anywhere}
/* Korean wraps at the spaces between words, never inside one (an e-mail may still break). */
:lang(ko) #modal .legal-text{word-break:keep-all}
#modal .legal-text .legal-intro{margin-bottom:10px}
#modal .legal-section{margin:0 0 10px}
#modal .legal-section h2{margin:0 0 2px;font:800 15px/1.3 system-ui;color:#2c3a52}
#modal .legal-text .legal-more{margin-top:4px;color:#5a5f6e;font-size:13px}
#modal:has(.legal-panel)>button,#modal:has(.legal-panel)>.equipment-actions{margin-top:12px}
@media(max-height:700px){
 #modal:has(.legal-panel){padding:12px 14px}
 #modal .legal-panel>h1{margin-bottom:2px;font-size:26px}
 #modal .legal-text{max-height:calc(100dvh - var(--safe-top,env(safe-area-inset-top,0px)) - var(--safe-bottom,env(safe-area-inset-bottom,0px)) - 216px)}
 #modal:has(.legal-panel)>button,#modal:has(.legal-panel)>.equipment-actions{margin-top:8px}
}

/* Compact Settings reserves space for the two legal links below the fixed card. */
@media(max-height:700px){
 #modal .settings-panel>h1{margin-bottom:6px}
 #modal .settings-panel>p{margin-bottom:8px}
 #modal .settings-panel .menu-grid{gap:8px}
 #modal .settings-panel .settings-language{margin-top:6px;padding-top:4px;padding-bottom:6px}
 #modal .settings-panel .settings-rows>.settings-language{margin-top:0;padding-bottom:4px}
 #modal .settings-panel .settings-language .secondary{min-height:44px;padding-top:4px;padding-bottom:4px}
 /* A two-line paired label (ja アップデート情報) packs tighter so the legal row stays on screen. */
 #modal .settings-panel .settings-pair .secondary{min-height:44px;padding-top:4px;padding-bottom:4px;line-height:1.05}
 #modal .settings-panel .home-scenery-options{margin-top:6px;padding:4px 8px 6px}
 #modal .settings-panel .home-scenery-options .secondary{min-height:44px;padding:4px 6px}
}

/* Legal destinations stay legible on the cream document surface in both themes. */
#modal .legal-text a,#modal .legal-text a:visited{color:#2a527a;text-decoration:underline;text-underline-offset:2px}
