/* Shared presentation rules; combat and management use separate surfaces. */
body {
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", "Microsoft YaHei", system-ui, sans-serif;
}

/* Keep the battlefield clear; darkening belongs to individual menus and rails. */
#vignette { background: radial-gradient(ellipse at center, transparent 76%, rgba(2, 4, 12, .22)); }

#startScreen .panel { width: min(720px, 100%); }
#startScreen .subtitle { margin: 12px 0 20px; }
#startScreen .pickrow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
#startScreen .wbtn, #pickScreen .wbtn { min-width: 0; max-width: none; min-height: 62px; }
.weapon-detail { min-height: 1.5em; margin: 10px 0 0; color: #9eb8cc; font-size: 13px; line-height: 1.5; }
.start-links { display: flex; justify-content: center; margin-top: 8px; }
.start-links .btn { border: 0; padding: 8px 14px; font-size: 13px; }
.start-help { margin-top: 8px; text-align: left; }
.start-help summary { cursor: pointer; text-align: center; padding: 10px; color: #9eb8cc; font-size: 13px; }
.start-help .localbox { margin-top: 12px; }
#startScreen:not(.coop) #pickTitle1 { margin-bottom: 8px; }
#startScreen .btnrow { margin-top: 18px; }
#startScreen .btnrow .btn { min-height: 46px; }
#startScreen #tRotate {
  position: static; inset: auto; padding: 0; margin: 0 0 12px;
  width: auto; height: auto; background: none; z-index: auto; display: none;
}
#startScreen #tRotate.show { display: block; }
#startScreen #tRotate .rtitle { font-size: 11px; letter-spacing: 0; color: #9eb8cc; }
#startScreen #tRotate .ricon, #startScreen #tRotate .rsub, #startScreen #tRotate button { display: none; }

.hud-menu {
  position: fixed; top: calc(10px + var(--sat)); right: calc(12px + var(--sar));
  z-index: 15; min-width: 48px; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--panel-line); border-radius: 10px;
  background: rgba(8, 18, 34, .85); color: #cceaff; font: inherit; font-size: 12px; cursor: pointer;
}
.ui-modal #hud, .ui-preparing #hud .bottombar { visibility: hidden; }
.ui-modal #touchui { visibility: hidden; }
.ui-modal .screen.pass { pointer-events: auto; }
.ui-modal .screen.pass > .panel { max-height: none; }
.ui-modal.ui-preparing #cardsScreen,
.ui-modal.ui-preparing #pickScreen,
.ui-modal.ui-preparing #shopScreen,
.ui-modal.ui-preparing #loadoutScreen {
  padding-bottom: calc(110px + var(--sab));
  background: rgba(3, 8, 18, .94);
}
.ui-modal.ui-preparing #cardsScreen > .panel,
.ui-modal.ui-preparing #pickScreen > .panel,
.ui-modal.ui-preparing #shopScreen > .panel,
.ui-modal.ui-preparing #loadoutScreen > .panel {
  margin: 0 auto; max-height: 100%; overflow: auto;
}
#shopScreen .panel { overflow: auto; }
#shopCloseBtn, #pickCloseBtn { margin-top: 12px; }
#interBar { bottom: calc(12px + var(--sab)); gap: 8px; }
#interBar #readyBtn { order: 10; }
#interBar .btn { min-height: 44px; }
#interBar #prepLoadoutBtn { order: 3; }
#interBar #repairBtn { order: 4; }
#interBar #shopBtn { order: 2; }
#interBar #prepToggleBtn { order: 1; }
#interBar .interTimer { order: 0; }
.ui-settings #interBar { display: none; }
#pauseScreen { z-index: 40; }
.ui-preparing #loadoutScreen > .panel > .btnrow { display: none; }
.session-stats { color: #93b3ca; font-size: 12px; line-height: 1.6; }
.loadout-upgrades { color: #9eb8cc; font-size: 12px; line-height: 1.6; margin: 8px 0; }
.prep-details { margin: 14px 0 0; }
.prep-details summary { padding: 12px; color: #9eb8cc; font-size: 12px; cursor: pointer; }
.wicon, .loicon, .skillbtn { font-variant-emoji: text; }

/* Phone and tablet touch HUD: health and resources, without cumulative stats. */
html.is-touch .topbar {
  display: grid; grid-template-columns: minmax(112px, 160px) minmax(150px, 270px);
  align-items: start; justify-content: start; gap: 10px;
  padding: calc(8px + var(--sat)) calc(72px + var(--sar)) 0 calc(10px + var(--sal));
}
html.is-touch .topbar:has(.pcard.p1:not(.hidden)) {
  grid-template-columns: minmax(100px, 140px) minmax(140px, 240px) minmax(100px, 140px);
}
html.is-touch .pcard, html.is-touch .corebox {
  min-width: 0; padding: 6px 8px; border-radius: 9px;
  background: rgba(5, 13, 25, .62); box-shadow: none; backdrop-filter: none;
}
html.is-touch .corebox { order: 0; }
html.is-touch .pcard .pname { font-size: 11px; }
html.is-touch .pcard .ptag,
html.is-touch .pcard .wpn, html.is-touch .corebox #bestWave,
html.is-touch .corebox [data-i18n="hud.localMode"], html.is-touch .corebox .dot,
html.is-touch .corebox .mutrow, html.is-touch .hintbox > span,
html.is-touch .hintbox > .touch-only, html.is-touch #upgList { display: none !important; }
html.is-touch .pcard .prow { font-size: 11px; letter-spacing: 0; }
html.is-touch .pcard .bar { height: 12px; margin-top: 4px; }
html.is-touch .pcard .bar > span { line-height: 12px; font-size: 9px; }
html.is-touch .pcard .prow.small { margin-top: 4px; }
html.is-touch .corelabel { font-size: 12px; letter-spacing: 0; margin: 0; }
html.is-touch .corebox .bar.core { height: 12px; margin-top: 4px; }
html.is-touch .corebox .bar.core > span { font-size: 9px; line-height: 12px; }
html.is-touch .corebox .bar.shield { height: 8px; margin-top: 3px; }
html.is-touch .corebox .bar.shield > span { display: none; }
html.is-touch .corebox .corerow { font-size: 10px; margin-top: 3px; }
html.is-touch #coreWarn { font-size: 11px; }
html.is-touch .bottombar {
  left: 50%; right: auto; bottom: calc(14px + var(--sab)); transform: translateX(-50%);
  padding: 0; width: max-content; max-width: calc(100% - 240px);
}
html.is-touch .hintbox { display: flex !important; padding: 0; background: none; border: 0; }
html.is-touch #buffPill:not(.hidden) {
  display: inline-flex !important; position: absolute; bottom: 52px; left: 50%;
  transform: translateX(-50%); font-size: 10px; white-space: nowrap;
}
html.is-touch:not(.ui-wide) .bottombar { max-width: 98px; }
html.is-touch .skillrow { gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 98px; }
html.is-touch .skillbtn { width: 46px; height: 46px; margin: 0; }
html:not(.ui-skills) .skillrow { display: none; }
html.is-touch #tSet, html.is-touch #tSwap { display: none; }
html.is-touch .tstick { opacity: .42; }
html.is-touch .tstick.active { opacity: .9; }
html.is-touch .tstick .tbase { backdrop-filter: none; background: rgba(6, 16, 30, .18); box-shadow: none; }
html.is-touch .tstick .tlabel { display: none; }
html.is-touch .tdash {
  width: 60px; height: 60px; right: calc(130px + var(--sar)); bottom: calc(100px + var(--sab));
  font-size: 11px; letter-spacing: 0; display: flex; flex-direction: column;
  justify-content: center; align-items: center; box-shadow: 0 2px 10px rgba(75, 224, 138, .2);
}
html.is-touch .tdash small { font-size: 10px; }
html.is-touch .tdash.cooldown { filter: saturate(.3); opacity: .7; }
html.is-touch #tShop { bottom: calc(162px + var(--sab)); right: calc(12px + var(--sar)); min-height: 44px; }
html.is-touch .bossbar { top: calc(92px + var(--sat)); max-width: 50%; }
html.is-touch #banner { top: 32%; font-size: clamp(22px, 4vw, 38px); letter-spacing: 2px; }
html.is-touch #banner small { font-size: 12px; }
html.is-touch #combo { top: 28%; font-size: 20px; }
html.is-touch #hurt { background: radial-gradient(ellipse at center, transparent 65%, rgba(255, 45, 70, .3)); }
html.is-touch #lowhp { background: radial-gradient(ellipse at center, transparent 65%, rgba(220, 25, 55, .2)); }

html.is-touch .screen { padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)); }
html.is-touch { --prep-footer-space: 86px; }
html.is-touch.ui-modal.ui-preparing :is(#cardsScreen, #pickScreen, #shopScreen, #loadoutScreen) {
  padding-bottom: calc(var(--prep-footer-space) + var(--sab));
}
html.is-touch.ui-modal.ui-preparing :is(#cardsScreen, #pickScreen, #shopScreen, #loadoutScreen) > .panel {
  max-height: calc(100dvh - var(--prep-footer-space) - var(--sat) - var(--sab) - 24px);
}
html.is-touch .screen > .panel { padding: 16px; }
html.is-touch #interBar { bottom: calc(8px + var(--sab)); padding: 8px; flex-wrap: wrap; gap: 6px; }
html.is-touch #interBar .btn { min-height: 44px; padding: 7px 10px; font-size: 12px; }
html.is-touch #interBar .cardtimer { width: 50px; }
html.is-touch.ui-preparing #interBar { max-width: calc(100% - 20px); }
html.is-touch.ui-modal.ui-preparing .screen > .panel { max-height: 100%; }
html.is-touch .cardowner { font-size: 12px; letter-spacing: 0; }
html.is-touch #cardsSection .cardowner { margin-top: 8px; }
html.is-touch #readyHint { display: none; }
html.is-touch .ctcard { min-width: 0; }
html.is-touch .ctrow { display: grid; grid-template-columns: 1fr; }
html.is-touch .ctcard {
  max-width: none; display: grid; grid-template-columns: 28px minmax(0, 1fr);
  gap: 4px 8px; padding: 10px; text-align: left;
}
html.is-touch .ctcard .cticon { grid-row: span 2; align-self: center; }
html.is-touch .ctcard b, html.is-touch .ctcard small { grid-column: 2; text-align: left; }
.shopgroup { grid-column: 1 / -1; margin: 12px 0 4px; color: #a9dfff; font-size: 14px; }
.shopgroup:first-child { margin-top: 0; }
@media (min-width: 700px) {
  .shoprow, .online-prep [data-ui="shopRow"] {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  }
}
html.is-touch #pickScreen .pickrow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
html.is-touch #pickScreen .wbtn { min-height: 52px; }
html.is-touch #pickScreen .wbtn .wicon { display: block; }
html.is-touch #pickScreen .weapon-detail { font-size: 12px; }

@media (max-width: 600px) {
  #startScreen .pickrow, html.is-touch #pickScreen .pickrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #startScreen .pickrow > :last-child:nth-child(odd), html.is-touch #pickScreen .pickrow > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  #startScreen .title { font-size: clamp(21px, 6vw, 30px); }
  #startScreen .subtitle { font-size: 12px; margin: 10px 0 14px; }
  #startScreen .wbtn { min-height: 48px; padding: 5px; gap: 2px; }
  #startScreen .wbtn .wicon { font-size: 16px; }
  #startScreen .wbtn b { font-size: 11px; letter-spacing: 0; }
  #startScreen .weapon-detail { font-size: 12px; }
  #startScreen > .panel > .btnrow { position: sticky; bottom: 0; padding: 8px 0; background: rgba(6, 12, 26, .96); }
  #startScreen .btnrow .btn { padding: 9px 14px; font-size: 13px; }
  html.is-touch .topbar { gap: 6px; grid-template-columns: minmax(90px, 1fr) minmax(120px, 1.3fr); }
  html.is-touch .topbar:has(.pcard.p1:not(.hidden)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.is-touch .topbar:has(.pcard.p1:not(.hidden)) .corebox { grid-row: 1; grid-column: 1 / -1; }
  html.is-touch .bottombar { bottom: calc(10px + var(--sab)); max-width: calc(100% - 40px); }
  html.is-touch .tdash { right: calc(18px + var(--sar)); bottom: calc(194px + var(--sab)); }
  html.is-touch #interBar { width: calc(100% - 20px); }
  html.is-touch #interBar .interTimer { flex: 1 1 100%; justify-content: center; }
  html.is-touch #interBar .cardtimer { width: 120px; }
  html.is-touch #interBar #readyBtn { flex: 1 1 100%; }
  html.is-touch #interBar .btn { flex: 1 1 20%; font-size: 11px; padding: 6px; }
  html.is-touch { --prep-footer-space: 174px; }
  html.is-touch .cardtitle { font-size: 16px; letter-spacing: .08em; line-height: 1.4; white-space: normal; }
  html.is-touch .cardwrap { flex-direction: column; align-items: stretch; margin-top: 12px; }
  html.is-touch .card {
    min-width: 0; width: 100%; min-height: 86px; padding: 10px;
    display: grid; grid-template-columns: 36px 1fr; gap: 3px 8px; text-align: left;
  }
  html.is-touch .card .icon { grid-row: 1 / 4; align-self: center; justify-self: center; }
  html.is-touch .card .cname, html.is-touch .card .cdesc, html.is-touch .card .cstack { grid-column: 2; }
  html.is-touch .shoprow { grid-template-columns: 1fr; }
  html.is-touch .bossbar { top: calc(108px + var(--sat)); max-width: 65%; }
}

@media (max-height: 500px) and (min-width: 601px) {
  #startScreen .panel { width: min(900px, 100%); padding: 14px 20px; }
  #startScreen .title { font-size: 27px; margin: 0; }
  #startScreen .subtitle { margin: 6px 0 12px; font-size: 12px; }
  #startScreen .pickrow { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  #startScreen .wbtn { min-height: 58px; padding: 6px 3px; }
  #startScreen .wbtn b { font-size: 11px; letter-spacing: 0; }
  #startScreen .weapon-detail { font-size: 12px; margin: 6px 0 0; }
  #startScreen .btnrow { margin: 10px 0 0; }
  #startScreen .start-links { margin: 0; }
  .start-help { margin: 0; }
  html.is-touch .bossbar { top: calc(86px + var(--sat)); }
  html.is-touch .screen .title { font-size: 22px; }
  html.is-touch .screen .cardtitle { font-size: 18px; margin: 0 0 10px; }
  html.is-touch .cardwrap { margin-top: 10px; }
  html.is-touch .card { min-height: 105px; padding: 8px; gap: 3px; }
  html.is-touch .card .icon { font-size: 20px; }
  html.is-touch .card .cname { font-size: 13px; }
  html.is-touch .prep-details { margin-top: 6px; }
  html.is-touch .prep-details summary { padding: 8px; }
  html.is-touch #prepButtons { margin-top: 8px; }
  html.is-touch #interBar .interTimer { gap: 5px; }
  html.is-touch #interBar .cardtimer { display: none; }
}

/* Wide phones and desktop screens share the same two HUD rails. */
html.ui-wide .topbar, html.ui-wide.is-touch .topbar {
  display: block; position: static; padding: 0;
}
html.ui-wide .topbar > .pcard, html.ui-wide .topbar > .corebox {
  position: absolute; width: var(--hud-rail); min-width: 0;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(5, 13, 25, .78); backdrop-filter: none; box-shadow: none;
}
html.ui-wide .pcard.p0 { top: calc(12px + var(--sat)); left: calc(12px + var(--sal)); }
html.ui-wide .pcard.p1 { top: calc(var(--p0-bottom, 90px) + 8px); left: calc(12px + var(--sal)); }
html.ui-wide .topbar > .corebox { top: calc(12px + var(--sat)); right: calc(12px + var(--sar)); }
html.ui-wide .pcard .prow { font-size: 12px; letter-spacing: 0; }
html.ui-wide .pcard .pname { font-size: 12px; }
html.ui-wide .pcard .ptag,
html.ui-wide #bestWave, html.ui-wide .corebox .dot,
html.ui-wide .corebox [data-i18n="hud.localMode"], html.ui-wide .corebox .mutrow,
html.ui-wide #upgList, html.ui-wide #hudHint, html.ui-wide .hintbox > .touch-only { display: none !important; }
html.ui-wide .pcard .bar { height: 14px; margin-top: 5px; }
html.ui-wide .pcard .bar > span { font-size: 10px; line-height: 14px; }
html.ui-wide .corelabel { font-size: 13px; letter-spacing: 0; margin: 0; }
html.ui-wide .corebox .bar.core { height: 14px; margin-top: 5px; }
html.ui-wide .corebox .bar.core > span { font-size: 10px; line-height: 14px; }
html.ui-wide .corebox .bar.shield { height: 9px; margin-top: 4px; }
html.ui-wide .corebox .bar.shield > span { display: none; }
html.ui-wide .corebox .corerow { font-size: 11px; margin-top: 5px; justify-content: center; }
html.ui-wide #coreWarn { font-size: 11px; letter-spacing: 0; }
html.ui-wide .hud-menu {
  top: calc(var(--player-bottom, 100px) + 8px); left: calc(12px + var(--sal)); right: auto;
}
html.ui-wide .bossbar {
  top: calc(var(--core-bottom, 100px) + 8px); right: calc(12px + var(--sar)); left: auto;
  transform: none; width: var(--hud-rail); max-width: none; padding: 6px 8px;
}
html.ui-wide .bossbar .bosstop { flex-wrap: wrap; gap: 2px; }
html.ui-wide .bossbar .bossname { font-size: 12px; letter-spacing: 0; }
html.ui-wide .bossbar .bosssub { font-size: 9px; }
html.ui-wide .bottombar {
  top: calc(var(--status-bottom, 100px) + 8px); bottom: auto;
  right: calc(12px + var(--sar)); left: auto; transform: none;
  width: var(--hud-rail); max-width: none; padding: 0;
}
html.ui-wide .hintbox {
  display: flex !important; flex-direction: column; align-items: center; gap: 6px;
  width: 100%; min-width: 0; padding: 0; border: 0; background: none;
}
html.ui-wide .skillrow { flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 94px; }
html.ui-wide .skillbtn { width: 44px; height: 44px; margin: 0; }
html.ui-wide #buffPill:not(.hidden), html.ui-wide.is-touch #buffPill:not(.hidden) {
  position: static; transform: none; font-size: 10px; white-space: normal; text-align: center;
}
html.ui-wide #toasts { left: calc(12px + var(--sal)); right: auto; top: calc(var(--player-bottom, 100px) + 62px); }
html.ui-wide .toast { max-width: var(--hud-rail); font-size: 11px; }
html.ui-wide .basehint { left: calc(12px + var(--sal)); right: auto; transform: none; width: var(--hud-rail); bottom: calc(16px + var(--sab)); }
html.ui-wide.is-touch .tdash {
  right: calc(var(--hud-rail) / 2 - 18px + var(--sar)); bottom: calc(138px + var(--sab));
}
html.ui-wide.is-touch .bottombar {
  top: calc(var(--player-bottom, 100px) + 60px); left: calc(12px + var(--sal)); right: auto;
}
html.ui-wide.is-touch #buffPill:not(.hidden) {
  position: fixed; top: calc(var(--status-bottom, 100px) + 8px); bottom: auto;
  right: calc(12px + var(--sar)); left: auto; width: var(--hud-rail);
}
html.ui-wide.is-touch #toasts {
  top: auto; bottom: calc(6px + var(--sab)); left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 2 * var(--hud-rail) - 48px);
}
html.ui-wide.is-touch .toast { max-width: 100%; padding: 4px 7px; font-size: 10px; }
html.ui-wide.is-touch .toast:not(:last-child) { display: none; }
/* Preserve the shared skill strip until co-op gets its own personal menus. */
html.ui-wide.is-touch:has(.pcard.p1:not(.hidden)) .bottombar {
  top: auto; bottom: calc(8px + var(--sab)); left: 50%; right: auto;
  transform: translateX(-50%); width: max-content;
}
html.ui-wide.is-touch:has(.pcard.p1:not(.hidden)) .skillrow { max-width: none; flex-wrap: nowrap; }
html.ui-wide.is-touch #tShop {
  left: calc(var(--hud-rail) - 72px + var(--sal)); right: auto;
  top: calc(var(--player-bottom, 100px) + 8px); bottom: auto;
  height: 44px; min-height: 44px; font-size: 11px;
}

/* Short landscape viewports (including browser bars and safe areas). */
html.ui-wide.is-touch.ui-compact .topbar > .pcard { padding: 5px 8px; }
html.ui-wide.is-touch.ui-compact .pcard .prow { line-height: 1.1; }
html.ui-wide.is-touch.ui-compact .pcard .pname { font-size: 10px; }
html.ui-wide.is-touch.ui-compact .pcard .prow.small { margin-top: 3px; font-size: 10px; }
html.ui-wide.is-touch.ui-compact .pcard .bar { height: 10px; margin-top: 3px; }
html.ui-wide.is-touch.ui-compact .pcard .bar > span { font-size: 9px; line-height: 10px; }
html.ui-wide.is-touch.ui-compact .hud-menu, html.ui-wide.is-touch.ui-compact #tShop { height: 40px; min-height: 40px; }
html.ui-wide.is-touch.ui-compact .bottombar { top: calc(var(--player-bottom, 70px) + 56px); }
html.ui-wide.is-touch.ui-compact .skillrow { max-width: 84px; gap: 4px; }
html.ui-wide.is-touch.ui-compact .skillbtn { width: 40px; height: 40px; }
html.ui-wide.is-touch.ui-compact .tstick { width: 100px; height: 100px; margin: -50px 0 0 -50px; }
html.ui-wide.is-touch.ui-compact .tdash { width: 52px; height: 52px; bottom: calc(120px + var(--sab)); right: calc(var(--hud-rail) / 2 - 14px + var(--sar)); }
