/* Responsive layout and touch controls; loaded after the reference styles. */
.site-menu{display:contents}
.nav-left{grid-column:1;grid-row:1}
.nav-right{grid-column:3;grid-row:1}
.brand-center{grid-row:1}
.nav-toggle{align-items:center;justify-content:center;gap:8px;white-space:nowrap}
.nav-toggle span:first-child{font-size:22px;line-height:1}
.menu-backdrop[hidden]{display:none}
.menu-backdrop{position:fixed;inset:0;z-index:10060;background:rgba(18,12,30,.42);backdrop-filter:blur(2px)}
.nav-cluster a{min-height:44px;font-size:14px;padding:10px 12px;border-radius:8px}
.button{display:inline-flex;align-items:center;justify-content:center;min-height:44px;font-size:14px;line-height:1.35;border-radius:9px;padding:10px 16px;text-align:center}
.tool-button{font-size:14px;min-height:44px;border-radius:9px}
.account-toggle{justify-content:center}
.home-intro>img{width:min(210px,35vw)}
.home-gangsterka{margin:8px 0 0;line-height:1.15}
.home-download-heading h2{margin:0;color:var(--purple);font-size:clamp(24px,3vw,34px);font-variant-caps:small-caps;font-weight:500}
.choice-check-target{display:grid;place-items:center;cursor:pointer}
.choice-row button.name{border:0;background:transparent;padding:0;text-align:left;color:var(--ink);font-family:var(--serif);font-weight:inherit}
:where(button,a,input,select,textarea):focus-visible{outline:3px solid var(--gold);outline-offset:3px}

@media (pointer:coarse){
  .button,.tool-button,.nav-cluster a,.level-jump,.detail-toggle,.account-primary,.account-secondary{min-height:48px}
  .account-tabs button{min-height:48px;font-size:16px;padding:12px}
  .account-close,.chat-close,.calendar-modal-close{width:48px;height:48px;min-width:48px;min-height:48px;flex-basis:48px}
}

@media screen and (min-width:1440px){
  .site-header{grid-template-columns:minmax(0,1fr) auto auto;padding-right:140px}
  .header-tools{display:grid;grid-template-columns:repeat(2,48px);gap:6px;width:102px;top:12px;right:16px}
  .header-tools .tool-button{width:100%;height:44px;min-width:0;padding-inline:8px}
  .header-tools .account-toggle{grid-column:1/-1;max-width:100%}
}

@media screen and (max-width:1439px){
  .site-header{grid-template-columns:80px minmax(0,1fr) auto;min-height:96px;gap:10px;padding:8px 12px}
  .brand-center{grid-column:2;grid-row:1;justify-self:center;width:106px}
  .brand-center img{width:62px;height:68px}
  .brand-center span{font-size:13px}
  .header-tools{position:static;display:flex;flex-direction:row;grid-column:3;grid-row:1}
  .brand-center::before,.brand-center::after{display:none}
  .nav-toggle{display:inline-flex;min-height:48px;min-width:80px;font-size:15px;border-radius:12px}
  .site-header.mobile-open{z-index:10065;overflow:visible;max-height:none}
  .site-menu{
    display:none;position:fixed;top:calc(var(--site-header-height,96px) + 8px);left:max(12px,env(safe-area-inset-left));
    width:min(440px,calc(100% - 24px));max-height:calc(var(--visual-viewport-height,100dvh) - var(--site-header-height,96px) - 24px - env(safe-area-inset-bottom));
    padding:12px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    border:1px solid var(--line);border-radius:16px;background:var(--paper);box-shadow:var(--shadow);
  }
  .site-header.mobile-open .site-menu{display:grid;gap:8px}
  .site-menu .nav-cluster,.site-header.mobile-open .site-menu .nav-cluster{
    display:grid;grid-template-columns:minmax(0,1fr);grid-column:auto;grid-row:auto;gap:6px;padding:0;width:100%;
  }
  .site-menu .nav-right{padding-top:8px;border-top:1px solid var(--line)}
  .site-menu .nav-cluster a{
    justify-content:flex-start;min-height:52px;font:700 16px/1.3 var(--sans);padding:12px 16px;border-radius:10px;text-align:left;white-space:normal;
  }
  .site-menu .nav-cluster a::after{content:'›';margin-left:auto;padding-left:12px;font-size:22px;line-height:1;color:var(--gold)}
  .site-menu .nav-cluster a.active{box-shadow:inset 3px 0 var(--gold);border-color:var(--purple2);transform:none}
  html.navigation-open,html.navigation-open body{overflow-y:hidden!important}
}

@media screen and (max-width:760px){
  html{scroll-padding-top:calc(var(--site-header-height,72px) + 12px)}
  body{font-size:17px;line-height:1.55}
  .site-header{
    grid-template-columns:80px minmax(48px,1fr) auto;min-height:72px;gap:6px;
    padding:8px max(10px,env(safe-area-inset-right)) 8px max(10px,env(safe-area-inset-left));
  }
  .brand-center{width:48px;min-height:48px}
  .brand-center img{width:44px;height:48px}
  .brand-center span{display:none}
  .header-tools{gap:4px}
  .header-tools .tool-button,.header-tools .account-toggle{
    width:48px!important;min-width:48px!important;height:48px;padding:0!important;font-size:14px;border-radius:12px;
  }
  .account-toggle-label{display:none}
  .header-tools .account-toggle .account-avatar{width:32px;height:32px;flex-basis:32px}
  .header-tools .account-toggle .account-avatar-fallback{font-size:12px}
  .app-shell{width:calc(100% - 20px);margin:12px auto max(96px,calc(80px + env(safe-area-inset-bottom)));min-width:0}
  .home-landing{display:block;min-height:0;padding:20px 16px 24px;border-radius:16px}
  .home-content{width:100%;min-width:0}
  .home-intro{display:grid;grid-template-columns:64px minmax(0,1fr);align-items:center;gap:14px;text-align:left}
  .home-intro>img{width:64px;height:auto;animation:none;filter:drop-shadow(0 4px 8px rgba(35,15,56,.15))}
  .home-intro>div{min-width:0}
  .home-gangsterka{margin:0;font-size:clamp(27px,8vw,36px);letter-spacing:.01em}
  .home-coming{margin:7px 0 0;font-size:16px;font-style:normal;line-height:1.5}
  .home-downloads{width:100%;margin-top:26px}
  .home-download-heading{display:block;padding-bottom:10px}
  .home-download-heading h2{font-size:26px;line-height:1.2}
  .home-download-heading small{display:block;margin-top:5px;font-size:13px;line-height:1.4;letter-spacing:0;text-transform:none}
  .pdf-download-grid,.game-download-grid{grid-template-columns:minmax(0,1fr);gap:10px;margin-top:12px}
  .pdf-download-card,.class-cheat-download{
    grid-template-columns:44px minmax(0,1fr) 28px;min-height:82px;gap:12px;padding:13px 12px;border-radius:12px;max-width:100%;
  }
  .pdf-download-icon,.class-cheat-download .pdf-download-icon{width:44px;height:48px;border-radius:8px}
  .pdf-download-icon svg,.class-cheat-download .pdf-download-icon svg{width:32px;height:36px}
  .pdf-download-copy strong,.class-cheat-download .pdf-download-copy strong{font-size:21px;line-height:1.2;overflow-wrap:anywhere}
  .pdf-download-copy small,.class-cheat-download .pdf-download-copy small{font:600 13px/1.4 var(--sans);letter-spacing:0}
  .standard-reference,.class-reference{padding:22px 16px 28px;border-radius:14px;min-width:0}
  .hero{padding:0 0 18px;margin-bottom:20px}
  .hero h1,.lore-reference .hero h1,.class-title h1{font-size:clamp(32px,9vw,42px);line-height:1.15;overflow-wrap:anywhere}
  .hero p,.class-title p{font-size:17px;line-height:1.6}
  .class-frame{grid-template-columns:minmax(0,1fr);gap:22px;margin-top:20px}
  .class-main,.class-aside,.class-source-grid,.source-class-block{min-width:0}
  .class-aside,.class-source-grid{grid-template-columns:minmax(0,1fr)}
  .class-overview{grid-template-columns:minmax(0,1fr);gap:16px}
  .reference-stats td,.reference-stats th{padding:10px;font-size:14px;line-height:1.45}
  .rule-block p,.class-rule-rich .rule-paragraph,.class-rule-rich .rule-bullet,.rule-option-text,
  .rich-rule-option .rule-option-text p,.rich-rule-option .rule-bullet,.level-extras,
  .details .rules-text,.details .rule-paragraph,.rule-paragraph,.rule-bullet,.lore-prose,
  .side-panel p,.side-panel li,.source-detail-row,.action-card p,.combo-step p,.combo-example p,
  .combat-reminder p,.minor-action-banner span,.condition-body>p,.condition-stack-note p,.rest-summary p{
    font-size:16px;line-height:1.6;
  }
  .rule-block h3,.action-card h4,.combo-step h3{font-size:20px;line-height:1.3}
  .rule-block em,.choice-note,.details .meta,.rest-time,.rest-result span,.resource-strip span,
  .condition-defense-row span,.lore-toggle small,.section-head p{font-size:13px;line-height:1.5}
  .level-outline{padding:10px 0}
  .outline-level{grid-template-columns:78px minmax(0,1fr);gap:10px;align-items:start;padding:6px 0}
  .outline-level span{font-size:14px;line-height:1.5}
  .level-jump{width:100%;min-height:48px;font-size:14px;border-radius:8px}
  .class-progression-wrap{max-width:100%;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
  .class-progression-table{font-size:14px;line-height:1.5}
  .class-progression-table th,.class-progression-table td{padding:10px}
  .selector-group{padding:20px 14px 0;border-radius:14px;min-width:0}
  .filterbar{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}
  .filterbar input[type="search"],.filterbar select{width:100%;min-width:0;border-radius:10px;min-height:48px}
  .choice-row{grid-template-columns:48px minmax(0,1fr) auto;gap:8px;align-items:center;padding:5px 0;border-bottom:1px solid var(--soft)}
  .choice-check-target{width:48px;height:48px}
  .choice-row input{width:24px;height:24px;margin:0}
  .choice-row button.name{min-height:48px;width:100%;font-size:18px;line-height:1.35}
  .choice-row .cost{font-size:12px;line-height:1.5;padding:0}
  .details{margin-left:0;padding:12px}
  .details summary{min-height:48px;padding:12px 0;font-size:15px}
  .rule-option{grid-template-columns:32px minmax(0,1fr);gap:8px;padding:12px 0}
  .rule-option input{width:24px;height:24px;margin-top:3px}
  .rule-option strong{font-size:18px}
  .selection-footer{position:static;padding:14px 0;gap:12px;margin-top:14px}
  .selection-footer>div{display:flex;gap:8px;flex-wrap:wrap;width:100%}
  .selection-footer .button{flex:1 1 auto;min-width:0}
  .selection-footer b{font-size:15px}
  .button,.text-link,.rest-type,.condition-toggle,.school-pill,.account-tabs button,
  .account-primary,.account-secondary,.chat-empty-action,.app-update-bar button,.install-app-action,.install-help-ok{
    min-height:48px;font-size:16px;line-height:1.4;padding:12px 14px;
  }
  .text-link{display:inline-flex;align-items:center}
  .condition-toggle{gap:10px;text-align:left}
  .lore-toggle{min-height:60px;padding:16px 0;gap:12px}
  .lore-toggle strong{font-size:24px;line-height:1.3;overflow-wrap:anywhere}
  .condition-toolbar input,.rest-calculator input{min-height:48px;min-width:0;border-radius:10px}
  .rest-calculator label span{font-size:13px;letter-spacing:0}
  .combat-jumps{position:relative;top:auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;border-radius:12px;margin-bottom:24px}
  .combat-jumps button{min-height:48px;font-size:15px;line-height:1.35;border:1px solid var(--line);border-radius:8px;padding:10px 8px;background:var(--paper)}
  .combat-section{scroll-margin-top:calc(var(--site-header-height,72px) + 16px)}
  .combo-panel,.rest-helper{padding:18px 14px;border-radius:12px}
  .action-card{border-radius:10px;padding:14px}
  .resource-strip{grid-template-columns:repeat(2,minmax(0,1fr))}
  .resource-strip article{padding:14px 12px;border-radius:10px}
  .account-heading p,.account-status,.account-hint,.account-form label{font-size:14px;line-height:1.5}
  .account-form input{min-height:48px}
  .account-heading{padding-right:44px}
  .account-tabs{gap:8px}
  .account-close,.chat-close,.chat-notification-toggle,.calendar-modal-close,.chat-share-picker-close,.install-help-close,.install-app-dismiss{
    width:48px;height:48px;min-width:48px;min-height:48px;flex-basis:48px;
  }
  .chat-preview-remove,.chat-reply-preview button,.chat-share-preview-card button{
    width:48px;height:48px;min-width:48px;min-height:48px;flex-basis:48px;font-size:22px;
  }
  .chat-header{padding-inline:12px;gap:8px}
  .chat-header strong{font-size:20px}
  .chat-header small,.chat-status-line{font-size:13px}
  .chat-empty p,.chat-bubble{font-size:16px;line-height:1.55}
  .chat-message-meta{font-size:12px;gap:8px;flex-wrap:wrap}
  .chat-compose{display:grid;grid-template-columns:repeat(2,48px) minmax(0,1fr) 48px;align-items:end;gap:6px}
  .chat-compose textarea{grid-column:1/-1;grid-row:1;min-height:52px;width:100%}
  .chat-attach-button,.chat-share-button,.chat-compose button{width:48px;height:48px;min-height:48px;min-width:48px}
  .chat-compose .chat-send-button{grid-column:4}
  .chat-message-actions>button,.chat-reaction-picker-wrap>button{min-width:48px;min-height:48px;font-size:16px}
  .chat-reaction-chip{min-height:48px;padding:8px 12px}
  .chat-reaction-picker{display:grid;grid-template-columns:repeat(3,48px);gap:6px;bottom:52px}
  .chat-reaction-picker button{width:48px;height:48px;font-size:22px}
  .chat-reply-quote{min-height:48px;padding:10px}
  .chat-reply-quote strong,.chat-reply-quote span,.chat-reply-preview span,.chat-reply-preview small{font-size:13px}
  .chat-shared-card-copy strong{font-size:16px}
  .chat-shared-card-copy small,.chat-shared-card-copy em,.chat-shared-card-copy>span,.chat-shared-card-open{font-size:12px}
  .chat-mention-menu>button,.chat-share-results>button{min-height:56px;padding:10px;font-size:16px}
  .chat-share-results strong,.chat-mention-menu strong{font-size:15px}
  .chat-share-results small,.chat-mention-menu small{font-size:12px}
  .chat-share-filters{grid-template-columns:minmax(0,1fr);gap:8px}
  .chat-share-filters input,.chat-share-filters select{min-height:48px;width:100%}
  .calendar-month{margin-inline:0;border-radius:12px;overflow:hidden}
  .calendar-month-head{grid-template-columns:48px minmax(0,1fr) 48px;padding:10px 8px}
  .calendar-month-head button{width:48px;height:48px}
  .calendar-month-head h2{font-size:22px;line-height:1.3}
  .calendar-weekdays span{font-size:11px;letter-spacing:0;padding:8px 1px}
  .calendar-day{min-height:88px;padding:5px 2px}
  .calendar-day-number{font-size:13px;width:28px;height:28px}
  .calendar-day-events button{min-height:48px;width:100%;padding:6px 2px}
  .calendar-day-events button span{font-size:10px;line-height:1.3;color:var(--purple)}
  .calendar-session-main p{font-size:16px;line-height:1.55}
  .calendar-session-actions .button{min-height:48px;width:100%}
  .calendar-session-card{padding:14px 12px;border-radius:12px;gap:10px}
  .calendar-session-kicker,.calendar-date-block span{font-size:12px;letter-spacing:0}
  #calendarSessionForm label{font-size:14px}
  #calendarSessionForm input{min-height:48px}
  .calendar-dialog-heading{padding-right:52px}
  .to-top{right:16px;bottom:max(84px,calc(76px + env(safe-area-inset-bottom)));width:48px;height:48px}
  .offline-status-bar{right:84px;font-size:14px}
  .offline-status-bar small{font-size:12px}
  .rule-tooltip p{font-size:16px;line-height:1.55}
}

@media screen and (max-width:350px){
  .site-header{padding-inline:8px;gap:4px}
  .home-landing,.standard-reference,.class-reference{padding-inline:12px}
  .home-intro{grid-template-columns:56px minmax(0,1fr);gap:12px}
  .home-intro>img{width:56px}
  .pdf-download-card{gap:9px;padding-inline:10px}
  .chat-header{gap:4px;padding-inline:8px}
}


/* Campaign lore hierarchy: keep nested bullets readable without wasting mobile width. */
@media screen and (max-width:760px){
  .lore-item[data-share-type="gang"] .lore-prose .lore-bullets-level-1>li,
  .lore-item[data-share-type="character"] .lore-prose .lore-bullets-level-1>li{
    padding-left:25px;
  }
  .lore-item[data-share-type="gang"] .lore-prose .lore-bullets-level-2,
  .lore-item[data-share-type="character"] .lore-prose .lore-bullets-level-2,
  .lore-item[data-share-type="gang"] .lore-prose .lore-bullets-level-3,
  .lore-item[data-share-type="character"] .lore-prose .lore-bullets-level-3{
    padding-left:12px;
  }
  .lore-item[data-share-type="gang"] .lore-prose .lore-bullets-level-2>li,
  .lore-item[data-share-type="character"] .lore-prose .lore-bullets-level-2>li{
    padding-left:25px;
  }
}
/* Keep nested character folders usable on narrow screens. */
@media screen and (max-width:760px){
  .character-groups{gap:10px;margin-top:12px}
  .character-gang-toggle{gap:10px;min-height:84px;padding:8px 12px;flex-wrap:nowrap}
  .character-gang .gang-emblem,
  .lore-item[data-share-type="gang"] .gang-emblem{width:68px;height:68px;flex:0 0 68px}
  .lore-item[data-share-type="gang"]>.lore-toggle{min-height:84px;padding:8px 8px}
  .lore-heading{gap:10px}
  .character-gang-title{font-size:22px}
  .character-gang-count{font-size:12px}
  .character-gang-content{padding:0 12px 12px}
  .character-gang-content .lore-toggle{padding:14px 4px}
  .character-gang-content .lore-toggle strong{font-size:20px}
  .character-gang-content .lore-detail-inner{padding-inline:4px}
}
@media screen and (max-width:350px){
  .character-gang-toggle{min-height:72px;gap:8px;padding-inline:8px}
  .character-gang .gang-emblem,
  .lore-item[data-share-type="gang"] .gang-emblem{width:56px;height:56px;flex-basis:56px}
  .lore-item[data-share-type="gang"]>.lore-toggle{min-height:72px;padding-inline:6px}
}
