/* The established tablet landscape layout is intentionally outside these rules. */
body.regional-screen-layout :is(button,.hkt-return-nav a,.choice){
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  touch-action:manipulation;
}
body.regional-screen-layout .hkt-return-nav{isolation:isolate;}
body.regional-screen-layout .hkt-return-nav img{pointer-events:none;-webkit-user-drag:none;}
/* Portrait pieces pass over the upper HUD. Empty space allows menu actions. */
html body.regional-screen-layout.guide-layout-pilot > .shape-spring-field{
  position:fixed!important;inset:0!important;z-index:200;pointer-events:none;
}
/* In landscape the menu is on the left; use only the area to its right. */
@media(orientation:landscape){
  html body.regional-screen-layout.guide-layout-pilot > .shape-spring-field{
    left:var(--guide-shower-left,214px)!important;
    right:calc(12px + var(--safeR,0px))!important;
    top:var(--safeT,0px)!important;bottom:var(--safeB,0px)!important;
  }
}
body.regional-screen-layout > #overlay{
  position:fixed!important;inset:0!important;width:100%!important;height:100%!important;
  z-index:2147483000!important;isolation:isolate;
}
@media(orientation:portrait){
  html body.regional-screen-layout .hkt-return-nav{
    top:calc(var(--safeT,0px) + 18px)!important;
  }
  html body.regional-screen-layout .hkt-return-nav a{min-height:44px;}
  /* Three sources sit side by side above the map; practice remains under its source. */
  html body.guide-layout-pilot.regional-screen-layout > .cardHead{
    left:calc(12px + var(--safeL,0px));right:calc(12px + var(--safeR,0px));
    top:calc(72px + var(--safeT,0px));width:auto;height:auto;
    margin:0;padding:0;backdrop-filter:none;-webkit-backdrop-filter:none;
    pointer-events:none;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar{
    position:relative!important;inset:auto!important;width:100%!important;
    display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;
    max-height:none!important;
    overflow:visible!important;touch-action:auto;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar > .guideTitle{
    grid-column:1/-1;order:0;min-height:26px;height:auto;padding:0 0 2px;
    font-size:clamp(16px,2.8vw,22px);user-select:none;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar > .knowledgeGroup{
    order:1;align-self:start;padding:4px;border-width:1px;border-radius:11px;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar .practiceGroup{
    margin:5px 0 0;padding-left:0;border:0;gap:5px;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar :is(.viewBtn,.modeBtn){
    height:auto!important;min-height:40px!important;padding:5px 4px;
    font-size:clamp(11px,2.8vw,15px)!important;line-height:1.25;
    white-space:normal!important;justify-content:center;text-align:center;gap:3px;
    pointer-events:auto;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar :is(.viewBtn,.modeBtn)::before{
    display:none;
  }
  html body.guide-layout-pilot.regional-screen-layout .modeBar > .guidePilotQuestion{
    order:2;grid-column:1/-1;width:min(180px,100%);justify-self:center;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotQuestionCard{
    min-height:64px;padding:6px 10px;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotQuestionCard .name{font-size:26px;}
  html body.guide-layout-pilot.regional-screen-layout .guidePilotQuestionCard .yomi{font-size:12px;}
  html body.guide-layout-pilot.regional-screen-layout .modeBar > #allLangToggle{
    position:fixed!important;inset:auto!important;top:calc(18px + var(--safeT,0px))!important;
    right:calc(12px + var(--safeR,0px))!important;min-height:44px;
    margin:0;padding:0 12px;pointer-events:auto;font-size:13px;z-index:110;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList{
    left:calc(12px + var(--safeL,0px));right:calc(12px + var(--safeR,0px));padding-top:0;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:6px;
    max-width:none;margin:0;padding:0 0 4px;scrollbar-gutter:auto;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list .item{
    grid-column:auto!important;grid-row:auto!important;transform:none!important;
    width:100%!important;min-height:52px;padding:5px 6px;border-radius:12px;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list .blockTitle{
    grid-column:1/-1!important;grid-row:auto!important;transform:none!important;
    min-height:22px;margin:0;padding:0 2px;font-size:16px;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list .item :is(.name,.cap){
    font-size:clamp(16px,4vw,22px)!important;white-space:normal!important;
  }
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list .item :is(.yomi,.capYomi){font-size:11px!important;}
  html body.guide-layout-pilot.regional-screen-layout[data-region-id="03chu"] .guidePilotList #list{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
  html body.guide-layout-pilot.regional-screen-layout .shape-spring-field{
    inset:0!important;
  }
  /* A compact, full-width HUD leaves the full width available for map answers. */
  html body.hkt-game.regional-screen-layout:is(.hkt-page-1,.hkt-page-3,.hkt-page-4) .side,
  html body.hkt-game.regional-screen-layout .floatingInfo{
    position:fixed;left:calc(12px + var(--safeL,0px))!important;
    right:calc(12px + var(--safeR,0px))!important;top:calc(72px + var(--safeT,0px))!important;
    width:auto!important;max-width:none!important;height:auto!important;
    max-height:40dvh!important;overflow:visible!important;
    --hkt-panel-width:100%;--floatInfoW:100%;
  }
  html body.hkt-game.regional-screen-layout .side > .card{
    width:100%!important;max-width:none!important;padding:0!important;gap:6px;
    display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    overflow:visible;backdrop-filter:none;-webkit-backdrop-filter:none;background:transparent;box-shadow:none;
  }
  html body.hkt-game.regional-screen-layout .questInfo{grid-column:1;grid-row:1;gap:6px;}
  html body.hkt-game.regional-screen-layout :is(.bBox,.promptBox){width:100%!important;margin:0!important;}
  html body.hkt-game.regional-screen-layout .bBox{grid-column:2;grid-row:1;align-self:stretch;display:flex;}
  html body.hkt-game.regional-screen-layout .promptBox{min-height:76px;padding:8px 6px!important;display:flex;flex-direction:column;justify-content:center;}
  html body.hkt-game.regional-screen-layout :is(.questTitle,.floatTitleBar){min-height:34px!important;padding:6px!important;font-size:14px!important;}
  html body.hkt-game.regional-screen-layout :is(.questStatus,.floatStatus){height:36px!important;padding:6px!important;}
  html body.hkt-game.regional-screen-layout .regionalGameControls{
    grid-column:1/-1;grid-row:2;max-width:none;width:100%;margin:2px 0 0;
  }
  html body.hkt-game.regional-screen-layout .regionalGameHint{grid-column:1/-1;grid-row:3;margin:0;min-height:18px;}
  html body.hkt-game.regional-screen-layout .floatingInfo{
    display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px;
  }
  html body.hkt-game.regional-screen-layout .floatingInfo .floatTopArea{display:none;}
  html body.hkt-game.regional-screen-layout .floatingInfo .floatStatus{width:100%!important;}
  html body.hkt-game.regional-screen-layout.hkt-page-2 .side{
    position:fixed!important;left:calc(12px + var(--safeL,0px))!important;
    right:calc(12px + var(--safeR,0px))!important;bottom:calc(12px + var(--safeB,0px))!important;
    top:auto!important;width:auto!important;height:168px!important;
    max-height:30dvh!important;max-width:none!important;
  }
  html body.hkt-game.regional-screen-layout.hkt-page-2 .side .card{display:flex;height:100%;}
  html body.hkt-game.regional-screen-layout.hkt-page-2 .side .cardBody{padding:0!important;height:100%;}
  html body.hkt-game.regional-screen-layout .choice{padding:7px!important;min-height:48px;}
  html body.hkt-game.regional-screen-layout #showerField{inset:0!important;}
  html body.regional-screen-layout[data-region-id="06kyu"] #svgHost g.prefecture[data-code="47"],
  html body.regional-screen-layout.regional-kyushu #svgHost g.prefecture[data-code="47"]{display:none!important;}
}
/* Short landscape screens keep their side panels, but remove old list offsets. */
@media(orientation:landscape) and (max-height:600px){
  html body.guide-layout-pilot.regional-screen-layout .guidePilotList #list :is(.item,.blockTitle){transform:none!important;}
  html body.regional-screen-layout.regional-kyushu #svgHost g.prefecture[data-code="47"]{display:none!important;}
}

/* Keep geographic rows/columns; give two-column cards the three-column width. */
@media(orientation:portrait){
  html body.regional-screen-layout.guide-layout-pilot[data-region-id]:is([data-practice-mode="view"],[data-practice-mode="name"]) .cardBody #list{
    grid-template-columns:repeat(2,minmax(0,var(--portrait-choice-width,119px)))!important;
    justify-content:center;
  }
  html body.regional-screen-layout.guide-layout-pilot[data-region-id]:is([data-practice-mode="view"],[data-practice-mode="name"]) .cardBody #list .item[data-code]{
    width:var(--portrait-choice-width,119px)!important;min-height:52px;justify-self:center;
  }
  html body.regional-screen-layout.guide-layout-pilot:is([data-region-id="03chu"],[data-region-id="05chs"]):is([data-practice-mode="view"],[data-practice-mode="name"]) .cardBody #list{
    grid-template-columns:repeat(3,minmax(0,var(--portrait-choice-width,119px)))!important;
  }
  html body.regional-screen-layout.guide-layout-pilot[data-region-id="06kyu"]:is([data-practice-mode="view"],[data-practice-mode="name"]) .cardBody #list .item[data-code="46"]{grid-row:4!important;grid-column:1!important;}
  html body.regional-screen-layout.guide-layout-pilot[data-region-id="06kyu"]:is([data-practice-mode="view"],[data-practice-mode="name"]) .cardBody #list .item[data-code="47"]{grid-row:4!important;grid-column:2!important;}
}

@media(orientation:portrait){
  html body.hkt-game.regional-screen-layout > #allLangToggle{
    position:fixed!important;inset:auto!important;top:calc(18px + var(--safeT,0px))!important;
    right:calc(12px + var(--safeR,0px))!important;min-height:44px;margin:0;padding:0 12px;
    z-index:110;font-size:13px;
  }
  html body.hkt-game.regional-screen-layout .regionalGameControls{justify-content:flex-end;}
}
@media(orientation:portrait), (orientation:landscape) and (max-height:600px){
  html body.regional-screen-layout #allLangToggle{
    border:1px solid rgba(223,239,255,.58)!important;border-radius:6px!important;
    background:rgba(23,53,90,.45)!important;color:#f3f8ff!important;
    box-shadow:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
    font-weight:500;letter-spacing:.02em;transform:none!important;
  }
}
@media(orientation:portrait){
  html body.regional-screen-layout #allLangToggle{
    top:calc(22px + var(--safeT,0px))!important;height:36px!important;min-height:36px!important;
    padding:0 10px!important;min-width:72px;box-sizing:border-box;
  }
  html body.regional-screen-layout #allLangToggle::after{content:"";position:absolute;inset:-4px;}
}
@media(orientation:portrait), (orientation:landscape) and (max-height:600px){
  html body.regional-screen-layout #svgHost g.prefecture:not(.is-target){opacity:.45!important;}
}
/* Results own their navigation; background controls do not form a second row. */
html body.regional-screen-layout:has(> #result:not([hidden])) > :is(.hkt-return-nav,#allLangToggle),
html body.regional-screen-layout:has(> #result:not([hidden])) .regionalGameControls{
  visibility:hidden!important;pointer-events:none!important;
}
html body.regional-screen-layout #result .resultBox.is-showering :is(.btnRow,.questResultLanguage,.questPrefectureReward){visibility:hidden!important;}
