.navigation-open {
  display: block;
  min-height: 100dvh;
  height: auto;
  overflow: auto;
  background: radial-gradient(ellipse at 50% 0%, #275044 0%, #172f2a 46%, #0c201d 100%);
}
body.navigation-open > main,
.trix-navigation [hidden],
.trix-navigation[hidden],
.trix-catalog [hidden],
.trix-game-nav [hidden] { display: none !important; }
.trix-navigation { color: #fff1ce; padding: max(18px, env(safe-area-inset-top)) clamp(14px, 4vw, 42px) 26px; }
.trix-title {
  min-height: calc(100dvh - 48px);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(34px, 11vh, 110px);
}
.trix-title h1 {
  margin: 0;
  font-size: clamp(76px, 17vw, 180px);
  line-height: 1;
  letter-spacing: -.08em;
  font-family: Georgia, serif;
  color: #fff1cf;
  text-shadow: 4px 6px #091713;
}
.trix-title h1 span { color: #efbc6a; }
.trix-title-actions { width: min(100%, 320px); display: grid; gap: 12px; }
.trix-navigation button, .trix-navigation a { min-height: 44px; }
.trix-title-actions button, .trix-title-actions a {
  display: grid;
  place-items: center;
  padding: 13px;
  font-size: 19px;
  font-weight: 800;
}
.trix-title-actions a, .trix-profile a {
  border: 1px solid #c3a16a;
  border-radius: 8px;
  color: #fff1ce;
  text-decoration: none;
}
.trix-menu { max-width: 780px; margin: 0 auto; }
.trix-menu > header {
  display: flex; align-items: center; gap: 12px; padding: 0; margin: 0 0 18px;
  border: 0; background: transparent; box-shadow: none;
}
.trix-menu h1 { margin: 0; color: #fff1ce; font-size: clamp(19px, 5vw, 32px); }
.trix-menu-layout { display: grid; grid-template-columns: minmax(145px, 1fr) minmax(0, 2.5fr); gap: 14px; align-items: start; }
.trix-profile {
  display: grid; grid-template-columns: minmax(0,1fr); gap: 12px;
  min-width: 0; padding: 14px; border: 1px solid #806c4d;
  background: #112723; border-radius: 10px; overflow-wrap: anywhere;
}
.trix-profile-summary {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.trix-profile-details { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.trix-profile strong { font-size: 19px; line-height: 1.3; }
.trix-profile-details span { font-size: 13px; line-height: 1.35; }
.trix-profile-actions {
  display: grid; grid-template-columns: minmax(0,1fr); gap: 8px;
  width: 100%; min-width: 0;
}
.trix-profile-actions > button, .trix-profile-actions > a {
  display: grid; place-items: center; width: 100%; min-width: 0;
  min-height: 44px; box-sizing: border-box; margin: 0;
  padding: 10px 12px; font-size: 14px; font-weight: 700;
  line-height: 1.4; text-align: center;
  border: 1px solid #c3a16a; border-radius: 8px;
  color: #fff1ce; background: #263c36; text-decoration: none;
}
.trix-title-actions #titleLogout {
  border: 1px solid #c3a16a;
  border-radius: 8px;
  color: #fff1ce;
  background: #263c36;
  padding: 9px 12px;
}
.trix-navigation .trix-logout-error {
  margin: 2px 0; width: 100%; min-width: 0;
  color: #ffbcb8; font-size: 13px; line-height: 1.45;
}
.trix-profile .rank-icon { width: 40px; height: 40px; }
.trix-profile #menuRankIcon:empty, .trix-profile span:empty { display: none; }
.trix-menu-modes { display: grid; gap: 9px; }
.trix-menu-modes button {
  display: grid; gap: 3px; justify-items: start; padding: 10px 14px;
  min-height: 58px; text-align: left;
}
.trix-menu-modes strong { font-size: 18px; }
.trix-menu-modes small { opacity: .86; font-size: 12px; }
.trix-menu-help { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.trix-menu-help button { padding-inline: 11px; font-size: 13px; }
.trix-game-nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
#modeSelect, #adventureMenu { display: none !important; }
body.friend-lobby-view > main {
  display: block; width: min(100%, 1120px); height: auto; max-height: none;
  margin: auto; padding: clamp(16px, 4vw, 48px); overflow: visible;
}
body.friend-lobby-view main > header, body.friend-lobby-view main > footer,
body.friend-lobby-view .arena, body.friend-lobby-view .roster-panel, body.friend-lobby-view .history,
body.friend-lobby-view #status, body.friend-lobby-view #instruction, body.friend-lobby-view #setupControlToggle,
body.friend-lobby-view #actions, body.friend-lobby-view #reset, body.friend-lobby-view #modeLabel { display: none !important; }
body.friend-lobby-view .topline { margin: 0 0 22px; }
body.friend-lobby-view #heading { font-size: clamp(22px, 5vw, 38px); }
body.friend-lobby-view #gameMenuBack { min-height: 44px; }
body.friend-lobby-view .workspace,
body.friend-lobby-view .workspace > aside { display: block; width: 100%; height: auto; max-height: none; overflow: visible; }
body.friend-lobby-view .workspace .control,
body.friend-lobby-view .control #onlinePanel {
  height: auto; max-height: none; overflow: visible; background: transparent; border: 0;
  box-shadow: none; padding: 0; margin: 0;
}
.friend-lobby-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.friend-lobby-card {
  display: grid; align-content: start; grid-template-rows: auto auto auto auto 1fr auto;
  gap: 9px; background: #fff8e5; color: #26392f; border: 1px solid #baaa84;
  border-radius: 15px; padding: clamp(16px, 3vw, 28px);
}
.friend-lobby-card h2 { margin: 0; border: 0; padding: 0; font-size: 23px; }
#onlinePanel .friend-lobby-card p { color: #40564a; font-size: 15px; margin: 0 0 4px; }
.friend-lobby-card label { font-weight: 800; }
.friend-lobby-card small { color: #4a5d51; font-size: 12px; }
#onlinePanel .friend-lobby-card input {
  width: 100%; margin: 0; min-height: 48px; padding: 10px 12px;
  border: 1px solid #627a6d; border-radius: 8px; font-size: 16px;
  color: #172d23; background: #fffdf5;
}
#onlinePanel .friend-lobby-card button { grid-row: 6; min-height: 48px; font-size: 16px; margin-top: 3px; }
.friend-lobby-view #onlinePanel .matches-title,
.friend-lobby-view #onlinePanel .friend-lobby-empty { margin: 16px 0 8px; color: #fff1ce; }
.friend-lobby-view #onlinePanel .match-row { background: #fff8e5; color: #26392f; padding: 10px; }
.friend-lobby-view #onlinePanel .match-row button { min-height: 44px; }
@media (max-width: 620px) {
  .friend-lobby-options { grid-template-columns: 1fr; gap: 12px; }
}
.trix-catalog {
  width: min(720px, calc(100vw - 22px)); max-height: 89dvh; overflow: auto;
  padding: clamp(12px, 3vw, 24px); color: #fff1ce; background: #162f29;
  border: 1px solid #a88958; border-radius: 12px; overscroll-behavior: contain;
}
.trix-catalog > header, .trix-catalog nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trix-catalog > header { justify-content: space-between; padding: 0; margin-bottom: 12px; background: transparent; }
.trix-catalog h2 { margin: 0; color: inherit; }
.trix-catalog button { min-height: 42px; }
.trix-catalog [aria-pressed="true"] { background: #f5d694; color: #222722; }
.trix-catalog-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(106px,1fr)); gap: 8px; }
.trix-catalog-grid button, .trix-catalog-locked {
  min-height: 100px; display: grid; gap: 4px; place-items: center;
  text-align: center; font-size: 13px; padding: 7px; overflow-wrap: anywhere;
}
.trix-catalog-grid img { width: 68px; height: 64px; object-fit: contain; }
.trix-catalog-locked { color: #e5d7bd; border: 1px dashed #879d8c; border-radius: 8px; }
.trix-catalog-locked span { font-size: 29px; line-height: 1; }
#catalogStatus:empty { display: none; }
#catalogDetail > img { width: min(180px, 50%); height: 128px; object-fit: contain; object-position: left; }
#catalogDetail > h3 { margin-bottom: 8px; }
#catalogDetail > h3 small { margin-left: 6px; }
#catalogDetail { margin-top: 12px; }
@media (max-width: 480px) {
  .trix-menu-layout { grid-template-columns: minmax(0,1fr); gap: 9px; }
  .trix-profile { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; padding: 12px; }
  .trix-profile strong { font-size: 17px; }
  .trix-profile .rank-icon { width: 32px; height: 32px; }
  .trix-profile-actions { grid-template-columns: minmax(0,1fr); }
}

.trix-catalog .ability-copy,
.trix-catalog .ability-copy.ult-description {
  color: #fff1ce !important;
  font-size: 15px;
  line-height: 1.65;
}
.trix-catalog .ability-copy b { color: #ffdc92; }
#patchNotes { background: #fffaec; color: #25362d; }
#patchNotes .patch-heading { background: #fffaec; }
#patchNotes .patch-heading h2,
#patchNotes .patch-entry h3,
#patchNotes .patch-old summary { color: #674700; }
#patchNotes p, #patchNotes li { color: #25362d; }

#tutorialDialog {
  --tutorial-paper: #fff8e5;
  width: min(1050px, calc(100% - 24px)); max-width: none;
  max-height: calc(100dvh - 24px); padding: clamp(14px, 3vw, 26px);
  background: var(--tutorial-paper); color: #20352b; border: 1px solid #9a8356; box-shadow: none;
}
#tutorialDialog .tutorial-head { background: transparent; margin: 0; }
#tutorialDialog .tutorial-head > span, #tutorialDialog .tutorial-copy,
#tutorialDialog .tutorial-card span, #tutorialDialog .tutorial-tip { color: #365245; font-size: 15px; }
#tutorialDialog .tutorial-head button { min-height: 44px; min-width: 44px; }
#tutorialDialog .tutorial-steps i { background: #d6dece; }
#tutorialDialog .tutorial-steps i.active { background: #997020; }
#tutorialDialog .tutorial-task, #tutorialDialog .tutorial-feedback {
  background: #e2efdf; color: #203e31; border-color: #a8bfa7; font-size: 15px;
}
#tutorialDialog .tutorial-practice { border-color: #a2b4a0; background: #eaf0df; }
#tutorialDialog .tutorial-board { max-width: none; margin: 0; min-width: 0; }
#tutorialDialog .tutorial-board > strong { color: #244f3d; }
#tutorialDialog .tutorial-board:has(.enemy) > strong { color: #803942; }
#tutorialDialog .tutorial-row { margin: 0; grid-template-columns: 30px repeat(3,minmax(0,1fr)); }
#tutorialDialog .tutorial-row > span, #tutorialDialog .tutorial-front { color: #486055; }
#tutorialDialog .tutorial-cell {
  min-height: 54px; height: auto; justify-content: center;
  background: #fdfbee; color: #20352b; border-color: #9fae99; box-shadow: none;
}
#tutorialDialog .tutorial-cell img { opacity: .32; }
#tutorialDialog .tutorial-cell small { color: #283e33; }
#tutorialDialog .tutorial-target { border-color: #865e12 !important; background: #fff0bd; }
#tutorialDialog .tutorial-cell.selected { background: #f8dc87; }
#tutorialDialog .tutorial-rear { color: #713627; z-index: 2; font-size: 10px; }
#tutorialDialog .tutorial-confirm { z-index: 2; }
#tutorialDialog .tutorial-roster button { min-height: 44px; }
#tutorialDialog .tutorial-summary p { border-color: #a8bfa7; }
#tutorialDialog .tutorial-summary b { color: #624514; }
#tutorialDialog .tutorial-nav { bottom: -14px; background: var(--tutorial-paper); border-color: #a8bfa7; z-index: 3; }
#tutorialDialog .tutorial-nav button { min-height: 44px; }
#rules { color: #20352b; padding: clamp(14px, 3vw, 24px); }
#rules h2, #rules h3, #rules summary { color: #5e430d; }
#rules p, #rules li { color: #263b30; }
@media (min-width: 760px) {
  #tutorialDialog .tutorial-practice:has(.tutorial-front) {
    display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 12px;
  }
}
@media (max-width: 620px) {
  #tutorialDialog {
    inset: 0; width: 100%; height: 100dvh; max-height: 100dvh;
    margin: 0; border: 0; border-radius: 0;
  }
}
.extra-catalog-heading,.extra-catalog-note{grid-column:1/-1;margin:0}
.extra-catalog-heading{border-top:1px solid #879d8c;padding-top:1rem;margin-top:1rem}
.extra-catalog-note{padding-bottom:.4rem}
#characterCatalog .catalog-tabs{display:flex;gap:.5rem;margin:.75rem 0}
#characterCatalog .catalog-tabs button{flex:1}
#characterCatalog #catalogDetail :is(h3,small,p){color:#fff2d4}
#characterCatalog #catalogDetail .ability-copy{background:#10251f;padding:.65rem .85rem;border-radius:6px}
#characterCatalog .trix-catalog-grid button{background:#25433b;color:#fff6df}
#characterCatalog .trix-catalog-grid button strong{color:inherit}

.setup-extra-heading{grid-column:1/-1;margin:.75rem 0 .25rem;padding-top:.75rem;border-top:1px solid currentColor}

/* A compact menu-volume control that stays usable on narrow phones. */
.trix-menu-volume { display: flex; align-items: center; flex: 1 1 185px; gap: 8px; min-height: 44px; font-size: 13px; color: #fff1ce; }
.trix-menu-volume input { flex: 1 1 90px; min-width: 64px; accent-color: #efbc6a; }
.trix-menu-volume output { width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* Backup recovery is an independent account operation, not a story stage. */
.backup-recovery-dialog{width:min(620px,calc(100vw - 28px));max-height:calc(100dvh - 28px);padding:clamp(16px,4vw,28px);overflow:auto;overscroll-behavior:contain;border:1px solid #c3a16a;background:#12241f;color:#fff1ce}
.backup-recovery-dialog .backup-recovery-header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:0 0 12px;border-bottom:1px solid #806c4d}
.backup-recovery-header h2{margin:0;color:#f4d396;font-size:clamp(19px,4vw,24px)}
.backup-recovery-header small{color:#e2c58f;font-size:12px;letter-spacing:.08em}
.backup-recovery-header button{min-width:44px;min-height:44px;font-size:25px}
.backup-recovery-dialog p{line-height:1.65;margin:14px 0;color:#dbe5dd}
.backup-recovery-dialog a{color:#f7d28b;text-decoration:underline}
#storyTransferForm:not([hidden]){display:grid;gap:13px}
#storyTransferForm[hidden]{display:none}
#storyTransferForm>label:first-child{font-weight:750}
#storyTransferCode{display:block;width:100%;box-sizing:border-box;min-height:100px;padding:12px;border-radius:8px;border:1px solid #9c896c;background:#071a16;color:#fff;resize:vertical;font:13px/1.5 monospace;overflow-wrap:anywhere}
#storyTransferForm fieldset{display:grid;gap:10px;margin:0;padding:12px;border-radius:8px;border:1px solid #806c4d}
#storyTransferForm legend{padding:0 6px;font-weight:700}
#storyTransferForm fieldset label,#storyTransferForm .backup-recovery-repair{display:flex;align-items:flex-start;gap:10px;line-height:1.5;cursor:pointer}
#storyTransferForm input[type=radio],#storyTransferForm input[type=checkbox]{margin:4px 0 0;accent-color:#e7c378;flex:none}
#storyTransferForm button[type=submit]{min-height:46px;font-weight:750}
.backup-recovery-dialog .backup-recovery-help{font-size:13px;color:#c9d9ce}
#storyTransferStatus{white-space:pre-wrap;overflow-wrap:anywhere;font-weight:700;color:#f6d695}
@media(max-width:480px){.backup-recovery-dialog{padding:16px}.backup-recovery-dialog p{font-size:13px}}
