@import url('./panel-layout.css');
@import url('./combat-layout.css');

/* The opening roster scrolls within the existing partner screen. */
#ui .screen.sp.sp-expanded {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
  justify-content: flex-start;
  gap: 14px;
  padding: 20px 24px 64px;
}
#ui .sp-expanded .sp-head,
#ui .sp-expanded .sp-foot { flex: 0 0 auto; width: 100%; }
#ui .sp-expanded .sp-head h1 { font-size: clamp(30px, 4vw, 48px); }
#ui .sp-expanded .sp-head p { max-width: 820px; }
#ui .sp-expanded .sp-row {
  flex: 1 1 auto;
  min-height: 0;
  width: min(1180px, 100%);
  max-width: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 20px;
  padding: 12px;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding: 12px;
}
#ui .sp-expanded .sp-card { min-width: 0; transform: none; }
#ui .sp-expanded .sp-card.on { transform: none; }
#ui .sp-expanded .sp-show { min-height: 180px; height: 180px; }
#ui .sp-expanded .sp-show .ls-plate { max-width: calc(100% - 24px); box-sizing: border-box; }
#ui .sp-expanded .sp-show .ls-plate h1 {
  font-size: clamp(20px, 2vw, 26px);
  white-space: normal;
  overflow-wrap: anywhere;
}
#ui .sp-expanded .sp-info { display: flex; min-width: 0; gap: 8px; padding: 12px; }
#ui .sp-expanded .sp-pas,
#ui .sp-expanded small,
#ui .sp-expanded .sp-foot,
#ui .sp-expanded .sp-foot .keys { font-size: 14px; }
#ui .sp-expanded .sp-move { min-width: 0; padding: 8px; }
#ui .sp-expanded .sp-move > span { min-width: 0; }
#ui .sp-expanded .sp-move b { white-space: normal; overflow-wrap: anywhere; }
#ui .sp-expanded .sp-go { min-width: 0; max-width: 100%; white-space: normal; }
#ui .rg-tx .pb-map-unlock {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
@media (max-width: 960px) {
  #ui .sp-expanded .sp-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #ui .screen.sp.sp-expanded { padding: 14px 12px 58px; gap: 10px; }
  #ui .sp-expanded .sp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 10px; }
  #ui .sp-expanded .sp-show { min-height: 150px; height: 150px; }
  #ui .sp-expanded .sp-show .ls-plate { padding: 6px 8px 8px; }
  #ui .sp-expanded .sp-show .ls-plate h1 { font-size: clamp(14px, 4.1vw, 16px); line-height: 1.2; overflow-wrap: normal; }
  #ui .sp-expanded .sp-show .ls-plate small { letter-spacing: 0; line-height: 1.2; }
  #ui .sp-expanded .sp-show .ls-plate .row { flex-wrap: wrap; gap: 4px !important; }
  #ui .sp-expanded .sp-show .ls-plate .chip { flex-shrink: 0; white-space: nowrap; }
  #ui .sp-expanded .sp-head h1 { font-size: 30px; }
  #ui .sp-expanded .sp-head p { font-size: 14px; }
  #ui .sp-expanded .sp-info { padding: 10px; }
  #ui .sp-expanded .sp-move { flex-wrap: wrap; gap: 5px; }
  #ui .sp-expanded .sp-foot .keys { flex-wrap: wrap; justify-content: center; }
  #ui .sp-expanded .sp-go { font-size: clamp(16px, 4.8vw, 20px); gap: 10px; padding: 12px 18px; }
  #ui .sp-expanded .sp-go .btn-ball { flex-shrink: 0; width: 24px; height: 24px; }
  #ui .sp-expanded .sp-go kbd { display: none; }
}
@media (max-width: 359px) {
  #ui .sp-expanded .sp-row { grid-template-columns: minmax(0, 1fr); }
  #ui .sp-expanded .sp-show .ls-plate h1 { font-size: 20px; }
}

#local-save-tools { position: fixed; z-index: 100000; right: 18px; bottom: 14px; font: 14px/1.5 system-ui, sans-serif; color: #f9f7ff; }
#local-save-tools * { box-sizing: border-box; font-size: 14px; }
.auth-tabs button:not(:first-child), .auth-perks > div:last-child, .trainer > .btn.blue, .trainer > .tr-mail, .trainer > .tr-friends, .pz-bug { display: none !important; }
.pf-trophy-sum, .pf-cols > .pf-box:nth-child(2) { display: none !important; }
.pf-cols { grid-template-columns: minmax(0, 1fr) !important; }
.mm-local-summary { position: absolute; right: 6vw; top: 25%; width: min(320px, 30vw); padding: 24px 28px; background: #fffdf4e8; color: #302744; border: 2px solid #ffffff; border-radius: 22px; box-shadow: 0 8px 32px #221a4520; }
.mm-local-summary small { font-size: 14px; letter-spacing: .07em; color: #74617e; }
.mm-local-summary h2 { font-size: 27px; margin: 14px 0 24px; line-height: 1.3; }
.local-summary-stat { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid #30274422; padding: 12px 0; gap: 12px; }
.local-summary-stat b { font-size: 30px; }
.local-summary-stat span, .mm-local-summary p { font-size: 14px; }
.mm-local-summary p { color: #74617e; margin: 12px 0 0; }
.local-save-open { min-height: 42px; padding: 9px 17px; background: #272237e8; color: #f9f7ff; border: 1px solid #b4a4da80; border-radius: 12px; cursor: pointer; box-shadow: 0 3px 15px #0003; }
.local-save-open:hover { background: #413656; }
.local-save-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid #655478; border-radius: 22px; padding: 30px; color: #f9f7ff; background: #211b30; box-shadow: 0 20px 80px #0008; }
.local-save-dialog::backdrop { background: #090711b8; backdrop-filter: blur(5px); }
.local-save-dialog h2 { margin: 12px 0; font-size: 24px !important; line-height: 1.3; }
.local-save-dialog p { color: #d1c7df; margin: 14px 0; }
.local-kicker { letter-spacing: .08em; color: #c4acef !important; }
.local-close { position: absolute; right: 14px; top: 12px; border: 0; color: #eee5ff; background: transparent; font-size: 28px !important; cursor: pointer; width: 40px; height: 40px; }
.local-save-status { padding: 15px; background: #ffffff09; border: 1px solid #ffffff16; border-radius: 12px; margin: 20px 0; overflow-wrap: anywhere; }
.local-actions { display: flex; gap: 12px; }
.local-actions button { flex: 1; min-height: 46px; border: 0; border-radius: 10px; color: #251b38; background: #c8a9f4; font-weight: 700; cursor: pointer; }
.local-actions button + button { background: #41334f; color: #f6edff; border: 1px solid #8d709e; }
.local-save-message { min-height: 21px; color: #f2cc8c !important; }
.local-reset { color: #e4b5c2; background: none; border: 0; padding: 8px 0; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.local-credit { border-top: 1px solid #ffffff18; padding-top: 16px; }
.local-save-toast { position: fixed; bottom: 70px; right: 18px; max-width: min(440px, calc(100vw - 36px)); padding: 15px; color: #fff; background: #752d3c; border: 1px solid #ffc0c6; border-radius: 12px; }
@media (max-width: 600px) { #local-save-tools { right: 10px; bottom: 8px; } .local-save-open { padding: 7px 12px; max-width: calc(50vw - 16px); white-space: normal; } .local-save-dialog { padding: 26px 20px; } }
@media (max-width: 900px) { .mm-local-summary { display: none; } }

/* Auxiliary menu tools must not cover native panel actions. */
body:has(#ui > .screen:not(.mm):not(.auth), #ui .modal) #local-save-tools,
body:has(#ui > .screen:not(.mm):not(.auth), #ui .modal) #game-info { display: none; }

/* Portrait menus remain usable on touch devices; live combat keeps its hint. */
html.touch body:has(#ui > .screen) > .rotate-hint,
html.touch body:has(#ui .modal) > .rotate-hint { display: none; }

/* Keep the quest board readable when the backpack cannot fit beside it. */
#ui .tk-ball small {
  font-size: 14px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
@media (max-width: 1250px) {
  #ui .tk-main {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    padding-bottom: 64px;
    zoom: 1;
  }
  #ui .tk-bagpanel { position: static; min-width: 0; }
}
@media (max-width: 900px) {
  #ui .tk-cols { grid-template-columns: minmax(0, 1fr); }
  #ui .tk-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  #ui .tk-head-tx { flex: 1 1 220px; min-width: 0; }
  #ui .tk-head-side {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
  }
}
@media (max-width: 600px) {
  #ui .screen:has(> .tk-main) > .scr-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }
  #ui .screen:has(> .tk-main) > .scr-head > .back-btn {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }
  #ui .screen:has(> .tk-main) > .scr-head > .currency {
    grid-column: 2;
    grid-row: 1;
  }
  #ui .screen:has(> .tk-main) > .scr-head > .grow { display: none; }
  #ui .screen:has(> .tk-main) > .scr-head > .scr-title {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    flex-wrap: wrap;
    gap: 4px 12px;
  }
  #ui .screen:has(> .tk-main) .scr-title h1 { flex-shrink: 0; }
  #ui .screen:has(> .tk-main) .scr-title > span { flex: 1 1 180px; }
  #ui .tk-col .tk-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
    column-gap: 12px;
    row-gap: 10px;
    padding: 16px 6px;
  }
  #ui .tk-ball { width: 54px; }
  #ui .tk-body { min-width: 0; }
  #ui .tk-side {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
}
