/* PC単列化、スマホフル画面、スマホSafariの画面構成。 */

@media (max-width: 620px) and (orientation: portrait) {
  body.mobile-layout {
    --player-surrender-width: 24px;
    --player-surrender-height: 24px;
    --player-surrender-icon-size: 14px;
    --player-surrender-hit-inset: -4px;
  }

  body.mobile-layout:lang(en) .app .player-name-row {
    gap: 3px;
  }

  body.mobile-layout .app .player-head .mobile-log-tool .mobile-header-tool-icon {
    transform: translateY(-2px);
  }

  body.mobile-layout:lang(en) .app .hand .card.awakened-warrior-card .card-info,
  body.mobile-layout:lang(en) .app .hand .card.awakened-warrior-card .type-label {
    padding-inline: 1px;
  }
}

/* 狭い縦画面は枚数表示を2段にまとめ、名前と降参を同じ行に残す。 */
@media (max-width: 380px) and (orientation: portrait) {
  body.mobile-layout .app .player-head .pile-stats {
    grid-template-columns: 34px 48px;
    grid-template-rows: 23px 23px;
    gap: 1px;
    align-items: stretch;
  }

  body.mobile-layout .app .player-head .pile-stats > .pile {
    height: 23px;
    min-height: 0;
    padding: 0 3px;
    font-size: 8px;
    line-height: 1;
  }

  body.mobile-layout .app .player-head .pile strong {
    font-size: 12px;
    line-height: 1;
  }

  body.mobile-layout .app .player-head .pile > span:not(.pile-count-roll) {
    font-size: 8px;
    line-height: 1;
  }

  body.mobile-layout .app .player-head .pile-count-roll {
    height: 12px;
    font-size: 12px;
    line-height: 1;
  }

  body.mobile-layout .app .player-head .mobile-header-tool {
    justify-self: center;
    align-self: stretch;
    width: 29px;
    min-width: 29px;
    height: 23px;
    min-height: 23px;
    font-size: 15px;
  }

  body.mobile-layout .app .player-head .life-icons {
    --life-icon-width: 6px;
    --life-icon-height: 10px;
    --life-icon-gap: 2px;
    height: 10px;
    min-height: 10px;
  }
}

@media (min-width: 621px) and (max-width: 1400px) {
  body:not(.mobile-layout):not(.mobile-landscape-layout) .player-head {
    --player-header-ornament-width: 18px;
    --player-header-ornament-scale: 100%;
  }

  body:not(.mobile-layout):not(.mobile-landscape-layout) .player-head .pile-stats {
    --pile-stat-gap: 4px;
  }
}

@media (max-width: 1080px) {
  .table {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    order: -1;
  }
}

body.mobile-layout .title-data-manager-modal {
  top: var(--mobile-viewport-offset-top, 0px);
  right: auto;
  bottom: auto;
  left: var(--mobile-viewport-offset-left, 0px);
  width: var(--mobile-viewport-width, 100dvw);
  height: var(--mobile-viewport-height, 100dvh);
}

body.mobile-layout .title-data-manager-panel {
  max-height: calc(
    var(--mobile-viewport-height, 100dvh)
    - max(24px, env(safe-area-inset-top))
    - max(24px, env(safe-area-inset-bottom))
  );
}

body.mobile-landscape-layout .title-data-manager-modal {
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

body.mobile-landscape-layout .title-data-manager-panel {
  width: min(520px, 72vw);
  max-height: calc(var(--mobile-viewport-height, 100dvh) - 16px);
  padding: 14px 18px;
}

body.mobile-landscape-layout .title-data-manager-panel h2 {
  font-size: 20px;
}

body.mobile-landscape-layout .title-data-manager-description,
body.mobile-landscape-layout .title-data-manager-panel .match-resume-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
}

body.mobile-landscape-layout .title-data-manager-actions {
  margin-top: 12px;
}

body.mobile-landscape-layout .title-data-manager-actions .match-resume-button {
  min-height: 42px;
  font-size: 13px;
}

body.mobile-landscape-layout .title-data-manager-status {
  margin-top: 6px;
}

/*
  カード付近の操作吹き出しは、縦画面と横画面で同じ部品を使う。
  PCではJS側から表示しないため、タッチ向けレイアウトだけを対象にする。
*/
body.mobile-layout > .mobile-context-menu,
body.mobile-landscape-layout > .mobile-context-menu {
  --mobile-context-arrow-x: 50%;
  position: fixed;
  z-index: 128;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: calc(100dvw - 12px);
  padding: 5px;
  border: 1px solid rgba(244, 214, 129, 0.6);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 238, 178, 0.14), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 48%),
    rgba(18, 22, 18, 0.94);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 239, 178, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(7px);
  isolation: isolate;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.mobile-layout > .mobile-context-menu.show,
body.mobile-landscape-layout > .mobile-context-menu.show {
  display: flex;
  animation: mobile-context-pop 140ms ease-out both;
}

body.mobile-layout > .mobile-context-menu::after,
body.mobile-landscape-layout > .mobile-context-menu::after {
  content: "";
  position: absolute;
  left: var(--mobile-context-arrow-x);
  width: 9px;
  height: 9px;
  border: 1px solid rgba(244, 214, 129, 0.5);
  background: rgba(20, 24, 19, 0.94);
  transform: translateX(-50%) rotate(45deg);
  z-index: -1;
}

body.mobile-layout > .mobile-context-menu.above::after,
body.mobile-landscape-layout > .mobile-context-menu.above::after {
  bottom: -5px;
  border-top: 0;
  border-left: 0;
}

body.mobile-layout > .mobile-context-menu.below::after,
body.mobile-landscape-layout > .mobile-context-menu.below::after {
  top: -5px;
  border-right: 0;
  border-bottom: 0;
}

body.mobile-layout > .mobile-context-menu button,
body.mobile-landscape-layout > .mobile-context-menu button {
  min-width: 54px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border-color: rgba(244, 214, 129, 0.52);
  background:
    linear-gradient(180deg, rgba(255, 244, 198, 0.17), transparent 54%),
    linear-gradient(180deg, rgba(63, 72, 48, 0.94), rgba(34, 40, 30, 0.96));
  color: #fff2c6;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.08;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.24);
}

body.mobile-landscape-layout > .mobile-context-menu button {
  font-size: var(--landscape-text-lg, 11px);
}

body.mobile-layout > .mobile-context-menu button:active:not(:disabled),
body.mobile-landscape-layout > .mobile-context-menu button:active:not(:disabled) {
  transform: translateY(1px);
  filter: brightness(1.08);
}

body.mobile-layout > .mobile-context-menu button:disabled,
body.mobile-landscape-layout > .mobile-context-menu button:disabled {
  opacity: 0.48;
}

body.mobile-layout > .mobile-context-menu .mobile-context-play,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-play {
  border-color: rgba(244, 203, 113, 0.74);
  background:
    linear-gradient(180deg, rgba(255, 235, 164, 0.22), transparent 52%),
    linear-gradient(180deg, rgba(87, 70, 35, 0.98), rgba(54, 43, 26, 0.98));
  color: #fff6d5;
}

body.mobile-layout > .mobile-context-menu .mobile-context-cost,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-cost {
  border-color: rgba(148, 197, 214, 0.58);
  background:
    linear-gradient(180deg, rgba(198, 235, 245, 0.14), transparent 52%),
    linear-gradient(180deg, rgba(36, 58, 62, 0.98), rgba(25, 41, 44, 0.98));
  color: #eaffff;
}

body.mobile-layout > .mobile-context-menu .mobile-context-special,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-special {
  border-color: rgba(178, 145, 238, 0.68);
  background:
    linear-gradient(180deg, rgba(221, 203, 255, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(54, 42, 79, 0.98), rgba(35, 29, 54, 0.98));
  color: #f1e7ff;
}

body.mobile-layout > .mobile-context-menu .mobile-context-move,
body.mobile-layout > .mobile-context-menu .mobile-context-effect,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-move,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-effect {
  border-color: rgba(140, 204, 156, 0.58);
  background:
    linear-gradient(180deg, rgba(198, 246, 210, 0.15), transparent 52%),
    linear-gradient(180deg, rgba(38, 64, 43, 0.98), rgba(27, 45, 32, 0.98));
  color: #e8ffe9;
}

body.mobile-layout > .mobile-context-menu .mobile-context-attack,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-attack {
  border-color: rgba(238, 168, 93, 0.7);
  background:
    linear-gradient(180deg, rgba(255, 227, 164, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(84, 48, 31, 0.98), rgba(57, 34, 25, 0.98));
}

body.mobile-layout > .mobile-context-menu .mobile-context-cancel,
body.mobile-landscape-layout > .mobile-context-menu .mobile-context-cancel {
  border-color: rgba(169, 196, 219, 0.56);
  background:
    linear-gradient(180deg, rgba(203, 228, 246, 0.14), transparent 52%),
    rgba(34, 44, 54, 0.94);
  color: #e8f5ff;
}

@media (max-width: 620px) and (orientation: portrait),
  (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  .title-screen {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, auto) minmax(0, auto);
    align-content: center;
    gap: 14px;
    padding: max(18px, env(safe-area-inset-top)) 18px max(54px, calc(env(safe-area-inset-bottom) + 44px));
  }

  .title-screen.title-tutorial-menu-open {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .title-screen.title-match-setup-open {
    align-content: stretch;
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
  }

  .title-screen::before {
    background-position: 50% 20%;
    background-size: min(122vw, 520px) auto;
    opacity: 0.18;
    filter: blur(10px) saturate(1.08);
  }

  .title-visual {
    min-height: 0;
    height: clamp(100px, calc(var(--app-viewport-height, 100dvh) * 0.3), 214px);
    max-height: 100%;
  }

  .title-logo-art {
    width: min(96vw, 430px);
    max-height: 100%;
    object-fit: contain;
    transform: translateY(0);
  }

  .title-panel {
    gap: 16px;
    padding: 20px;
  }

  .title-panel-stack {
    justify-self: center;
  }

  body.mobile-safari-layout .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open) > .title-visual,
  body.mobile-safari-layout .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open) > .title-panel-stack {
    transform: translateY(-12px);
  }

  .title-panel h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .title-action {
    min-height: 50px;
    font-size: 16px;
  }

  .title-data-manager-button {
    left: max(10px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
    min-height: 34px;
    padding: 5px 11px;
    font-size: 12px;
  }

  .title-public-beta-link {
    justify-self: start;
    margin: 0 4px;
    padding: 1px 4px;
    font-size: 11px;
  }

  body.mobile-safari-layout .title-data-manager-button {
    bottom: max(4px, calc(env(safe-area-inset-bottom) - 6px));
  }

  body.mobile-fullscreen-layout .title-data-manager-button {
    left: max(16px, calc(env(safe-area-inset-left) + 8px));
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
  }

  .title-audio-note {
    grid-template-columns: 1fr;
    gap: 8px;
    font-size: 10.5px;
  }

  .title-audio-controls {
    gap: 6px;
    width: auto;
    flex-wrap: wrap;
  }

  .title-audio-toggle {
    min-height: 27px;
    min-width: 68px;
    padding: 3px 8px;
    font-size: 10.5px;
  }

  .title-tutorial-menu {
    min-height: 0;
    max-height: min(calc(var(--app-viewport-height, 100dvh) * 0.42), 300px);
    overflow: auto;
    padding: 12px;
  }

  .title-tutorial-menu h2 {
    font-size: 16px;
  }

  .title-tutorial-menu-head {
    gap: 8px;
  }

  .title-tutorial-menu-actions {
    gap: 5px;
  }

  .title-tutorial-back,
  .title-tutorial-rulebook {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 11px;
    white-space: nowrap;
  }

  .title-tutorial-section-head {
    align-items: flex-start;
  }

  .title-tutorial-section-label {
    display: grid;
    gap: 1px;
  }

  .title-tutorial-section-kicker {
    font-size: 9px;
    line-height: 1.1;
  }

  .title-tutorial-section-head strong {
    line-height: 1.2;
  }

  .title-tutorial-item {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 9px;
    min-height: 62px;
    padding: 9px 10px;
  }

  .title-tutorial-item.is-cleared {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .title-tutorial-clear {
    min-width: 58px;
    padding: 3px 6px;
    font-size: 9px;
  }

  .title-tutorial-number {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .title-tutorial-copy strong {
    font-size: 13px;
    line-height: 1.22;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .title-tutorial-copy span {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .title-tutorial-next {
    display: none;
  }

  .title-screen.first-launch-opening-open {
    align-content: stretch;
    justify-items: stretch;
    width: 100dvw;
    max-width: 100dvw;
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .title-screen.first-launch-opening-open::before {
    inset: 0;
  }

  .first-launch-opening {
    grid-template-columns: minmax(0, 1fr);
    /* 横幅基準にして、ソフトキーボードで表示高が変わってもナビを動かさない。 */
    grid-template-rows: clamp(205px, 64vw, 255px) auto;
    align-items: start;
    align-self: start;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: calc(var(--mobile-viewport-height, 100dvh) - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    border-radius: 10px;
    overflow: hidden;
  }

  .first-launch-opening.is-name-editing {
    grid-template-rows: minmax(0, 1fr);
    height: calc(
      var(--mobile-viewport-height, 100dvh)
      - max(16px, env(safe-area-inset-top))
      - max(16px, env(safe-area-inset-bottom))
    );
    min-height: 0;
    max-height: 100%;
  }

  .first-launch-opening.is-name-editing .first-launch-dialog {
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .first-launch-opening.is-name-editing .first-launch-portrait-wrap {
    display: none;
  }

  .first-launch-portrait-wrap {
    width: 100%;
    min-width: 0;
    min-height: 185px;
    overflow: hidden;
  }

  .first-launch-portrait {
    bottom: -46px;
    width: min(310px, 78vw);
    height: calc(100% + 50px);
    object-position: center bottom;
  }

  .first-launch-dialog {
    align-content: start;
    width: auto;
    min-width: 0;
    max-width: calc(100% - 12px);
    min-height: 0;
    margin: 0 6px 8px;
    padding: 17px 16px;
    overflow-wrap: anywhere;
  }

  .first-launch-dialog h2 {
    font-size: clamp(20px, 6.5vw, 27px);
  }

  .first-launch-content {
    margin-top: 13px;
    font-size: 14px;
    line-height: 1.6;
  }

  .first-launch-name-field {
    margin-top: 12px;
  }

  .first-launch-name-field input {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .first-launch-character-list {
    min-width: 0;
    gap: 8px;
    margin-top: 12px;
  }

  .first-launch-character {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 7px;
    min-height: 62px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .first-launch-character img {
    width: 46px;
    height: 46px;
  }

  .first-launch-summary {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 11px;
    padding: 10px;
  }

  .first-launch-summary img {
    width: 58px;
    height: 58px;
  }

  .first-launch-summary strong {
    font-size: 18px;
  }

  .first-launch-actions {
    min-width: 0;
    margin-top: 16px;
  }

  .first-launch-action {
    min-height: 46px;
    font-size: 13px;
  }

  .navi-hint {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 7px;
    width: calc(100% - 16px);
    padding: 8px 7px;
  }

  .navi-hint img {
    width: 54px;
    height: 54px;
  }

  .navi-hint strong {
    font-size: 12px;
  }

  .navi-hint p {
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.4;
  }

  .navi-hint[data-hint-id="match-setup-first-visit"] {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 2px 6px;
  }

  .navi-hint[data-hint-id="match-setup-first-visit"] .navi-hint-copy {
    display: contents;
  }

  .navi-hint[data-hint-id="match-setup-first-visit"] img {
    grid-area: 1 / 1 / span 2;
    width: 40px;
  }

  .navi-hint[data-hint-id="match-setup-first-visit"] p {
    grid-area: 2 / 2 / 3 / -1;
    margin: 0;
  }

  .navi-hint[data-hint-id="match-setup-first-visit"] .navi-hint-action {
    padding-inline: 6px;
  }

  .navi-hint-placement-bottom-left {
    right: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  .navi-hint-placement-top-right {
    top: max(8px, env(safe-area-inset-top));
    bottom: auto;
  }

  .navi-hint-placement-top-left {
    top: max(8px, env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  .option-character-name-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .player-match-setup {
    --player-match-character-icon-size: clamp(54px, 17vw, 68px);
    width: 100%;
    max-height: none;
    height: 100%;
  }

  .player-match-setup-header {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 64px;
    padding: 8px 10px;
  }

  .player-match-setup-header h2 {
    font-size: 17px;
  }

  .player-match-setup-back {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .player-match-setup-actions {
    gap: 5px;
  }

  @media (max-width: 420px) and (orientation: portrait) {
    :lang(en) .player-match-setup-header {
      grid-template-columns: 44px minmax(0, 1fr);
      gap: 6px 10px;
    }

    :lang(en) .player-match-setup-back {
      grid-row: 1 / 3;
    }

    :lang(en) .player-match-setup-actions {
      grid-column: 2;
      justify-self: end;
    }
  }

  .player-trade-screen {
    inset: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 0;
  }

  .player-trade-header {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    min-height: 64px;
    padding: 8px 10px;
  }

  .player-trade-header h2 {
    font-size: 17px;
  }

  .player-trade-body {
    padding: 12px 10px;
  }

  .player-trade-opponent-grid,
  .player-trade-target-list {
    grid-template-columns: 1fr;
  }

  .player-trade-offer-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .player-trade-intro,
  .player-trade-target-head {
    display: grid;
    gap: 4px;
  }

  .player-trade-opponent {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    min-height: 66px;
  }

  .player-trade-opponent img {
    width: 52px;
    height: 52px;
  }

  .player-trade-confirm-cards {
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    gap: 5px;
  }

  .player-trade-confirm-face {
    --trade-confirm-card-max-width: 250px;
  }

  .player-trade-confirm-arrow {
    font-size: 24px;
  }

  .player-trade-confirm-card > strong {
    font-size: 12px;
  }

  .player-match-setup-options,
  .player-match-setup-deck-link {
    min-height: 44px;
    padding: 8px 11px;
    font-size: 12px;
  }

  .player-match-setup-options {
    width: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 14px;
  }

  .player-match-setup-options .mobile-header-tool-icon {
    font-size: 20px;
  }

  .player-match-extra-button,
  .player-match-setup-trade {
    width: 82px;
    min-width: 82px;
    min-height: 36px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .player-match-setup-trade {
    padding-inline: 4px;
  }

  .player-match-setup-body {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .player-match-loadout,
  .player-match-opponents {
    padding: 12px;
  }

  .player-match-loadout {
    border-right: 0;
    border-bottom: 1px solid rgba(242, 219, 157, 0.16);
  }

  .player-match-section-head {
    margin-bottom: 8px;
  }

  .player-match-section-head h3 {
    font-size: 15px;
  }

  .player-match-deck-select-wrap select {
    min-height: 38px;
  }

  .player-match-deck-preview {
    grid-template-columns: calc(var(--player-match-character-icon-size) + 4px) minmax(0, 1fr);
    min-height: 112px;
    margin-top: 8px;
    padding: 8px 0 5px;
  }

  .player-match-setup.is-trade-mode .player-match-deck-preview {
    display: grid;
    min-height: 0;
  }

  .player-match-trade-candidates {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    min-height: clamp(220px, 64vw, 260px);
  }

  .player-match-trade-candidate > strong {
    padding: 4px 2px;
    font-size: 9px;
  }

  .player-match-trade-opponent-grid {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 6px;
  }

  .player-match-trade-opponent {
    min-height: 106px;
  }

  .player-match-trade-detail {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 2px 24px 10px;
  }

  .player-match-trade-detail-card {
    width: min(100%, 390px);
  }

  .player-match-trade-detail-nav {
    display: none;
  }

  .player-match-deck-character img {
    width: var(--player-match-character-icon-size);
    height: var(--player-match-character-icon-size);
  }

  .player-match-setup-card {
    max-height: 118px;
    justify-self: center;
    width: 100%;
  }

  .player-match-setup-card-role {
    top: 3px;
    left: 3px;
    font-size: 9px;
  }

  .player-match-setup-card-name {
    padding: 5px 3px;
    font-size: 10px;
  }

  .player-match-opponent-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .player-match-opponent-final-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .player-match-opponent-group {
    padding: 7px 0 2px;
  }

  .player-match-opponent-group h4 {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .player-match-opponent-group-list {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 6px;
  }

  .player-match-opponent {
    --player-match-opponent-portrait-size: var(--player-match-character-icon-size);
    min-height: 102px;
    gap: 5px;
    padding: 8px 4px 7px;
    font-size: 12px;
  }

  .player-match-opponent-portrait {
    width: min(100%, var(--player-match-opponent-portrait-size));
  }

  .player-match-opponent.is-selected::after {
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    padding: 0;
    display: grid;
    place-items: center;
    content: "✓";
    font-size: 11px;
  }

  .player-match-setup-footer {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 88px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  .player-match-setup-footer p {
    font-size: 13px;
    line-height: 1.3;
    text-align: center;
    white-space: pre-line;
  }

  .player-match-start-button {
    min-height: 44px;
    font-size: 15px;
  }

  :root {
    --compact-card-min-width: 50px;
    /*
      Mobile sizing rule:
      keep the two structural layouts below, but derive spacing/card sizes from
      viewport-bound tokens so Safari chrome and device variations do not need
      one-off pixel fixes.
    */
    --mobile-player-panel-height: calc(var(--app-usable-height) / 2);
    --mobile-gap-xxs: clamp(1px, 0.35dvw, 2px);
    --mobile-gap-xs: clamp(3px, 1dvw, 4px);
    --mobile-gap-md: clamp(6px, 2.05dvw, 8px);
    --mobile-panel-radius: clamp(5px, 1.7dvw, 7px);
    --mobile-panel-gap: var(--mobile-gap-md);
    --mobile-battle-panel-inset: 6px;
    --mobile-edge-inset: 0px;
    --mobile-layout-width: var(--app-usable-width);
    --mobile-cost-column-width: clamp(61px, 16dvw, 66px);
    --mobile-lane-label-width: clamp(50px, 13.8dvw, 56px);
    --mobile-lane-gap: var(--mobile-gap-xs);
    --mobile-unit-row-padding-x: var(--mobile-gap-md);
    --mobile-unit-card-gap: clamp(4px, 1.25dvw, 5px);
    --mobile-unit-card-info-spread: clamp(2px, 1.1dvw, 4px);
    /* バトルゾーンの戦士カード比率はPC版と揃える。 */
    --mobile-board-card-aspect-width: var(--board-card-aspect-width);
    --mobile-board-card-aspect-height: var(--board-card-aspect-height);
    --mobile-zone-card-info-pad-top: clamp(3px, 0.7dvh, 5px);
    --mobile-zone-card-info-pad-bottom: clamp(3px, 0.7dvh, 5px);
    --mobile-zone-card-info-pad-x: 4px;
    --mobile-zone-card-line-gap: clamp(0px, 0.18dvh, 1px);
    --mobile-zone-card-trim: clamp(9px, 1.45dvh, 13px);
    --compact-row-height: clamp(82px, 10.1dvh, 90px);
    --mobile-hand-row-height: var(--compact-row-height);
    --mobile-opponent-hand-preview-height: var(--mobile-hand-row-height);
    --mobile-zone-card-height: calc(var(--compact-row-height) - var(--mobile-zone-card-trim));
    --mobile-zone-card-width: var(--compact-card-min-width);
    --mobile-field-row-height: calc((var(--mobile-player-panel-height) - var(--mobile-player-head-height) - var(--mobile-hand-row-height) - max(var(--mobile-selection-height), var(--mobile-menu-height))) / 2);
    --mobile-card-text-preview-height: calc(
      var(--app-usable-height)
      - (var(--mobile-player-head-height) * 2)
      - var(--mobile-menu-height)
      - var(--mobile-gap-md)
    );
    --mobile-board-content-width: calc(var(--mobile-layout-width) - var(--mobile-cost-column-width) - var(--mobile-lane-label-width) - var(--mobile-lane-gap) - var(--mobile-unit-row-padding-x));
    --mobile-board-row-trim: clamp(4px, 0.8dvh, 8px);
    --mobile-board-card-width-by-row: calc((var(--mobile-field-row-height) - var(--mobile-board-row-trim)) * var(--mobile-board-card-aspect-width) / var(--mobile-board-card-aspect-height));
    --mobile-board-card-width-by-column: calc((var(--mobile-board-content-width) - (var(--mobile-unit-card-gap) * 2)) / 3);
    --mobile-board-card-min-width: clamp(60px, 16.8dvw, 70px);
    --mobile-board-card-max-width: clamp(82px, 22.1dvw, 96px);
    --board-card-width: clamp(var(--mobile-board-card-min-width), min(var(--mobile-board-card-width-by-column), var(--mobile-board-card-width-by-row)), var(--mobile-board-card-max-width));
    --mobile-player-head-height: clamp(50px, 6.15dvh, 56px);
    --mobile-selection-height: clamp(90px, 12.1dvh, 110px);
    --mobile-notice-anchor-height: var(--mobile-selection-height);
    --mobile-menu-height: clamp(50px, 6.6dvh, 60px);
    --mobile-battle-panel-top: calc(var(--mobile-player-head-height) + var(--mobile-battle-selection-height, var(--mobile-selection-height)) + var(--mobile-hand-row-height) + var(--mobile-panel-gap));
    --mobile-battle-panel-bottom: calc(var(--mobile-menu-height) + var(--mobile-player-head-height) + var(--mobile-panel-gap));
    --mobile-battle-panel-padding-block-start: 1px;
    --mobile-battle-panel-padding-inline: 7px;
    --mobile-battle-panel-padding-block-end: 10px;
    --board-card-height: calc(var(--board-card-width) * var(--mobile-board-card-aspect-height) / var(--mobile-board-card-aspect-width));
    --compact-card-height: var(--board-card-height);
    --mobile-unit-name-font-size: clamp(7.8px, calc(var(--board-card-width) * 0.096), 8.7px);
    --mobile-unit-stat-font-size: clamp(7px, calc(var(--board-card-width) * 0.084), 7.6px);
    --mobile-unit-tiny-font-size: clamp(6.7px, calc(var(--board-card-width) * 0.079), 7.1px);
    --mobile-unit-level-badge-size: clamp(14px, calc(var(--board-card-width) * 0.18), 16px);
    --mobile-unit-level-badge-font-size: clamp(6.2px, calc(var(--board-card-width) * 0.078), 6.8px);
    --status-panel-min-height: 0px;
    --selection-panel-height: auto;
    --unit-row-reserved-height: calc(var(--board-card-height) + 12px);
  }

  html {
    min-width: 0;
    height: var(--app-viewport-height);
    overflow: hidden;
  }

  body {
    height: var(--app-viewport-height);
    min-height: 0;
    overflow: hidden;
  }

  .app {
    /* 固定欄を先に確保し、上下で同じ残り高を戦士欄へ配分する。 */
    --mobile-field-row-height: max(0px, calc((var(--app-usable-height) - (var(--mobile-player-head-height) * 2) - (var(--mobile-hand-row-height) * 2) - var(--mobile-selection-height) - var(--mobile-menu-height) - 4px) / 4));
    --mobile-card-text-preview-height: calc(var(--app-usable-height) - (var(--mobile-player-head-height) * 2) - var(--mobile-menu-height) - var(--mobile-gap-md));
    position: fixed;
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top));
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset));
    height: var(--app-usable-height);
    min-height: 0;
    width: var(--mobile-layout-width);
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  .topbar,
  .header-show-button {
    display: none !important;
  }

  .topbar-title {
    grid-column: auto;
    grid-row: auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .topbar p {
    font-size: 10px;
  }

  .topbar-action-stack {
    grid-column: auto;
    gap: 5px;
  }

  .topbar-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .toggle-option,
  .volume-option,
  .speed-mode-group,
  .topbar-link,
  .player-setup-group,
  #logToggleBtn,
  .header-hide-button,
  .topbar #tutorialStartBtn,
  .topbar #returnTitleBtn,
  .topbar #newGameBtn {
    flex: 0 0 auto;
    min-height: 30px;
    border-radius: 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  .volume-option input[type="range"] {
    width: 76px;
  }

  .player-setup-group {
    align-items: center;
    flex-wrap: wrap;
    max-width: 260px;
  }

  .player-setup-field select {
    min-width: 78px;
    max-width: 92px;
    font-size: 11px;
  }

  .table {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr);
    /*
      上側プレイヤーはステータス欄、下側プレイヤーはメニュー欄を持つ。
      単純に50/50で割ると上側の戦士欄だけ狭くなるため、固定欄の差分を
      上下パネルの高さに戻して、戦士フィールドの実効高さを揃える。
    */
    --mobile-field-panel-balance: calc((var(--mobile-selection-height) - var(--mobile-menu-height)) / 2);
    grid-template-rows:
      minmax(0, calc(50% + var(--mobile-field-panel-balance)))
      minmax(0, calc(50% - var(--mobile-field-panel-balance)));
    grid-template-areas:
      "opponent"
      "self";
    gap: 0;
    height: 100%;
    min-height: 0;
    padding-top: 0;
    overflow: hidden;
  }

  #player2 {
    grid-area: opponent;
  }

  #controlPanel {
    grid-area: control;
  }

  #player1 {
    grid-area: self;
  }

  .player-panel {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--mobile-cost-column-width);
    grid-template-rows:
      var(--mobile-player-head-height)
      var(--compact-row-height)
      minmax(var(--mobile-field-row-height), 1fr)
      minmax(var(--mobile-field-row-height), 1fr);
    grid-template-areas:
      "head head"
      "hand cost"
      "back cost"
      "front cost";
    border-color: transparent;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }

  .player-panel.current {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .player-panel.fallen,
  .player-panel.fallen.current {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .player-panel.current .player-head {
    border-color: rgba(224, 184, 78, 0.34);
    box-shadow:
      var(--player-header-shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.045),
      inset 0 -1px 0 rgba(0, 0, 0, 0.24);
  }

  .player-head {
    --player-header-ornament-width: clamp(15px, 4.6dvw, 18px);
    position: relative;
    z-index: 6;
    grid-area: head;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    min-height: var(--mobile-player-head-height);
    height: var(--mobile-player-head-height);
    padding: 1px var(--player-header-ornament-width);
    border-bottom-color: rgba(242, 219, 157, 0.12);
    background:
      radial-gradient(circle at 7% 50%, rgba(255, 226, 154, 0.1), transparent 32%),
      linear-gradient(90deg, rgba(34, 39, 33, 0.4), rgba(21, 25, 21, 0.32)),
      var(--player-header-texture) center / 768px 384px repeat;
    backdrop-filter: blur(4px);
    box-shadow:
      var(--player-header-shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.045),
      inset 0 -1px 0 rgba(0, 0, 0, 0.24);
    overflow: visible;
  }

  .player-panel.fallen .player-head {
    border-bottom-color: rgba(242, 219, 157, 0.12);
    background:
      radial-gradient(circle at 7% 50%, rgba(255, 226, 154, 0.1), transparent 32%),
      linear-gradient(90deg, rgba(34, 39, 33, 0.4), rgba(21, 25, 21, 0.32)),
      var(--player-header-texture) center / 768px 384px repeat;
    box-shadow:
      var(--player-header-shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.045),
      inset 0 -1px 0 rgba(0, 0, 0, 0.24);
  }

  .player-head > .player-identity {
    min-width: 0;
  }

  .avatar-icon {
    width: 38px;
    height: 38px;
  }

  .player-name {
    font-size: 13px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-name-row {
    gap: 5px;
  }

  .player-surrender-button {
    min-height: 18px;
    padding: 1px 5px;
    font-size: 9px;
  }

  .player-flags {
    display: block;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-avatar .player-state-badge {
    padding: 1px 2px;
    font-size: 8px;
  }

  .player-state-badge,
  .fallen-badge {
    max-width: 58px;
    padding: 2px 5px;
    font-size: 9px;
    line-height: 1.1;
    overflow: visible;
    text-overflow: clip;
  }

  .pile-stats {
    --pile-stat-gap: 3px;
    grid-auto-flow: row;
    grid-auto-columns: initial;
    grid-template-columns: 30px 48px repeat(2, 34px);
    gap: var(--pile-stat-gap);
  }

  :lang(en) .pile-stats {
    grid-template-columns: 30px 48px 34px 38px;
  }

  .pile-stats > .pile {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    contain: layout;
  }

  .mobile-header-tool {
    display: grid;
    place-items: center;
    width: 29px;
    min-width: 29px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 1px solid rgba(174, 231, 255, 0.35);
    border-radius: 7px;
    background:
      radial-gradient(circle at 50% 18%, rgba(174, 231, 255, 0.18), transparent 36%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 55%),
      rgba(16, 24, 26, 0.9);
    color: #e8f8ff;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 0 8px rgba(174, 231, 255, 0.08);
  }

  .mobile-header-tool-icon {
    display: block;
    transform: translateY(-0.5px);
  }

  .mobile-options-tool {
    border-color: rgba(224, 184, 78, 0.5);
    color: #fff2bc;
    background:
      radial-gradient(circle at 50% 18%, rgba(255, 242, 183, 0.22), transparent 36%),
      linear-gradient(180deg, rgba(255, 242, 183, 0.14), transparent 58%),
      rgba(31, 27, 18, 0.9);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 0 9px rgba(224, 184, 78, 0.12);
  }

  .pile {
    min-width: 34px;
    padding: 3px 4px;
    border-radius: 5px;
  }

  .pile strong {
    font-size: 12px;
  }

  .pile-count-roll {
    width: 100%;
    height: 13.2px;
    margin-inline: 0;
  }

  .pile span {
    font-size: 8.5px;
  }

  .life-pile {
    min-width: 0;
  }

  .life-icons {
    --life-icon-width: 10px;
    --life-icon-height: 14px;
    --life-icon-gap: 2px;
    height: 14px;
    min-height: 14px;
    gap: var(--life-icon-gap);
  }

  .life-icon {
    width: var(--life-icon-width);
    height: var(--life-icon-height);
  }

  .zone {
    padding: 4px;
  }

  .board {
    display: contents;
    gap: 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #player1.player-panel {
    grid-template-rows:
      minmax(var(--mobile-field-row-height), 1fr)
      minmax(var(--mobile-field-row-height), 1fr)
      var(--mobile-hand-row-height)
      var(--mobile-menu-height)
      var(--mobile-player-head-height);
    grid-template-areas:
      "front cost"
      "back cost"
      "hand cost"
      "actions special"
      "head head";
  }

  #player1 .player-head {
    --player-header-shadow: 0 -2px 3px rgba(0, 0, 0, 0.42), 0 -7px 14px rgba(0, 0, 0, 0.24);
  }

  #player2.player-panel {
    grid-template-rows:
      var(--mobile-player-head-height)
      var(--mobile-selection-height)
      var(--mobile-hand-row-height)
      minmax(var(--mobile-field-row-height), 1fr)
      minmax(var(--mobile-field-row-height), 1fr);
    grid-template-areas:
      "head head"
      "selection selection"
      "hand cost"
      "back cost"
      "front cost";
  }

  .app.mobile-fullscreen-layout {
    --mobile-fullscreen-selection-height: clamp(76px, calc(var(--app-usable-height) * 0.117), 104px);
    --mobile-selection-height: var(--mobile-fullscreen-selection-height);
    --mobile-menu-height: clamp(48px, calc(var(--app-usable-height) * 0.0625), 56px);
    --mobile-hand-row-height: clamp(64px, calc(var(--app-usable-height) * 0.09), calc(var(--compact-row-height) - 4px));
    /* 高さ不足時は相手の手札に重ねて、戦闘の表示領域を先に確保する。 */
    --mobile-battle-panel-top: min(
      calc(var(--mobile-player-head-height) + var(--mobile-battle-selection-height, var(--mobile-selection-height)) + var(--mobile-hand-row-height)),
      max(
        calc(var(--mobile-player-head-height) + var(--mobile-battle-selection-height, var(--mobile-selection-height))),
        calc(var(--app-usable-height) - var(--mobile-battle-panel-bottom) - 400px)
      )
    );
    --mobile-battle-panel-bottom: calc(var(--mobile-menu-height) + var(--mobile-player-head-height) + 1px);
    --mobile-battle-panel-padding-block-end: 6px;
    --mobile-lane-label-width: clamp(46px, 12.2dvw, 50px);
    --mobile-unit-row-padding-x: clamp(2px, 0.75dvw, 4px);
    --mobile-unit-card-gap: clamp(2px, 0.85dvw, 4px);
    --mobile-board-row-trim: clamp(0px, 0.16dvh, 2px);
    --mobile-board-card-height-max: clamp(104px, 12.35dvh, 116px);
    --mobile-board-card-height-limit:
      clamp(64px, calc(var(--app-usable-height) * 0.1225), var(--mobile-board-card-height-max));
    --board-card-height: max(0px, min(
      calc(var(--mobile-field-row-height) - var(--mobile-board-row-trim)),
      var(--mobile-board-card-height-limit)
    ));
    --board-card-width: calc(var(--board-card-height) * var(--mobile-board-card-aspect-width) / var(--mobile-board-card-aspect-height));
  }

  /*
    Android Chromeなどの縦長ブラウザでは、カード高が上限へ達した後も
    戦士行だけが伸び続ける。カード高付近を超えた4行分の余白は上部の
    フェイズ・テキスト欄へ戻し、盤面中央に不自然な空白を作らない。
  */
  @media (display-mode: browser) {
    .app.mobile-fullscreen-layout:not(.native-app-layout) {
      --mobile-browser-base-field-row-height: max(0px, calc(
        (
          var(--app-usable-height)
          - (var(--mobile-player-head-height) * 2)
          - (var(--mobile-hand-row-height) * 2)
          - var(--mobile-fullscreen-selection-height)
          - var(--mobile-menu-height)
          - 4px
        ) / 4
      ));
      --mobile-browser-board-card-height: max(0px, min(
        calc(var(--mobile-browser-base-field-row-height) - var(--mobile-board-row-trim)),
        var(--mobile-board-card-height-limit)
      ));
      --mobile-browser-field-row-height: min(
        var(--mobile-browser-base-field-row-height),
        calc(var(--mobile-browser-board-card-height) + clamp(3px, 0.45dvh, 5px))
      );
      --mobile-browser-field-surplus: max(0px, calc(
        (var(--mobile-browser-base-field-row-height) - var(--mobile-browser-field-row-height)) * 4
      ));
      --mobile-selection-height: calc(
        var(--mobile-fullscreen-selection-height) + var(--mobile-browser-field-surplus)
      );
    }

    /*
      縦長ブラウザで上部欄へ戻した余白は、カード選択中のイラストにも使う。
      短い画面では従来寸法を保ち、長押し詳細は専用レイアウトへ任せる。
    */
    .app.mobile-fullscreen-layout:not(.native-app-layout) .selection:not(.card-text-hold-preview) {
      --compact-selection-art-height: min(112px, calc(var(--mobile-selection-height) - 12px));
      --compact-selection-art-width: calc(var(--compact-selection-art-height) * 54 / 76);
    }
  }

  /*
    SafariでURLバーが出る実機表示は縦幅が足りないため、戦士欄だけ
    前衛/後衛を横並びに戻す。カード寸法は上の共通変数を使い回す。
  */
  .app.mobile-safari-layout {
    --mobile-edge-inset: calc(var(--app-usable-width) * 0.0045);
    --mobile-layout-width: calc(var(--app-usable-width) - (var(--mobile-edge-inset) * 2));
    --mobile-safari-selection-base: clamp(76px, calc(var(--app-usable-height) * 0.121), 110px);
    --mobile-selection-height: calc(var(--mobile-safari-selection-base) + clamp(0px, calc((var(--app-usable-height) - 680px) * 0.2), 24px));
    --compact-row-height: clamp(56px, calc(var(--app-usable-height) * 0.105), 90px);
    --mobile-hand-row-height: var(--compact-row-height);
    /*
      Safariの短い可視領域では行高だけが先に縮むため、手札が正方形に
      近づかないようカード高を幅と可視高の両方から決める。
    */
    --mobile-safari-zone-card-height: clamp(
      calc(var(--mobile-zone-card-width) * 1.2),
      calc(var(--app-usable-height) * 0.115),
      calc(var(--mobile-zone-card-width) * 1.46)
    );
    --mobile-zone-card-height: max(
      calc(var(--compact-row-height) - var(--mobile-zone-card-trim)),
      var(--mobile-safari-zone-card-height)
    );
    --mobile-safari-hand-clearance: max(10px, calc(var(--mobile-zone-card-height) - var(--mobile-hand-row-height) + 14px));
    --mobile-safari-lane-overhead: calc(24px + var(--mobile-safari-hand-clearance));
    --mobile-opponent-hand-preview-height: var(--compact-row-height);
    --mobile-battle-panel-top: calc(var(--mobile-player-head-height) + var(--mobile-battle-selection-height, var(--mobile-selection-height)) + var(--mobile-panel-gap));
    --mobile-battle-panel-bottom: calc(var(--mobile-player-head-height) + var(--mobile-gap-xxs));
    position: fixed;
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top));
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset));
    width: var(--mobile-layout-width);
    height: var(--app-usable-height);
    margin: 0;
  }

  .app.mobile-safari-layout .player-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--mobile-cost-column-width);
    /*
      狭幅Safariは前衛/後衛を横並びにするため、通常スマホの縦積み行高から
      戦士カード幅を逆算すると細くなりすぎる。横幅はこれ以上広げず、
      Safariの縦方向の余白だけを少しカード高さに戻す。
    */
    --mobile-safari-board-card-width: clamp(66px, min(18.8dvw, calc((var(--mobile-layout-width) - var(--mobile-cost-column-width) - 18px) / 4.05)), 76px);
    --board-card-width: min(var(--mobile-safari-board-card-width), max(0px, calc((var(--mobile-field-row-height) * 2 - var(--mobile-safari-lane-overhead)) * var(--mobile-board-card-aspect-width) / var(--mobile-board-card-aspect-height))));
    --board-card-height: calc(var(--board-card-width) * var(--mobile-board-card-aspect-height) / var(--mobile-board-card-aspect-width));
  }

  /*
    狭幅Safariは前衛/後衛を横並びにするため、3体いる列へ幅を寄せる。
    戦士カード寸法は変えず、フィールド配分だけを戻す。
  */
  .app.mobile-safari-layout .player-panel.board-front-heavy {
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) var(--mobile-cost-column-width);
  }

  .app.mobile-safari-layout .player-panel.board-back-heavy {
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) var(--mobile-cost-column-width);
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy.board-back-heavy {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--mobile-cost-column-width);
  }

  .app.mobile-safari-layout #player2.player-panel {
    grid-template-rows:
      var(--mobile-player-head-height)
      var(--mobile-selection-height)
      var(--compact-row-height)
      minmax(0, 1fr);
    grid-template-areas:
      "head head head"
      "selection selection selection"
      "hand hand cost"
      "front back cost";
  }

  .app.mobile-safari-layout #player1.player-panel {
    grid-template-rows:
      minmax(0, 1fr)
      var(--compact-row-height)
      var(--mobile-menu-height)
      var(--mobile-player-head-height);
    grid-template-areas:
      "front back cost"
      "hand hand cost"
      "actions actions special"
      "head head head";
  }

  .lane {
    position: relative;
    z-index: 1;
    min-width: 0;
    grid-template-columns: var(--mobile-lane-label-width) minmax(0, 1fr);
    gap: var(--mobile-lane-gap);
    min-height: 0;
    padding: 1px 4px;
    background: transparent;
  }

  .front-row {
    background: var(--field-front-bg);
  }

  .back-row {
    background: var(--field-back-bg);
  }

  .front-lane {
    grid-area: front;
  }

  .back-lane {
    grid-area: back;
  }

  @supports selector(.lane:has(.unit.selected)) {
    .lane:has(.unit.selected, .unit.targeted) {
      z-index: 66;
    }
  }

  .lane-label {
    border-radius: 5px;
    font-size: 10.5px;
    writing-mode: horizontal-tb;
    letter-spacing: 0;
  }

  .app.mobile-fullscreen-layout .lane {
    --mobile-fullscreen-lane-offset: calc(var(--mobile-lane-label-width) + var(--mobile-lane-gap));
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .app.mobile-fullscreen-layout .lane-label {
    position: absolute;
    left: 10px;
    top: clamp(6px, 1.8dvw, 8px);
    z-index: 4;
    min-width: clamp(44px, 12.5dvw, 52px);
    height: clamp(20px, 5.2dvw, 22px);
    padding: 0 8px;
    border-radius: 999px;
    writing-mode: horizontal-tb;
    font-size: clamp(9.5px, 2.8dvw, 10.5px);
    line-height: 1;
    pointer-events: none;
  }

  .app.mobile-fullscreen-layout .unit-row {
    --mobile-field-depth-scale: 1;
    --mobile-field-shadow-opacity: 0.2;
    padding-left: calc(var(--mobile-fullscreen-lane-offset) + 1px);
    padding-right: 1px;
    transform: scale(var(--mobile-field-depth-scale));
    transform-origin: 50% 50%;
    transition: transform 180ms ease;
  }

  /*
   * iOS WebKitでは盤面再描画ごとに多数のカードをGPUレイヤー化すると、
   * CSS背景画像の再合成がちらついて見える。動く要素だけが必要時に昇格するため、
   * フル画面版とSafari版の通常カードは常時予約を解除する。
   */
  .app.mobile-fullscreen-layout .card,
  .app.mobile-fullscreen-layout .unit,
  .app.mobile-safari-layout .card,
  .app.mobile-safari-layout .unit {
    will-change: auto;
  }

  /* 縦画面の選択は枠で示し、可視高による配置切替後も画像の再合成を避ける。 */
  .app.mobile-fullscreen-layout .card.selected,
  .app.mobile-fullscreen-layout .unit.selected,
  .app.mobile-fullscreen-layout .unit.targeted,
  .app.mobile-safari-layout .card.selected,
  .app.mobile-safari-layout .unit.selected,
  .app.mobile-safari-layout .unit.targeted {
    filter: none;
  }

  /* 縦背景の消失点へ向かうほど盤面カードをわずかに縮める。 */
  .app.mobile-fullscreen-layout #player2 .back-lane .unit-row {
    --mobile-field-depth-scale: 0.955;
    --mobile-field-shadow-opacity: 0.1;
  }

  .app.mobile-fullscreen-layout #player2 .front-lane .unit-row {
    --mobile-field-depth-scale: 0.972;
    --mobile-field-shadow-opacity: 0.13;
  }

  .app.mobile-fullscreen-layout #player1 .front-lane .unit-row {
    --mobile-field-depth-scale: 0.988;
    --mobile-field-shadow-opacity: 0.16;
  }

  .app.mobile-fullscreen-layout .unit-row::after {
    left: 18%;
    right: 10%;
    bottom: 0;
    height: clamp(6px, 0.9dvh, 8px);
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.62), transparent 72%);
    filter: blur(3px);
    opacity: var(--mobile-field-shadow-opacity);
  }

  .app.mobile-fullscreen-layout .front-lane {
    padding-bottom: 0;
    overflow: visible;
  }

  .app.mobile-fullscreen-layout .back-lane {
    padding-top: 0;
    overflow: visible;
  }

  .app.mobile-fullscreen-layout .front-lane .unit-row {
    align-items: start;
    padding-top: 1px;
    padding-bottom: 1px;
  }

  .app.mobile-fullscreen-layout .back-lane .unit-row {
    align-items: end;
    padding-top: 1px;
    padding-bottom: 0;
  }

  /*
   * 縦長端末で戦士カードが最大高に達した後の余白は、手札との間へ残さない。
   * 後衛は各プレイヤーの手札側、前衛は盤面中央側へ寄せる。
   */
  .app.mobile-fullscreen-layout #player2 .back-lane .unit-row,
  .app.mobile-fullscreen-layout #player1 .front-lane .unit-row {
    align-content: safe start;
  }

  .app.mobile-fullscreen-layout #player2 .front-lane .unit-row,
  .app.mobile-fullscreen-layout #player1 .back-lane .unit-row {
    align-content: safe end;
  }

  .app.mobile-fullscreen-layout #player2 .back-lane .unit-row {
    /* 遠近縮小と行高の余りを補正し、前衛との見た目の隙間を自分側へ揃える。 */
    padding-top: clamp(
      1px,
      calc(2px + (
        var(--board-card-height)
        - max(0px, calc(var(--mobile-field-row-height) - var(--board-card-height) - 4px))
      ) * 0.033),
      6px
    );
    padding-bottom: clamp(2px, 0.35dvh, 3px);
  }

  .app.mobile-fullscreen-layout #player2 .front-lane .unit-row {
    padding-top: 0;
  }

  .app.mobile-fullscreen-layout #player2 .back-lane,
  .app.mobile-fullscreen-layout #player2 .front-lane {
    transform: translateY(calc(-1 * clamp(2px, 0.35dvh, 3px)));
  }

  @media (max-width: 620px) {
    body.mobile-layout .app.mobile-fullscreen-layout[data-portrait-field-layout] {
      --board-card-height: var(--portrait-field-card-height);
      --board-card-width: var(--portrait-field-card-width);
      --mobile-selection-height: var(--portrait-field-selection-height);
    }

    /* 中央へ揃えた前衛のレベル表示が、未選択時も陣営の境界で切れないようにする。 */
    .app.mobile-fullscreen-layout[data-portrait-field-layout="balanced"] #player1.player-panel {
      overflow: visible;
    }

    .app.mobile-fullscreen-layout[data-portrait-field-layout="balanced"] :is(#player1, #player2) .lane .unit-row {
      position: absolute;
      top: var(--portrait-row-top);
      left: var(--portrait-row-left);
      right: auto;
      width: var(--portrait-row-width);
      height: calc(var(--board-card-height) + 2px);
      padding-top: 0;
      padding-bottom: 0;
      align-content: start;
      align-items: start;
      transform-origin: 50% 0;
    }

    .app.mobile-fullscreen-layout[data-portrait-field-layout="balanced"] .lane-label {
      top: var(--portrait-row-label);
    }

    .app #player2 .back-lane {
      --portrait-row-top: var(--portrait-field-opponent-back-top);
      --portrait-row-label: var(--portrait-field-opponent-back-label);
      --portrait-row-left: var(--portrait-field-opponent-back-left);
      --portrait-row-width: var(--portrait-field-opponent-back-width);
    }
    .app #player2 .front-lane {
      --portrait-row-top: var(--portrait-field-opponent-front-top);
      --portrait-row-label: var(--portrait-field-opponent-front-label);
      --portrait-row-left: var(--portrait-field-opponent-front-left);
      --portrait-row-width: var(--portrait-field-opponent-front-width);
    }
    .app #player1 .front-lane {
      --portrait-row-top: var(--portrait-field-self-front-top);
      --portrait-row-label: var(--portrait-field-self-front-label);
      --portrait-row-left: var(--portrait-field-self-front-left);
      --portrait-row-width: var(--portrait-field-self-front-width);
    }
    .app #player1 .back-lane {
      --portrait-row-top: var(--portrait-field-self-back-top);
      --portrait-row-label: var(--portrait-field-self-back-label);
      --portrait-row-left: var(--portrait-field-self-back-left);
      --portrait-row-width: var(--portrait-field-self-back-width);
    }

    .app.mobile-fullscreen-layout {
      --mobile-rear-gap-adjustment: clamp(0px, calc((var(--board-card-height) - 80px) * 0.125), 2px);
    }

    /* 相手後衛だけを前衛へ寄せる。小さいカードでは重ならないよう移動を抑える。 */
    .app.mobile-fullscreen-layout #player2 .back-lane .unit-row {
      top: clamp(0px, calc((var(--board-card-height) - 96px) * 0.2), 3px);
    }

    /* 自分側の間隔は維持する。 */
    .app.mobile-fullscreen-layout #player1 .back-lane .unit-row {
      top: var(--mobile-rear-gap-adjustment);
    }
  }

  @supports selector(.player-panel:has(.unit.commander)) {
    .player-panel:has(.unit.commander),
    .lane:has(.unit.commander),
    .lane:has(.unit.commander) .unit-row {
      overflow: visible;
    }

    .player-panel:has(.unit.commander) {
      z-index: 70;
    }

    .lane:has(.unit.commander) {
      z-index: 72;
    }

    .unit-row .unit.commander {
      z-index: 74;
    }

    .app.mobile-fullscreen-layout #player1.player-panel:has(.front-lane .unit.commander) {
      z-index: 76;
    }

    @media (max-width: 620px) {
      /* 盤面では前衛の大将バッジを相手側のカードや登場演出より手前に表示する。 */
      .app.mobile-fullscreen-layout:not(:has(.control-panel.has-pending-battle)) #player1.player-panel:has(.front-lane .unit.commander) {
        z-index: 83;
      }
    }
  }

  /*
    登場・レベルアップ中だけ、カードの上昇と発光がプレイヤーパネルの
    境界で切れないようにする。通常時の盤面クリップはそのまま保つ。
  */
  @supports selector(.player-panel:has(.unit-visual-level-up)) {
    .app.mobile-fullscreen-layout .player-panel:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-safari-layout .player-panel:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-fullscreen-layout .lane:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-safari-layout .lane:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-fullscreen-layout .lane:has(.unit-visual-call, .unit-visual-level-up) .unit-row,
    .app.mobile-safari-layout .lane:has(.unit-visual-call, .unit-visual-level-up) .unit-row {
      overflow: visible;
    }

    .app.mobile-fullscreen-layout .player-panel:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-safari-layout .player-panel:has(.unit-visual-call, .unit-visual-level-up) {
      z-index: 82;
    }

    .app.mobile-fullscreen-layout .lane:has(.unit-visual-call, .unit-visual-level-up),
    .app.mobile-safari-layout .lane:has(.unit-visual-call, .unit-visual-level-up) {
      z-index: 84;
    }
  }

  .app.mobile-fullscreen-layout #player2 .back-lane {
    z-index: 71;
  }

  .app.mobile-fullscreen-layout #player2 .front-lane {
    z-index: 78;
  }

  @supports selector(.lane:has(.unit.selected)) {
    .app.mobile-fullscreen-layout .player-panel:has(.unit.selected, .unit.targeted),
    .app.mobile-fullscreen-layout .lane:has(.unit.selected, .unit.targeted),
    .app.mobile-fullscreen-layout .lane:has(.unit.selected, .unit.targeted) .unit-row {
      overflow: visible;
    }

    .app.mobile-fullscreen-layout .lane:has(.unit.selected, .unit.targeted) {
      z-index: 96;
    }

    .app.mobile-fullscreen-layout .lane:has(.unit.selected, .unit.targeted) .unit-row {
      z-index: 98;
    }

    .app.mobile-fullscreen-layout .unit-row .unit.selected,
    .app.mobile-fullscreen-layout .unit-row .unit.targeted {
      z-index: 100;
    }

    .app.mobile-fullscreen-layout .unit-row .unit.selected .level-badge,
    .app.mobile-fullscreen-layout .unit-row .unit.targeted .level-badge {
      z-index: 124;
    }
  }

  .app.mobile-fullscreen-layout .front-lane .unit-row,
  .app.mobile-fullscreen-layout .back-lane .unit-row {
    overflow: visible;
  }

  .unit-row {
    grid-template-columns: repeat(3, var(--board-card-width));
    grid-auto-rows: var(--board-card-height);
    justify-content: center;
    column-gap: var(--mobile-unit-card-gap);
    align-items: center;
    min-height: 0;
    height: 100%;
    padding: 4px calc(var(--mobile-unit-row-padding-x) / 2) 2px;
    border-radius: 6px;
    overflow: visible;
  }

  .unit-row::after {
    display: none;
  }

  .app.mobile-safari-layout .lane {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 18px minmax(0, 1fr);
    gap: 1px;
    padding: 1px 2px 2px;
  }

  /* 手札の張り出し分を両側に確保し、戦士欄の残りの余白を均等に配分する。 */
  .app.mobile-safari-layout #player2 .lane {
    grid-template-rows: 18px calc(var(--board-card-height) + 2px);
    /* 相手側は手札と戦士の間に列ラベルが入る分、追加余白を控える。 */
    padding-top: max(2px, calc(var(--mobile-safari-hand-clearance) - 12px));
    align-content: safe center;
  }

  /* 自分側もカードの高さで背景を止め、余った高さは上下の余白へ分ける。 */
  .app.mobile-safari-layout #player1 .lane {
    grid-template-rows: 18px calc(var(--board-card-height) + 2px);
    padding-bottom: var(--mobile-safari-hand-clearance);
    align-content: safe center;
  }

  .app.mobile-safari-layout .lane-label {
    min-height: 18px;
    height: 18px;
    justify-content: center;
    align-items: center;
    writing-mode: horizontal-tb;
  }

  .app.mobile-safari-layout .unit-row {
    justify-content: start;
    align-content: start;
    align-items: center;
    padding-inline: 2px;
    padding-top: 1px;
    padding-bottom: 1px;
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .unit-row,
  .app.mobile-safari-layout .player-panel.board-back-heavy .unit-row {
    column-gap: clamp(3px, 0.9dvw, 4px);
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane,
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane {
    overflow: visible;
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane::before,
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane::before {
    content: "";
    position: absolute;
    inset: 2px -2px 3px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 0;
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane::before {
    background: var(--field-back-bg);
  }

  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane::before {
    background: var(--field-front-bg);
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane > *,
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane > * {
    position: relative;
    z-index: 1;
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane .unit-row,
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane .unit-row {
    grid-template-columns: var(--board-card-width);
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane .unit-row:has(> .empty),
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane .unit-row:has(> .empty) {
    justify-content: center;
    overflow: hidden;
  }

  .app.mobile-safari-layout .player-panel.board-front-heavy .back-lane .unit-row:has(> .empty) > .empty,
  .app.mobile-safari-layout .player-panel.board-back-heavy .front-lane .unit-row:has(> .empty) > .empty {
    max-width: calc(100% - 4px);
  }

  .unit-row > .unit,
  .unit-row > .empty {
    scroll-snap-align: start;
  }

  .unit-row > .empty {
    width: var(--board-card-width);
    height: var(--board-card-height);
  }

  .unit-row > .empty,
  .cost > .empty {
    font-size: 0;
  }

  .special-commander-focus {
    inset: -4px !important;
    border-radius: 9px;
  }

  .unit {
    height: var(--board-card-height);
    min-height: 0;
    padding: var(--unit-frame-padding);
    overflow: visible;
  }

  .unit.has-card-art {
    background-position: center top;
  }

  .unit.has-card-art > .card-art-surface > img {
    object-position: center top;
  }

  .unit.has-card-art .card-info {
    width: calc(100% + var(--mobile-unit-card-info-spread));
    max-width: none;
    margin-left: calc(var(--mobile-unit-card-info-spread) / -2);
    padding-right: 5px;
    padding-left: 5px;
    overflow: hidden;
  }

  .app.mobile-fullscreen-layout .unit.has-card-art .card-info {
    width: calc(100% + var(--mobile-unit-card-info-spread) + 4px);
  }

  .app.mobile-fullscreen-layout .unit .level-badge {
    top: -4px;
    left: -5px;
    z-index: 110;
  }

  .unit .name {
    min-height: 15px;
    font-size: var(--mobile-unit-name-font-size);
    line-height: 1.12;
    -webkit-line-clamp: 2;
  }

  .app.mobile-safari-layout .unit .name {
    font-size: clamp(7.7px, calc(var(--board-card-width) * 0.092), 8.4px);
    line-height: 1.1;
  }

  .unit .unit-stat-line,
  .unit .stat-line {
    margin-top: 2px;
    font-size: var(--mobile-unit-stat-font-size);
    line-height: 1.1;
  }

  .unit .stat-delta {
    margin-left: 1px;
    font-size: var(--mobile-unit-tiny-font-size);
    font-weight: 700;
  }

  .unit .tiny {
    font-size: var(--mobile-unit-tiny-font-size);
    line-height: 1;
  }

  .unit .tag-line,
  .unit .effect-line {
    display: none;
  }

  .unit .hpbar {
    height: 6px;
    margin-top: 4px;
  }

  .unit .level-badge {
    top: -1px;
    left: -3px;
    z-index: 110;
    width: var(--mobile-unit-level-badge-size);
    height: var(--mobile-unit-level-badge-size);
    font-size: var(--mobile-unit-level-badge-font-size);
  }

  .hand .level-badge,
  .cost .level-badge {
    top: -1px;
    left: -1px;
    width: 15px;
    height: 15px;
    font-size: 6.5px;
  }

  .unit .commander-badge {
    top: -8px;
    z-index: 112;
    min-width: 34px;
    padding: 1px 7px 2px;
    font-size: 9px;
  }

  .unit .rest-badge {
    top: -1px;
    right: -1px;
    z-index: 82;
    padding: 1px 4px;
    font-size: 8px;
  }

  .unit-role-badges {
    top: -8px;
    right: -5px;
  }

  .attack-role-badge {
    min-width: 30px;
    padding: 2px 6px 3px;
    font-size: 9px;
  }

  .card {
    width: auto;
  }

  .hand .card,
  .cost .card {
    width: var(--compact-card-min-width);
  }

  .hand-zone,
  .cost-zone {
    position: relative;
    z-index: 1;
    padding-top: 5px;
    padding-bottom: 4px;
  }

  .cost-zone {
    grid-area: cost;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    border-top: 0;
    border-left: 1px solid rgba(255, 225, 154, 0.32);
    padding: 5px 4px;
    overflow: hidden;
  }

  .cost-zone > * {
    position: relative;
    z-index: 1;
  }

  .cost-zone .zone-title {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    place-items: center;
    font-size: 9px;
    line-height: 1;
  }

  .cost-zone .zone-title > span {
    display: none;
  }

  .cost-zone .zone-count {
    min-height: 16px;
    padding: 2px 4px;
    font-size: 9px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }

  .cost-payable-full {
    display: none;
  }

  .cost-payable-compact {
    display: inline;
  }

  .hand-zone {
    grid-area: hand;
    overflow: hidden;
  }

  @supports selector(.hand-zone:has(.card.selected)) {
    .player-panel:has(.hand .card.selected),
    .player-panel:has(.cost .card.selected) {
      overflow: visible;
      z-index: 72;
    }

    .hand-zone:has(.card.selected),
    .cost-zone:has(.card.selected) {
      overflow: visible;
      z-index: 74;
    }

    .hand-zone:has(.card.selected) .hand {
      overflow: visible;
    }

    .cost-zone:has(.card.selected) .cost {
      overflow-x: hidden;
      overflow-y: auto;
    }
  }

  .hand .card.selected,
  .cost .card.selected {
    z-index: 76;
    transform: translateY(-4px) scale(1.018);
  }

  .hand .card.selected {
    transform:
      translateY(calc((var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)) - 4px))
      rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
      scale(1.018);
  }

  .hand .card.selected .level-badge,
  .cost .card.selected .level-badge {
    z-index: 78;
  }

  .hand-zone .zone-title {
    display: none;
  }

  .mobile-selection-panel {
    display: none !important;
  }

  .mobile-selection-panel[hidden] {
    display: none;
  }

  .mobile-selection-detail {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    min-height: 0;
    padding: 8px;
    border: 1px solid rgba(255, 225, 154, 0.46);
    border-radius: 7px;
    background:
      linear-gradient(90deg, rgba(255, 225, 154, 0.1), transparent 62%),
      rgba(12, 16, 14, 0.95);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.26),
      0 10px 28px rgba(0, 0, 0, 0.36);
    overflow: hidden;
  }

  .mobile-selection-detail .selection-art-card {
    width: 58px;
    min-width: 58px;
    border-radius: var(--compact-card-corner-radius);
  }

  .mobile-selection-text {
    display: block;
    min-width: 0;
    max-height: 100%;
    overflow: auto;
    color: #eee6cf;
    font-size: 10.5px;
    line-height: 1.32;
  }

  .mobile-selection-text strong,
  .mobile-selection-text span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-selection-text small {
    display: block;
    margin-top: 3px;
    overflow: visible;
    color: var(--muted);
    white-space: normal;
  }

  .mobile-selection-text strong {
    color: #fff2bc;
    font-size: 12px;
  }

  .mobile-selection-text .card-detail-attribute {
    display: inline;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .mobile-selection-text .card-detail-attribute-name {
    display: inline;
  }

  .mobile-selection-text .mobile-warrior-stats {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .selection-card-detail-body {
    display: block;
    margin-top: 3px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 3px;
    overflow: visible;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-trait {
    display: inline-flex;
    min-height: 0;
    gap: 1px;
    padding: 0 3px;
    overflow: visible;
    font-size: 9px;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-trait-name {
    display: inline;
    flex: 0 0 auto;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .mobile-selection-text .card-detail-trait-description {
    display: inline;
    overflow: visible;
    font-size: 8.5px;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-effect-segment {
    display: block;
    margin-top: 2px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-timing {
    display: inline-flex;
    width: auto;
    margin: 0 2px 0 0;
    padding: 0 3px;
    overflow: visible;
    font-size: 9px;
    line-height: 1.25;
    text-overflow: clip;
    white-space: normal;
  }

  .mobile-selection-text .card-detail-effect {
    display: inline;
    overflow: visible;
    color: var(--muted);
    font-size: 9px;
    text-overflow: clip;
    white-space: normal;
  }

  .hand,
  .cost {
    gap: 4px;
  }

  .cost {
    height: auto;
    min-height: 0;
    max-height: none;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px;
    scroll-snap-type: y proximity;
  }

  /* カード位置を保ち、選択で持ち上がるレベル表示の分だけスクロール上端を広げる。 */
  .app.mobile-fullscreen-layout .cost,
  .app.mobile-safari-layout .cost {
    margin-top: -4px;
    padding-top: 8px;
    scroll-padding-top: 8px;
  }

  .cost .card + .card {
    margin-left: 0;
    margin-top: calc(-1 * var(--cost-card-overlap-y-fit, var(--cost-card-overlap-y, 0px)));
  }

  .app.mobile-safari-layout .cost .card + .card {
    margin-top: calc(-1 * var(--cost-card-overlap-y-fit, var(--cost-card-overlap-y-safari, var(--cost-card-overlap-y, 0px))));
  }

  .cost .card {
    position: relative;
    z-index: 1;
    box-shadow:
      var(--shadow-card-polished),
      0 calc(5px + var(--cost-stack-shadow-y, 0px)) 10px rgba(0, 0, 0, 0.27),
      0 0 0 1px var(--card-edge-dark),
      inset 0 1px 0 var(--card-edge-light),
      inset 0 -18px 24px rgba(0, 0, 0, 0.22);
  }

  .cost .card.selected,
  .cost .card.tutorial-highlight {
    z-index: 4;
  }

  .hand {
    min-height: 0;
    height: 100%;
    max-height: none;
    align-items: center;
    padding: 3px;
    scroll-snap-type: x proximity;
  }

  .app.mobile-fullscreen-layout .hand-zone {
    padding-top: 1px;
    padding-bottom: 1px;
  }

  .app.mobile-fullscreen-layout .hand {
    padding-block: 1px;
  }

  .app.mobile-fullscreen-layout #player2 .hand {
    align-items: flex-start;
  }

  .app.mobile-fullscreen-layout #player2 .player-head {
    transform: translateY(-1px);
  }

  .app.mobile-fullscreen-layout #player2 .selection {
    transform: translateY(-3px);
  }

  .app.mobile-fullscreen-layout #player2 .hand-zone {
    transform: translateY(calc(-1 * clamp(5px, 0.7dvh, 6px)));
  }

  .app.mobile-fullscreen-layout #player2 .hand-zone,
  .app.mobile-fullscreen-layout #player1 .hand-zone,
  .app.mobile-safari-layout #player2 .hand-zone,
  .app.mobile-safari-layout #player1 .hand-zone {
    overflow: visible;
    z-index: 79;
  }

  .app.mobile-fullscreen-layout .hand,
  .app.mobile-safari-layout .hand {
    position: relative;
    z-index: 79;
    overflow: visible;
  }

  .app.mobile-fullscreen-layout .hand .card,
  .app.mobile-safari-layout .hand .card {
    z-index: 1;
  }

  .app.mobile-fullscreen-layout #player2 .hand .card,
  .app.mobile-safari-layout #player2 .hand .card {
    --hand-card-lift-direction: -1;
    --hand-card-rotate-direction: -1;
    transform-origin: 50% -18%;
  }

  .app.mobile-fullscreen-layout .hand .level-badge,
  .app.mobile-safari-layout .hand .level-badge {
    z-index: 3;
  }

  .app.mobile-fullscreen-layout .hand .card.selected,
  .app.mobile-fullscreen-layout .hand .card.tutorial-highlight,
  .app.mobile-safari-layout .hand .card.selected,
  .app.mobile-safari-layout .hand .card.tutorial-highlight {
    z-index: 4;
  }

  .app.mobile-fullscreen-layout .hand .card.selected .level-badge,
  .app.mobile-fullscreen-layout .hand .card.tutorial-highlight .level-badge,
  .app.mobile-safari-layout .hand .card.selected .level-badge,
  .app.mobile-safari-layout .hand .card.tutorial-highlight .level-badge {
    z-index: 5;
  }

  .app.mobile-fullscreen-layout #player1 .hand {
    align-items: flex-end;
    transform: translateY(clamp(2px, 0.35dvh, 3px));
  }

  /* Safariの可変高カードは操作ボタン側ではなく盤面側へ伸ばす。 */
  .app.mobile-safari-layout #player1 .hand {
    align-items: flex-end;
  }

  .hand .card,
  .hand > .empty {
    flex: 0 0 var(--mobile-zone-card-width);
    width: var(--mobile-zone-card-width);
    min-width: var(--mobile-zone-card-width);
    max-width: var(--mobile-zone-card-width);
    height: var(--mobile-zone-card-height);
    min-height: var(--mobile-zone-card-height);
    max-height: var(--mobile-zone-card-height);
    inline-size: var(--mobile-zone-card-width);
    min-inline-size: var(--mobile-zone-card-width);
    max-inline-size: var(--mobile-zone-card-width);
    block-size: var(--mobile-zone-card-height);
    min-block-size: var(--mobile-zone-card-height);
    max-block-size: var(--mobile-zone-card-height);
  }

  .cost .card,
  .cost > .empty {
    transform: none;
    flex: 0 0 var(--mobile-zone-card-height);
    inline-size: var(--mobile-zone-card-width);
    min-inline-size: var(--mobile-zone-card-width);
    max-inline-size: var(--mobile-zone-card-width);
    block-size: var(--mobile-zone-card-height);
    min-block-size: var(--mobile-zone-card-height);
    max-block-size: var(--mobile-zone-card-height);
    width: var(--mobile-zone-card-width);
    min-width: var(--mobile-zone-card-width);
    max-width: var(--mobile-zone-card-width);
    height: var(--mobile-zone-card-height);
    min-height: var(--mobile-zone-card-height);
    max-height: var(--mobile-zone-card-height);
  }

  .cost .face-down-label {
    display: none;
  }

  .hand .card,
  .cost .card,
  .hand > .empty,
  .cost > .empty {
    scroll-snap-align: start;
  }

  .hand .card .card-info,
  .cost .card .card-info {
    padding:
      var(--mobile-zone-card-info-pad-top)
      var(--mobile-zone-card-info-pad-x)
      var(--mobile-zone-card-info-pad-bottom);
    transform: translateY(2px);
  }

  .hand .card.triple-surface-name .card-info,
  .cost .card.triple-surface-name .card-info {
    transform: translateY(1px);
  }

  .app.mobile-fullscreen-layout .hand .card .card-info {
    transform: translateY(0);
  }

  .hand .name,
  .cost .name {
    min-height: 0;
    max-height: 3.45em;
    font-size: 7.6px;
    line-height: 1.15;
    -webkit-line-clamp: 3;
  }

  .hand .card.dense-surface-name .name,
  .cost .card.dense-surface-name .name {
    max-height: 3.3em;
    font-size: 7.2px;
    line-height: 1.1;
  }

  .hand .card.triple-surface-name .name,
  .cost .card.triple-surface-name .name {
    max-height: 3em;
    font-size: 7px;
    line-height: 1;
  }

  .hand .card.triple-surface-name .stat-line,
  .cost .card.triple-surface-name .stat-line {
    margin-top: 0;
    line-height: 1.02;
  }

  .hand .card.triple-surface-name .type-label,
  .cost .card.triple-surface-name .type-label {
    margin-bottom: 0;
    line-height: 1;
  }

  .hand .stat-line,
  .hand .tag-line,
  .hand .effect-line,
  .cost .stat-line,
  .cost .tag-line,
  .cost .effect-line {
    font-size: 7px;
    line-height: 1.12;
  }

  .hand .tag-line,
  .hand .effect-line,
  .cost .tag-line,
  .cost .effect-line {
    display: none;
  }

  .hand .card.type-special .effect-line,
  .cost .card.type-special .effect-line {
    display: -webkit-box;
    margin-top: 2px;
    color: #91eaa0;
    font-size: 6.8px;
    line-height: 1.08;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .hand .card.type-special.triple-surface-name .effect-line,
  .cost .card.type-special.triple-surface-name .effect-line {
    margin-top: 1px;
    line-height: 1.02;
  }

  .hand .stat-line,
  .cost .stat-line {
    margin-top: var(--mobile-zone-card-line-gap);
  }

  .hand .effect-line,
  .cost .effect-line {
    max-height: 30px;
    -webkit-line-clamp: 2;
  }

  .control-panel {
    display: contents;
    position: static;
    top: auto;
    align-self: start;
  }

  .control-panel:not(.has-pending-battle) {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: visible;
  }

  .control-panel:not(.has-pending-battle) .status,
  .control-panel:not(.has-pending-battle) .battle-panel,
  .control-panel:not(.has-pending-battle) .operation-hints,
  .control-panel .log-wrap {
    display: none;
  }

  .status {
    padding: 7px;
    border-radius: 7px;
    font-size: 12px;
    line-height: 1.35;
  }

  .selection {
    --card-detail-awaken-font-size: 10px;
    --compact-selection-art-width: 54px;
    --compact-selection-art-height: 76px;
    grid-area: selection;
    position: relative;
    z-index: 70;
    height: var(--mobile-selection-height);
    max-height: var(--mobile-selection-height);
    min-height: var(--mobile-selection-height);
    padding: 5px 6px;
    border: 1px solid color-mix(in srgb, var(--phase-accent-soft) 72%, #535b4a);
    border-radius: 7px;
    background:
      linear-gradient(180deg, rgba(18, 22, 18, 0.58), rgba(13, 16, 14, 0.44)),
      rgba(13, 16, 14, 0.36);
    backdrop-filter: blur(3px);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      0 8px 20px rgba(0, 0, 0, 0.3);
    font-size: 11px;
    overflow: auto;
  }

  .mobile-progress-tips {
    position: fixed;
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + 8px);
    right: auto;
    width: calc(var(--app-usable-width) - 16px);
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-notice-anchor-height) + 5px);
    z-index: 85;
    display: none;
    gap: 3px;
    padding: 6px 9px;
    border: 1px solid rgba(174, 231, 255, 0.46);
    border-radius: 7px;
    background: rgba(17, 24, 26, 0.97);
    color: #e8f8ff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.32;
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.28),
      0 10px 24px rgba(0, 0, 0, 0.36);
    pointer-events: none;
  }

  .mobile-progress-tips.is-warning {
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-notice-anchor-height) + var(--mobile-gap-xs));
    border-color: rgba(244, 199, 95, 0.62);
    background:
      linear-gradient(90deg, rgba(122, 78, 23, 0.46), rgba(24, 22, 18, 0.93) 58%),
      rgba(18, 19, 16, 0.96);
    color: #fff0bd;
    font-size: clamp(10.5px, 2.85dvw, 11.5px);
    line-height: 1.28;
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.3),
      0 0 16px rgba(244, 199, 95, 0.16),
      0 8px 22px rgba(0, 0, 0, 0.34);
  }

  .mobile-progress-tips.show {
    display: grid;
  }

  .mobile-progress-tips.has-rule-link {
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: center;
    column-gap: 2px;
    padding-right: 1px;
    pointer-events: auto;
  }

  .mobile-progress-tips .rule-context-link {
    width: 28px;
    min-width: 28px;
    min-height: 24px;
    padding: 1px;
    font-size: 10px;
  }

  .tutorial-guide {
    position: fixed;
    z-index: 180;
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-selection-height) + 5px);
    bottom: auto;
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset) + 2px);
    right: auto;
    width: calc(var(--mobile-layout-width) - 8px);
    grid-template-columns: 62px minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    height: 154px;
    min-height: 154px;
    max-height: 154px;
    padding: 0 7px 0 0;
    border-radius: 8px;
    transform: none;
    pointer-events: none;
  }

  .tutorial-guide.tutorial-guide-has-action {
    pointer-events: auto;
  }

  .tutorial-guide.tutorial-guide-complete {
    grid-template-rows: 154px 34px;
    height: 194px;
    min-height: 194px;
    max-height: 194px;
  }

  .tutorial-guide .tutorial-guide-portrait {
    pointer-events: auto;
  }

  .tutorial-guide-portrait {
    width: 76px;
    height: 114px;
    max-height: 114px;
    margin: 4px -10px 0 -5px;
  }

  .mobile-fullscreen-layout .tutorial-guide-portrait {
    margin-top: 10px;
  }

  .tutorial-guide-bubble {
    overflow-y: auto;
    max-height: 140px;
    padding: 8px 31px 8px 10px;
    border-radius: 7px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 52%),
      rgba(10, 13, 13, 0.76);
  }

  .tutorial-guide-complete .tutorial-guide-bubble {
    overflow-y: auto;
    max-height: 140px;
    padding-bottom: 8px;
  }

  .tutorial-guide-head {
    margin-bottom: 2px;
    font-size: 10.5px;
  }

  .tutorial-guide-bubble strong {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    font-size: 13px;
    line-height: 1.16;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: unset;
  }

  .tutorial-guide-bubble p {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.36;
  }

  .tutorial-guide-actions {
    margin-top: 5px;
  }

  .tutorial-guide-complete-actions {
    margin-top: 0;
  }

  .tutorial-guide-next-icon {
    right: 7px;
    bottom: 6px;
    width: 21px;
    height: 21px;
    font-size: 10px;
  }

  .tutorial-guide-next {
    min-width: 92px;
    min-height: 30px;
    padding: 4px 12px;
    font-size: 12px;
  }

  .mobile-progress-tips span {
    display: block;
  }

  .mobile-progress-warning-line {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .selection-none-desktop {
    display: none;
  }

  .selection-status-summary {
    display: block;
    min-height: 100%;
    padding: 2px 3px;
    border-radius: 0;
    background: transparent;
    color: #eee6cf;
    font-size: 12px;
    line-height: 1.45;
  }

  .selection-status-summary strong {
    color: #fff2bc;
    font-size: 13px;
  }

  .selection-status-summary .status-progress-badge {
    min-height: 17px;
    padding: 2px 6px;
    font-size: 10px;
    vertical-align: 1px;
  }

  .selection-detail {
    gap: 5px;
  }

  .selection-art-card {
    width: var(--compact-selection-art-width);
    min-width: var(--compact-selection-art-width);
    height: var(--compact-selection-art-height);
  }

  .selection-text {
    font-size: 10.5px;
    line-height: 1.28;
  }

  .selection-detail.selection-detail--compact {
    gap: 6px;
  }

  .selection-detail--compact .selection-art-card {
    height: min(var(--compact-selection-art-height), calc(var(--mobile-selection-height) - 12px));
  }

  .selection-detail--compact .selection-text {
    gap: 3px;
    font-size: 11px;
  }

  body.mobile-layout:not(.mobile-landscape-layout) .selection.selection--flexible-detail {
    height: var(--compact-detail-height);
    max-height: var(--compact-detail-height);
  }

  body.mobile-layout .selection.selection--flexible-detail .selection-text {
    max-height: none;
    overflow: visible;
  }

  /* 親全体を手前に出さず、伸びた説明だけを相手手札と戦闘パネルの上へ置く。 */
  body.mobile-layout .app #player2.has-expanded-compact-detail {
    z-index: auto;
    isolation: auto;
  }

  body.mobile-layout .app #player2.has-expanded-compact-detail .front-lane { z-index: 78; }
  body.mobile-layout .app #player2.has-expanded-compact-detail .back-lane { z-index: 71; }

  .selection-text .card-detail-warrior-mobile-separator {
    display: inline;
  }

  .selection-text .card-detail-warrior-stat-break {
    display: none;
  }

  /*
    戦闘アニメのカードはスクロール領域ではないため、Safariへタッチを
    引き渡さず長押しを優先する。横スクロールする候補カードは従来どおり。
  */
  body.mobile-layout [data-battle-visual-unit="true"] {
    touch-action: none;
  }

  /*
    詳細欄は相手パネル内へ移されているため、欄自身だけでなくアプリと親パネルも
    カードイラストモーダル相当の階層へ上げる。盤面外の手札操作UIも確実に覆う。
  */
  body.mobile-layout .app.card-text-hold-preview-active {
    z-index: 2000;
  }

  body.mobile-layout .app.card-text-hold-preview-active #player2.card-text-hold-preview-host {
    z-index: 2000;
    overflow: visible;
  }

  /*
    縦画面は局面を問わず、長押ししたカードだけ上部詳細欄から下側の
    操作ボタン直前まで重ねる。fixed化で既存グリッドを動かさず、解除時の位置ずれを防ぐ。
  */
  .selection.card-text-hold-preview {
    position: fixed;
    z-index: 2001;
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height));
    right: auto;
    bottom: auto;
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset));
    display: block;
    box-sizing: border-box;
    width: var(--mobile-layout-width);
    height: var(--mobile-card-text-preview-height);
    min-height: var(--mobile-card-text-preview-height);
    max-height: var(--mobile-card-text-preview-height);
    padding: 6px;
    overflow: hidden;
    border-color: var(--ui-active-border);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 34%),
      rgba(20, 24, 20, 0.97);
    backdrop-filter: blur(8px);
    box-shadow:
      0 0 0 1px rgba(224, 184, 78, 0.24),
      0 12px 28px rgba(0, 0, 0, 0.34);
    pointer-events: none;
  }

  .selection.card-text-hold-preview .selection-detail {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 6px;
    overflow: hidden;
    isolation: isolate;
  }

  .selection.card-text-hold-preview .selection-detail--formal {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    place-items: stretch center;
    padding: 0;
    overflow: hidden;
    border-radius: 0;
  }

  .selection.card-text-hold-preview .selection-detail--formal::after {
    content: none;
  }

  .selection.card-text-hold-preview .selection-detail--formal .selection-card-face-host {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    justify-self: stretch;
    align-items: center;
    justify-content: center;
  }

  .selection.card-text-hold-preview .selection-detail--formal .selection-card-face-host > .card-face {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    cursor: default;
  }

  .selection.card-text-hold-preview .selection-detail--formal .selection-current-state {
    display: grid;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.24;
  }

  .selection.card-text-hold-preview .selection-current-state__header {
    gap: 3px 6px;
  }

  .selection.card-text-hold-preview .selection-current-state__summary,
  .selection.card-text-hold-preview .selection-current-state__stats {
    gap: 3px 4px;
  }

  .selection.card-text-hold-preview .selection-current-state__level,
  .selection.card-text-hold-preview .selection-current-state__position,
  .selection.card-text-hold-preview .selection-current-state__activity,
  .selection.card-text-hold-preview .selection-current-state__hp {
    padding: 0.22em 0.48em;
  }

  .selection.card-text-hold-preview .selection-current-state__hp {
    min-width: 76px;
  }

  .selection.card-text-hold-preview .selection-detail:not(.selection-detail--formal)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
      linear-gradient(180deg, rgba(9, 12, 10, 0.02) 0 42%, rgba(9, 12, 10, 0.3) 70%, rgba(9, 12, 10, 0.7) 100%),
      linear-gradient(90deg, rgba(9, 12, 10, 0.16), transparent 16% 84%, rgba(9, 12, 10, 0.16));
    pointer-events: none;
  }

  .selection.card-text-hold-preview .selection-art-card {
    --warrior-portrait-position: center 24%;
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    min-width: 0;
    height: 100%;
    aspect-ratio: auto;
    border: 0;
    border-radius: inherit;
    background-position: center 24%;
    background-size: cover;
    box-shadow: none;
    opacity: 0.94;
  }

  .selection.card-text-hold-preview .selection-text {
    position: absolute;
    z-index: 2;
    right: 8px;
    bottom: 8px;
    left: 8px;
    box-sizing: border-box;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: 52%;
    margin: 0;
    padding: 10px 11px 11px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(239, 220, 163, 0.3);
    border-radius: 6px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 48%),
      rgba(12, 15, 13, 0.86);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      0 6px 18px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(5px);
    font-size: 12px;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
    scrollbar-gutter: stable;
  }

  /* クリック表示も長押し詳細と同じ領域・文字寸法を使い、閉じるまで保持する。 */
  body.mobile-layout .art-modal {
    inset: auto;
    top: var(--app-viewport-offset-top);
    left: var(--app-viewport-offset-left);
    width: var(--app-viewport-width);
    height: var(--app-viewport-height);
    place-items: start;
    padding: 0;
  }

  body.mobile-layout .art-modal-card {
    --card-detail-label-font-size: 11px;
    --card-detail-awaken-font-size: 10px;
    position: absolute;
    top: calc(var(--app-safe-top) + var(--mobile-player-head-height));
    left: calc(var(--app-safe-left) + var(--mobile-edge-inset));
    width: var(--mobile-layout-width);
    height: var(--mobile-card-text-preview-height);
    min-height: var(--mobile-card-text-preview-height);
    max-height: var(--mobile-card-text-preview-height);
    padding: 6px;
    border-radius: var(--card-corner-radius);
  }

  body.mobile-layout .art-modal-text {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-height: 52%;
    padding: 10px 11px 11px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
  }

  body.mobile-layout .art-modal-close {
    position: absolute;
    top: max(8px, var(--app-safe-top));
    right: max(8px, var(--app-safe-right));
  }

  .actions {
    grid-area: actions;
    order: 2;
    position: relative;
    z-index: 35;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(20px, 1fr);
    gap: 4px;
    padding: 4px 6px;
    margin: 0;
    height: var(--mobile-menu-height);
    min-height: var(--mobile-menu-height);
    max-height: var(--mobile-menu-height);
    align-content: stretch;
    border-top: 1px solid rgba(255, 225, 154, 0.08);
    background:
      linear-gradient(180deg, rgba(12, 14, 12, 0.12), rgba(12, 14, 12, 0.34)),
      transparent;
    backdrop-filter: none;
  }

  .actions.has-commander-shortcut,
  .actions.is-commander-choice-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .actions.is-commander-choice-actions .commander-select-action {
    grid-column: 1 / span 2;
  }

  .actions.is-commander-choice-actions .commander-action {
    grid-column: 3;
  }

  .control-panel.has-pending-battle .actions {
    margin-bottom: 0;
  }

  .control-panel.phase-finish.has-pending-battle .actions {
    z-index: 120;
    pointer-events: auto;
  }

  .control-panel.has-pending-battle .status {
    display: none;
  }

  .actions button {
    min-height: 24px;
    padding: 2px 8px;
    border-color: var(--phase-mobile-button-border);
    border-radius: 7px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 50%),
      linear-gradient(180deg, var(--phase-tint), transparent 56%),
      var(--phase-mobile-button-bg);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 2px 8px rgba(0, 0, 0, 0.22);
    color: #f6edd1;
    font-size: clamp(12.5px, 3.35dvw, 13px);
    line-height: 1.15;
  }

  .actions .commander-select-action,
  .actions .commander-designate-action {
    border-color: #f2c861;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 42%),
      linear-gradient(135deg, rgba(151, 103, 24, 0.98), rgba(75, 42, 25, 0.99));
    color: #fff5c7;
    box-shadow:
      inset 0 1px 0 rgba(255, 252, 218, 0.36),
      0 0 0 1px rgba(255, 213, 105, 0.22),
      0 0 14px rgba(255, 185, 54, 0.56),
      0 3px 9px rgba(0, 0, 0, 0.28);
  }

  .actions .commander-select-action:disabled {
    border-color: rgba(224, 178, 78, 0.62);
    box-shadow:
      inset 0 1px 0 rgba(255, 252, 218, 0.18),
      0 0 10px rgba(222, 153, 34, 0.22);
  }

  .actions .mobile-menu-start-action,
  .actions .mobile-menu-end-action {
    border-color: rgba(255, 225, 154, 0.42);
    color: #fff2c9;
    font-size: clamp(13.5px, 3.65dvw, 14px);
  }

  .actions button.mobile-menu-start-action:not(.commander-action):not(.commander-select-action):not(.attack-action):not(.cancel-cost-action):not(.cancel-position-action):not(.cancel-attack-action):not(:where(.action-start-battle-phase, .action-end-battle-phase, .action-end-turn)) {
    border-color: var(--phase-mobile-button-border);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 58%),
      var(--phase-mobile-start-bg);
    color: #fff7dc;
  }

  .actions button.mobile-menu-end-action:not(.commander-action):not(.commander-select-action):not(.attack-action):not(.cancel-cost-action):not(.cancel-position-action):not(.cancel-attack-action):not(:where(.action-start-battle-phase, .action-end-battle-phase, .action-end-turn)) {
    border-color: var(--phase-mobile-button-border);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 58%),
      var(--phase-mobile-end-bg);
    color: #fff1c2;
  }

  .operation-hints {
    display: none !important;
  }

  .mobile-utility-modal {
    --utility-modal-gutter: 8px;
    z-index: 220;
  }

  .mobile-utility-panel {
    width: 100%;
    max-height: var(--utility-modal-available-height);
    gap: 8px;
    padding: 10px;
    border-radius: 9px;
  }

  .mobile-utility-head h2 {
    font-size: 16px;
  }

  .mobile-utility-close {
    top: 8px;
    right: 8px;
    min-height: 36px;
    padding: 4px 8px;
    font-size: 11px;
  }

  .mobile-utility-body {
    min-height: 0;
    gap: 7px;
  }

  .mobile-options-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-options-body .match-autosave-option {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mobile-options-body .match-autosave-limit {
    grid-column: 1;
  }

  .mobile-options-body .match-autosave-option .toggle-option {
    grid-column: 2;
  }

  .mobile-options-body .match-autosave-select {
    grid-column: 1;
  }

  .mobile-options-body .option-section {
    gap: 6px;
    padding: 8px;
  }

  .option-duel-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .mobile-options-body .player-setup-group {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .mobile-options-body .player-setup-field {
    grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
  }

  .mobile-options-body .option-duel-grid .player-setup-group {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 5px;
    padding: 6px;
  }

  .mobile-options-body .option-duel-grid .player-setup-field {
    grid-column: 2;
    grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px;
  }

  .mobile-options-body .option-duel-grid .player-setup-title {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .mobile-options-body .option-duel-grid .player-setup-field + .player-setup-field {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .mobile-log-modal .log-wrap {
    max-height: none;
  }

  .mobile-log-modal .log {
    max-height: none;
  }

  .log-wrap {
    max-height: 138px;
    border-radius: 7px;
  }

  .log-head {
    padding: 5px 7px;
  }

  .log-wrap h2 {
    font-size: 12px;
  }

  .log-head button {
    min-height: 24px;
    padding: 3px 6px;
    font-size: 10px;
  }

  .log {
    max-height: 92px;
    padding: 6px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  .log li {
    padding: 5px 6px 5px 24px;
  }

  .log li::before {
    left: 6px;
    top: 5px;
    font-size: 9px;
    line-height: 1.35;
  }

  .actions .commander-action {
    grid-column: auto;
  }

  .special-stack-panel {
    position: relative;
    right: auto;
    bottom: auto;
    z-index: 1200;
    grid-area: special;
    width: auto;
    min-width: 0;
    height: var(--mobile-menu-height);
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    justify-items: center;
    align-items: center;
    align-content: center;
    gap: 2px;
    padding: 2px;
    border-top: 1px solid rgba(255, 225, 154, 0.14);
    border-left: 1px solid rgba(73, 80, 64, 0.72);
    background:
      linear-gradient(180deg, rgba(24, 28, 24, 0.72), rgba(17, 20, 18, 0.96)),
      rgba(17, 20, 18, 0.96);
    backdrop-filter: blur(5px);
  }

  .special-stack-panel.special-wait-temporary-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  body.mobile-safari-layout > .special-stack-panel {
    position: fixed;
    top: calc(var(--app-viewport-offset-top) + var(--app-viewport-height) - var(--app-safe-bottom) - var(--mobile-player-head-height) - var(--mobile-gap-xxs) - var(--mobile-menu-height));
    right: auto;
    bottom: auto;
    left: calc(var(--app-viewport-offset-left) + var(--app-viewport-width) - var(--app-safe-right) - var(--mobile-edge-inset) - var(--mobile-cost-column-width));
    z-index: 1300;
    width: var(--mobile-cost-column-width, clamp(63px, 15.9dvw, 64px));
    height: var(--mobile-menu-height, clamp(50px, 6.8dvh, 56px));
    pointer-events: none;
  }

  body.mobile-safari-layout > .special-stack-panel .special-wait-option {
    position: relative;
    z-index: 1301;
    pointer-events: auto;
  }

  .special-wait-option {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto auto;
    justify-self: center;
    align-self: center;
    justify-content: center;
    align-items: center;
    align-content: center;
    gap: 1px;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 2px 1px;
    border-radius: 7px;
    line-height: 1;
    white-space: nowrap;
  }

  .special-wait-option input {
    width: 1px;
    height: 1px;
  }

  .special-wait-label {
    font-size: 7px;
    line-height: 1;
  }

  .special-wait-state {
    min-width: 19px;
    padding: 1px 3px;
    font-size: 9px;
    line-height: 1;
  }

  .special-stack {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
    padding: 2px;
    border-radius: 7px;
    text-align: center;
    overflow-y: auto;
  }

  .special-stack-panel.special-stack-frozen {
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    padding: 2px;
    align-content: stretch;
    border-color: transparent;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    overflow: visible;
    pointer-events: none;
  }

  .special-stack-panel.special-stack-frozen .special-wait-option {
    align-self: center;
    min-height: 0;
    padding: 2px 0;
    pointer-events: auto;
  }

  .special-stack::before {
    content: none;
  }

  .special-stack > * {
    display: block;
  }

  .special-stack .stack-title {
    font-size: 7px;
    line-height: 1.15;
    font-weight: 900;
    white-space: nowrap;
  }

  .special-stack:not(.empty) .stack-title {
    display: none;
  }

  .special-stack .stack-name {
    font-size: 8px;
    line-height: 1.16;
    max-width: 100%;
    text-align: center;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .special-stack .stack-meta,
  .special-stack .stack-remove {
    font-size: 8px;
    line-height: 1.18;
    text-align: center;
  }

  .special-stack .stack-effect {
    display: none;
  }

  .special-stack.empty .stack-meta,
  .special-stack .stack-remove {
    display: none;
  }

  .phase-notice {
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-notice-anchor-height) + 8px);
    right: auto;
    bottom: auto;
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + 8px);
    width: calc(var(--app-usable-width) - 16px);
    z-index: 90;
  }

  .phase-card-with-art {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 10px;
  }

  .notice-card-art {
    width: 62px;
  }

  .notice-player-avatar {
    width: 62px;
  }

  /* Mobile choice prompts stay light; special-wait notices stay opaque because the battle panel itself fades. */
  .phase-notice.notice-general .phase-card {
    opacity: 0.72;
    background:
      linear-gradient(135deg, rgba(41, 35, 24, 0.54), rgba(19, 22, 18, 0.5));
    border-color: rgba(255, 224, 136, 0.58);
    box-shadow:
      0 0 0 1px rgba(255, 224, 136, 0.08),
      0 10px 24px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(1px);
  }

  .phase-notice.notice-commander .phase-card {
    opacity: 1;
    background:
      linear-gradient(135deg, rgba(41, 35, 24, 0.96), rgba(19, 22, 18, 0.96));
    border-color: rgba(255, 224, 136, 0.9);
    box-shadow:
      0 0 0 1px rgba(255, 224, 136, 0.14),
      0 18px 52px rgba(0, 0, 0, 0.42),
      0 0 24px rgba(255, 224, 136, 0.18);
    backdrop-filter: none;
  }

  .phase-notice.notice-general .phase-card,
  .phase-notice.notice-fall .phase-card {
    max-width: calc(100dvw - 16px);
    padding: 8px 10px;
  }

  /* 陥落通知は相手手札を隠さず、その直下のバトルゾーン側へ出す。 */
  .phase-notice.notice-fall {
    top: calc(
      var(--app-viewport-offset-top)
      + var(--app-safe-top)
      + var(--mobile-player-head-height)
      + var(--mobile-selection-height)
      + var(--mobile-hand-row-height)
      + 8px
    );
  }

  .phase-notice.notice-general .phase-card strong,
  .phase-notice.notice-fall .phase-card strong {
    font-size: clamp(16px, 4.5dvw, 20px);
    line-height: 1.15;
  }

  .phase-notice.notice-general .phase-card em,
  .phase-notice.notice-general .phase-card small,
  .phase-notice.notice-fall .phase-card em,
  .phase-notice.notice-fall .phase-card small {
    line-height: 1.22;
  }

  .phase-notice.notice-special-wait .phase-card {
    opacity: 1;
    background:
      linear-gradient(135deg, rgba(60, 49, 18, 0.92), rgba(25, 23, 18, 0.9));
    border-color: rgba(255, 224, 136, 0.78);
    box-shadow:
      0 0 0 1px rgba(255, 224, 136, 0.16),
      0 10px 24px rgba(0, 0, 0, 0.34),
      0 0 22px rgba(255, 224, 136, 0.12);
    backdrop-filter: blur(3px);
  }

  .nonbattle-special-wait-panel {
    position: absolute;
    z-index: 36;
    top: calc(var(--mobile-player-head-height) + var(--mobile-selection-height) + 8px);
    left: calc(var(--mobile-edge-inset) + 8px);
    right: calc(var(--mobile-edge-inset) + var(--mobile-cost-column-width) + 14px);
    pointer-events: auto;
  }

  /*
    Safariの非戦闘特殊選択は下側プレイヤーパネルを基準にすると画面下へ寄る。
    特殊ウェイト通知の直下へ固定し、相手側バトルゾーン上で選択できるようにする。
  */
  .app.mobile-fullscreen-layout .nonbattle-special-wait-panel,
  .app.mobile-safari-layout .nonbattle-special-wait-panel {
    position: fixed;
    z-index: 89;
    top: var(
      --nonbattle-special-wait-top,
      calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-notice-anchor-height) + 124px)
    );
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset) + 8px);
    right: auto;
    width: calc(var(--mobile-layout-width) - var(--mobile-cost-column-width) - 22px);
  }

  /* 計測前もSafariでは通知が縦に伸びる前提の安全な位置を使う。 */
  .app.mobile-safari-layout .nonbattle-special-wait-panel {
    top: var(
      --nonbattle-special-wait-top,
      calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-notice-anchor-height) + 136px)
    );
  }

  .app.mobile-fullscreen-layout .nonbattle-special-wait-panel .battle-special-wait-choice-panel,
  .app.mobile-safari-layout .nonbattle-special-wait-panel .battle-special-wait-choice-panel {
    max-height: min(
      156px,
      calc(var(--app-viewport-offset-top) + var(--app-viewport-height) - var(--app-safe-bottom) - var(--nonbattle-special-wait-top, 180px) - var(--mobile-menu-height) - 8px)
    );
  }

  .nonbattle-special-wait-panel .battle-special-wait-choice-panel {
    max-height: min(178px, calc(100% - 12px));
    background:
      linear-gradient(180deg, rgba(255, 231, 154, 0.14), transparent 42%),
      rgba(15, 13, 8, 0.82);
    backdrop-filter: blur(2px);
  }

  .nonbattle-special-wait-panel .battle-choice-section {
    max-height: 112px;
  }

  .nonbattle-special-wait-panel .battle-choice-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 104px;
    overflow-y: auto;
  }

  .tutorial-start-notice .game-start-copy {
    width: min(430px, calc(100dvw - 16px));
    padding: 10px 14px 14px;
  }

  .tutorial-start-notice .game-start-copy strong {
    max-width: 100%;
    font-size: clamp(34px, 10.5dvw, 52px);
    line-height: 1.04;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .tutorial-start-notice .game-start-copy em {
    max-width: 100%;
    font-size: clamp(14px, 4dvw, 18px);
    line-height: 1.22;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* スマホ縦画面は選択欄の直下へナビの頭位置を固定し、わずかな余白だけ残す。 */
@media (max-width: 620px) and (orientation: portrait) {
  body.mobile-layout .tutorial-guide {
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-player-head-height) + var(--mobile-selection-height) + 2px);
  }

  body.mobile-layout .tutorial-guide-portrait {
    position: static;
    grid-column: 1;
    grid-row: 1;
    margin: 2px -10px 0 -5px;
  }

  body.mobile-layout .tutorial-guide.tutorial-guide-complete {
    grid-template-rows: auto auto;
    align-content: start;
    row-gap: 6px;
    height: 154px;
    min-height: 154px;
    max-height: 154px;
  }

  body.mobile-layout .tutorial-guide-complete .tutorial-guide-portrait {
    grid-row: 1 / span 2;
  }

  body.mobile-layout .tutorial-guide-complete .tutorial-guide-bubble {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    margin-top: 4px;
  }

  body.mobile-layout .tutorial-guide-complete .tutorial-guide-complete-actions {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
  }
}

/*
  幅広iPhoneは小型端末向け上限で一部だけ拡大が止まらないよう、
  フル画面版とSafari版をそれぞれ同じ比率帯へ揃える。
*/
@media (min-width: 400px) and (max-width: 620px) and (orientation: portrait) {
  body.mobile-layout .app.mobile-fullscreen-layout {
    --compact-card-min-width: clamp(52px, 12.8dvw, 55px);
    --compact-row-height: clamp(88px, 10.1dvh, 94px);
    --mobile-zone-card-trim: clamp(11px, 1.45dvh, 14px);
    --mobile-zone-card-width: var(--compact-card-min-width);
    --mobile-zone-card-height: calc(var(--compact-row-height) - var(--mobile-zone-card-trim));
    --mobile-cost-column-width: clamp(65px, 16dvw, 69px);
    --mobile-lane-label-width: clamp(49px, 12.2dvw, 54px);
    --mobile-player-head-height: clamp(54px, 6.15dvh, 58px);
    --mobile-fullscreen-selection-height: clamp(96px, 11.7dvh, 110px);
    --mobile-menu-height: clamp(53px, 6.25dvh, 59px);
    --mobile-board-card-height-max: 112px;
    --mobile-board-card-height-limit:
      clamp(64px, calc(var(--app-usable-height) * 0.115), var(--mobile-board-card-height-max));
    --board-card-width:
      calc(var(--board-card-height) * var(--mobile-board-card-aspect-width) / var(--mobile-board-card-aspect-height));
  }

  body.mobile-layout .app.mobile-safari-layout {
    --compact-card-min-width: clamp(52px, 12.8dvw, 55px);
    --compact-row-height: clamp(56px, calc(var(--app-usable-height) * 0.1135), 88px);
    --mobile-zone-card-trim: clamp(10px, 1.45dvh, 13px);
    --mobile-zone-card-width: var(--compact-card-min-width);
    --mobile-zone-card-height: max(
      calc(var(--compact-row-height) - var(--mobile-zone-card-trim)),
      var(--mobile-safari-zone-card-height)
    );
    --mobile-cost-column-width: clamp(65px, 16dvw, 69px);
    --mobile-lane-label-width: clamp(49px, 12.2dvw, 54px);
    --mobile-player-head-height: clamp(51px, 7dvh, 54px);
    --mobile-safari-selection-base: clamp(76px, calc(var(--app-usable-height) * 0.127), 100px);
    --mobile-menu-height: clamp(51px, 7dvh, 54px);
    --mobile-safari-board-card-width:
      clamp(
        72px,
        min(19dvw, calc((var(--mobile-layout-width) - var(--mobile-cost-column-width) - 18px) / 4.05)),
        84px
      );
  }

  body.mobile-layout .player-head {
    grid-template-columns: 46px minmax(0, 1fr) auto;
  }

  body.mobile-layout .avatar-icon {
    width: 42px;
    height: 42px;
  }

  body.mobile-layout .player-name {
    font-size: 14px;
  }

  body.mobile-layout .player-flags {
    font-size: 10px;
  }

  body.mobile-layout .mobile-header-tool {
    width: 32px;
    min-width: 32px;
    height: 37px;
    min-height: 37px;
    font-size: 17px;
  }

  body.mobile-layout .hand .name,
  body.mobile-layout .cost .name {
    font-size: 8.2px;
  }

  body.mobile-layout .hand .stat-line,
  body.mobile-layout .cost .stat-line {
    font-size: 7.5px;
  }

  body.mobile-layout .selection-status-summary {
    font-size: 13px;
  }

  body.mobile-layout .selection-status-summary strong {
    font-size: 14px;
  }

  body.mobile-layout .actions button,
  body.mobile-layout .actions .mobile-menu-start-action,
  body.mobile-layout .actions .mobile-menu-end-action {
    font-size: 14.5px;
  }

  body.mobile-layout .tutorial-guide,
  body.mobile-layout .tutorial-guide.tutorial-guide-complete {
    height: 162px;
    min-height: 162px;
    max-height: 162px;
  }

  body.mobile-layout .tutorial-guide-portrait {
    width: 82px;
    height: 123px;
    max-height: 123px;
  }

  body.mobile-layout .tutorial-guide-bubble,
  body.mobile-layout .tutorial-guide-complete .tutorial-guide-bubble {
    max-height: 150px;
  }
}

/* 縦横で文字の倍率が急変しないよう、盤面の情報・通常操作は利用可能な短辺を基準にする。 */
@media (min-width: 621px) and (min-height: 501px) and (max-width: 1400px) and (max-height: 1400px) {
  body:is(.mobile-layout, .mobile-landscape-layout) {
    --tablet-hud-short-side: min(var(--app-usable-width), var(--app-usable-height));
    --tablet-hud-title-font: clamp(17px, calc(var(--tablet-hud-short-side) * 0.025), 26px);
    --tablet-hud-body-font: clamp(15px, calc(var(--tablet-hud-short-side) * 0.022), 23px);
    --tablet-hud-meta-font: clamp(12px, calc(var(--tablet-hud-short-side) * 0.018), 18px);
    --tablet-hud-small-font: clamp(11px, calc(var(--tablet-hud-short-side) * 0.014), 14px);
  }
}

/*
  タブレット縦画面は前衛・後衛を横へ並べ、4体分の横幅と残りの高さから
  カードを同じ比率で拡大する。ヘッダー・手札・操作欄の高さは先に確保する。
*/
@media (min-width: 621px) and (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  body.mobile-layout {
    --mobile-portrait-stage-width:
      calc(var(--app-usable-width) - 24px);
    --mobile-layout-width: var(--mobile-portrait-stage-width);
    --mobile-edge-inset:
      max(0px, calc((var(--app-usable-width) - var(--mobile-layout-width)) / 2));
    --tablet-portrait-avatar-size: clamp(42px, 5dvh, 70px);
    --tablet-portrait-selection-art-width: clamp(58px, 8dvh, 112px);
    --tablet-portrait-tutorial-font: clamp(14px, calc(var(--mobile-layout-width) * 0.02), 22px);
    --tablet-portrait-tutorial-height: max(196px, min(calc(var(--mobile-layout-width) * 0.25), calc(var(--app-usable-height) * 0.24)));
    --tablet-portrait-tutorial-action-height: max(42px, calc(var(--tablet-portrait-tutorial-font) * 2.4));
    --tablet-portrait-tutorial-complete-height:
      calc(var(--tablet-portrait-tutorial-height) + var(--tablet-portrait-tutorial-action-height) + 8px);
    --tablet-portrait-tutorial-width: clamp(96px, calc(var(--mobile-layout-width) * 0.14), 180px);
  }

  body.mobile-layout .app.mobile-fullscreen-layout {
    --mobile-battle-panel-inset: calc(var(--mobile-edge-inset) + 6px);
    --tablet-portrait-field-columns: 4;
    --compact-row-height: clamp(88px, calc(var(--app-usable-height) * 0.205 - 76px), 202px);
    --mobile-hand-row-height: var(--compact-row-height);
    --mobile-zone-card-trim: 12px;
    --compact-card-min-width: calc((var(--compact-row-height) - var(--mobile-zone-card-trim)) * var(--compact-card-aspect-width) / var(--compact-card-aspect-height));
    --mobile-zone-card-width: var(--compact-card-min-width);
    --mobile-zone-card-height: calc(var(--compact-row-height) - var(--mobile-zone-card-trim));
    --mobile-cost-column-width: calc(var(--mobile-zone-card-width) + 20px);
    --mobile-lane-label-width: clamp(58px, 5.5dvh, 74px);
    --mobile-player-head-height: clamp(48px, calc(var(--app-usable-height) * 0.06), 80px);
    --mobile-selection-height: clamp(104px, calc(var(--app-usable-height) * 0.13), 182px);
    /* 相手の手札に少し重ね、攻撃経路と対象候補を縦スクロールなしで選べる高さを取る。 */
    --mobile-battle-panel-top: calc(var(--mobile-player-head-height) + var(--mobile-battle-selection-height, var(--mobile-selection-height)) + var(--mobile-hand-row-height) * 0.35);
    --tablet-portrait-selection-art-width: min(clamp(58px, 8dvh, 112px), calc((var(--mobile-selection-height) - 18px) * 54 / 76));
    --mobile-menu-height: var(--mobile-player-head-height);
    --mobile-unit-name-font-size: calc((var(--board-card-width) - 16px) / 7);
    --mobile-unit-stat-font-size: clamp(12px, calc(var(--board-card-width) * 0.095), 22px);
    --mobile-unit-tiny-font-size: var(--mobile-unit-stat-font-size);
    --mobile-unit-level-badge-size: clamp(28px, calc(var(--board-card-width) * 0.21), 42px);
    --mobile-unit-level-badge-font-size: clamp(13px, calc(var(--board-card-width) * 0.095), 19px);
    --board-card-width:
      min(
        calc((var(--mobile-layout-width) - var(--mobile-cost-column-width) - 44px) / var(--tablet-portrait-field-columns)),
        calc((var(--mobile-field-row-height) * 2 - 42px) * var(--mobile-board-card-aspect-width) / var(--mobile-board-card-aspect-height))
      );
    --board-card-height: calc(var(--board-card-width) * var(--mobile-board-card-aspect-height) / var(--mobile-board-card-aspect-width));
  }

  body.mobile-layout .app.mobile-fullscreen-layout .table {
    /* カードが高さで頭打ちになった時は、配置数とコスト欄に必要な幅だけを中央に確保する。 */
    width: min(var(--mobile-layout-width), calc(var(--board-card-width) * var(--tablet-portrait-field-columns) + var(--mobile-cost-column-width) + 60px));
    margin-inline: auto;
  }

  body.mobile-layout .app.mobile-fullscreen-layout:has(.player-panel.board-front-heavy.board-back-heavy) {
    --tablet-portrait-field-columns: 6;
  }

  body.mobile-layout .app.mobile-fullscreen-layout .selection:not(.card-text-hold-preview) {
    --compact-selection-art-width: var(--tablet-portrait-selection-art-width);
  }

  body.mobile-layout .app.mobile-fullscreen-layout .player-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--mobile-cost-column-width);
  }

  body.mobile-layout .app.mobile-fullscreen-layout .player-panel.board-front-heavy {
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) var(--mobile-cost-column-width);
  }

  body.mobile-layout .app.mobile-fullscreen-layout .player-panel.board-back-heavy {
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) var(--mobile-cost-column-width);
  }

  body.mobile-layout .app.mobile-fullscreen-layout #player2.player-panel {
    grid-template-rows: var(--mobile-player-head-height) var(--mobile-selection-height) var(--mobile-hand-row-height) minmax(0, 1fr);
    grid-template-areas: "head head head" "selection selection selection" "hand hand cost" "front back cost";
  }

  body.mobile-layout .app.mobile-fullscreen-layout #player1.player-panel {
    grid-template-rows: minmax(0, 1fr) var(--mobile-hand-row-height) var(--mobile-menu-height) var(--mobile-player-head-height);
    grid-template-areas: "front back cost" "hand hand cost" "actions actions special" "head head head";
  }

  body.mobile-layout .app.mobile-fullscreen-layout .lane {
    grid-template-rows: 26px calc(var(--board-card-height) + 4px);
    align-content: safe center;
    padding: 4px;
  }

  body.mobile-layout .app.mobile-fullscreen-layout .lane-label {
    position: static;
    justify-self: start;
    height: 24px;
    font-size: 14px;
  }

  body.mobile-layout .app.mobile-fullscreen-layout .lane .unit-row {
    grid-template-columns: repeat(2, var(--board-card-width));
    column-gap: 6px;
  }

  /* 俯瞰の横並び配置では、通常スマホ縦の遠近補正と人数による中央寄せを使わない。 */
  body.mobile-layout .app.mobile-fullscreen-layout :is(#player1, #player2) .lane {
    transform: none;
  }

  body.mobile-layout .app.mobile-fullscreen-layout :is(#player1, #player2) .lane .unit-row {
    justify-content: start;
    align-content: start;
    align-items: start;
    padding: 1px 0;
    transform: none;
  }

  body.mobile-layout .app.mobile-fullscreen-layout .board-front-heavy .front-lane .unit-row,
  body.mobile-layout .app.mobile-fullscreen-layout .board-back-heavy .back-lane .unit-row {
    grid-template-columns: repeat(3, var(--board-card-width));
  }

  body.mobile-layout .app.mobile-fullscreen-layout .board-front-heavy .back-lane .unit-row,
  body.mobile-layout .app.mobile-fullscreen-layout .board-back-heavy .front-lane .unit-row {
    grid-template-columns: var(--board-card-width);
  }

  /* 前後とも3体いる時は、片側だけ広げる規則を重ねず3列ずつ確保する。 */
  body.mobile-layout .app.mobile-fullscreen-layout .player-panel.board-front-heavy.board-back-heavy {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--mobile-cost-column-width);
  }

  body.mobile-layout .app.mobile-fullscreen-layout .board-front-heavy.board-back-heavy .lane .unit-row {
    grid-template-columns: repeat(3, var(--board-card-width));
  }

  body.mobile-layout .app.mobile-fullscreen-layout .unit.has-card-art .card-info {
    width: 100%;
    margin-left: 0;
    padding-inline: 3px;
  }

  body.mobile-layout .app.mobile-fullscreen-layout .unit .name {
    width: 7em;
    max-width: 100%;
    min-height: 2.24em;
    max-height: 2.24em;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  body.mobile-layout:lang(en) .app.mobile-fullscreen-layout .unit .name {
    word-break: normal;
  }

  /*
    iPad Safariではfixed要素が中央ステージ基準になることがあり、画面側の余白を
    二重に加算してしまう。詳細欄は親の相手パネルへ絶対配置し、通常のgrid領域は外す。
  */
  body.mobile-layout
    .app.card-text-hold-preview-active
    .selection.card-text-hold-preview {
    position: absolute;
    grid-area: auto;
    top: var(--mobile-player-head-height);
    right: 0;
    left: 0;
    width: auto;
    transform: none;
  }

  body.mobile-layout .player-head {
    grid-template-columns: calc(var(--tablet-portrait-avatar-size) + 6px) minmax(0, 1fr) auto;
    --player-header-ornament-width: 28px;
    gap: 7px;
    padding-inline: var(--player-header-ornament-width);
  }

  body.mobile-layout .avatar-icon {
    width: var(--tablet-portrait-avatar-size);
    height: var(--tablet-portrait-avatar-size);
  }

  body.mobile-layout .player-name {
    font-size: var(--tablet-hud-title-font);
    line-height: 1.2;
  }

  body.mobile-layout .player-flags {
    font-size: var(--tablet-hud-meta-font);
    line-height: 1.25;
  }

  body.mobile-layout .player-surrender-button {
    font-size: var(--tablet-hud-small-font);
  }

  body.mobile-layout .player-state-badge,
  body.mobile-layout .fallen-badge {
    max-width: 74px;
    padding: 3px 7px;
    font-size: var(--tablet-hud-small-font);
  }

  body.mobile-layout .player-avatar .player-state-badge {
    max-width: 100%;
    padding: 2px 3px;
    font-size: 10px;
  }

  body.mobile-layout .pile-stats {
    --pile-stat-gap: 4px;
    grid-template-columns: 42px 62px repeat(2, 44px);
  }

  body.mobile-layout .mobile-header-tool {
    width: 40px;
    min-width: 40px;
    height: 46px;
    min-height: 46px;
    font-size: 20px;
  }

  body.mobile-layout .pile {
    min-width: 0;
    padding: 4px 6px;
  }

  body.mobile-layout .pile strong {
    font-size: 15px;
  }

  body.mobile-layout .pile-count-roll {
    height: 16.5px;
  }

  body.mobile-layout .pile span {
    font-size: 10.5px;
  }

  body.mobile-layout .life-pile {
    min-width: 0;
  }

  body.mobile-layout .life-icons {
    --life-icon-width: 12px;
    --life-icon-height: 17px;
    --life-icon-gap: 2px;
    height: 18px;
    min-height: 18px;
  }

  body.mobile-layout .life-icon {
    width: var(--life-icon-width);
    height: var(--life-icon-height);
  }

  body.mobile-layout .lane-label {
    min-width: 58px;
    font-size: 13px;
  }

  body.mobile-layout .unit {
    padding: var(--unit-frame-padding);
  }

  body.mobile-layout .unit .name {
    min-height: 19px;
  }

  body.mobile-layout .unit .hpbar {
    height: 8px;
    margin-top: 5px;
  }

  body.mobile-layout .hand .level-badge,
  body.mobile-layout .cost .level-badge {
    width: clamp(24px, calc(var(--mobile-zone-card-width) * 0.27), 36px);
    height: clamp(24px, calc(var(--mobile-zone-card-width) * 0.27), 36px);
    font-size: clamp(13px, calc(var(--mobile-zone-card-width) * 0.135), 18px);
  }

  body.mobile-layout .hand .name,
  body.mobile-layout .cost .name {
    font-size: clamp(12px, 1.1dvh, 15px);
  }

  body.mobile-layout .hand .card.dense-surface-name .name,
  body.mobile-layout .cost .card.dense-surface-name .name {
    font-size: clamp(11px, 1dvh, 14px);
  }

  body.mobile-layout .hand .card.triple-surface-name .name,
  body.mobile-layout .cost .card.triple-surface-name .name {
    font-size: clamp(10px, 0.95dvh, 13px);
  }

  body.mobile-layout .hand .stat-line,
  body.mobile-layout .cost .stat-line {
    font-size: clamp(11px, 1dvh, 14px);
  }

  body.mobile-layout .hand .card.type-special .effect-line,
  body.mobile-layout .cost .card.type-special .effect-line {
    font-size: clamp(10px, 0.95dvh, 13px);
  }

  body.mobile-layout .cost-zone .zone-title,
  body.mobile-layout .cost-zone .zone-count {
    font-size: 11px;
  }

  body.mobile-layout .cost-zone .zone-title {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  body.mobile-layout .cost-zone .zone-count {
    /* コスト列の寸法を変えず、その内幅に表示を収める。 */
    box-sizing: border-box;
    max-width: min(100%, calc(var(--mobile-cost-column-width) - 10px));
    min-height: 1.5em;
    padding: 0.15em 0.3em;
    font-size: clamp(11px, calc(var(--mobile-zone-card-width) * 0.14), 17px);
  }

  body.mobile-layout > .mobile-context-menu {
    font-size: clamp(13px, min(1.7dvw, 1.45dvh), 18px);
    gap: 0.3em;
    padding: 0.3em;
  }

  body.mobile-layout > .mobile-context-menu button {
    font-size: inherit;
    min-width: 3.8em;
    min-height: max(36px, 2.5em);
    padding: 0.45em 0.7em;
  }

  body.mobile-layout .selection {
    --compact-selection-art-width: var(--tablet-portrait-selection-art-width);
    --card-detail-awaken-font-size: clamp(12px, 1.2dvh, 16px);
    padding: 8px 9px;
    font-size: clamp(14px, 1.2dvh, 16px);
  }

  body.mobile-layout .selection-status-summary {
    padding: 4px 5px;
    font-size: var(--tablet-hud-body-font);
  }

  body.mobile-layout .selection-status-summary strong {
    font-size: var(--tablet-hud-title-font);
  }

  body.mobile-layout .selection-status-summary .status-progress-badge {
    min-height: 22px;
    padding: 3px 8px;
    font-size: min(var(--tablet-hud-body-font), 18px);
  }

  body.mobile-layout .selection-art-card {
    width: var(--tablet-portrait-selection-art-width);
    min-width: var(--tablet-portrait-selection-art-width);
    height: calc(var(--tablet-portrait-selection-art-width) * 1.4054);
  }

  body.mobile-layout .selection-text {
    font-size: clamp(16px, 1.5dvh, 20px);
    line-height: 1.34;
  }

  body.mobile-layout .selection-text .card-detail-trait {
    padding: 1px 4px;
    font-size: 1em;
  }

  body.mobile-layout .selection-text .card-detail-trait-description {
    font-size: 0.9em;
  }

  body.mobile-layout .selection-compact-meta {
    font-size: 0.95em;
  }

  body.mobile-layout .actions {
    gap: 6px;
    padding: 5px 8px;
  }

  body.mobile-layout .actions button,
  body.mobile-layout .actions .mobile-menu-start-action,
  body.mobile-layout .actions .mobile-menu-end-action {
    min-height: 34px;
    font-size: var(--tablet-hud-title-font);
  }

  body.mobile-layout .special-wait-label {
    min-width: 0;
    max-width: 100%;
    font-size: var(--tablet-hud-small-font);
    line-height: 1.2;
    white-space: normal;
    text-align: center;
  }

  body.mobile-layout .special-wait-state {
    min-width: 25px;
    font-size: var(--tablet-hud-meta-font);
    line-height: 1.2;
  }

  body.mobile-layout .tutorial-guide {
    font-size: var(--tablet-portrait-tutorial-font);
    grid-template-columns: var(--tablet-portrait-tutorial-width) minmax(0, 1fr);
    gap: 0.4em;
    height: var(--tablet-portrait-tutorial-height);
    min-height: var(--tablet-portrait-tutorial-height);
    max-height: var(--tablet-portrait-tutorial-height);
    padding-right: 0.45em;
  }

  body.mobile-layout .tutorial-guide.tutorial-guide-complete {
    grid-template-rows:
      var(--tablet-portrait-tutorial-height)
      var(--tablet-portrait-tutorial-action-height);
    height: var(--tablet-portrait-tutorial-complete-height);
    min-height: var(--tablet-portrait-tutorial-complete-height);
    max-height: var(--tablet-portrait-tutorial-complete-height);
  }

  body.mobile-layout .tutorial-guide-portrait {
    width: var(--tablet-portrait-tutorial-width);
    height: calc(var(--tablet-portrait-tutorial-width) * 1.5);
    max-height: calc(var(--tablet-portrait-tutorial-width) * 1.5);
    margin: 8px -12px 0 -6px;
  }

  body.mobile-layout .tutorial-guide-bubble,
  body.mobile-layout .tutorial-guide-complete .tutorial-guide-bubble {
    max-height: calc(var(--tablet-portrait-tutorial-height) - 14px);
    padding: 0.55em 3em 0.55em 0.65em;
  }

  body.mobile-layout .tutorial-guide-head {
    font-size: 0.82em;
  }

  body.mobile-layout .tutorial-guide-bubble strong {
    font-size: 1.14em;
  }

  body.mobile-layout .tutorial-guide-bubble p {
    font-size: 1em;
  }

  body.mobile-layout .tutorial-guide-next {
    min-width: 6em;
    min-height: 2.4em;
    font-size: 1em;
  }

  body.mobile-layout .tutorial-guide-next-icon {
    width: max(36px, 2.2em);
    height: max(36px, 2.2em);
    font-size: 1em;
  }

  body.mobile-layout .mobile-progress-tips,
  body.mobile-layout .phase-notice {
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-edge-inset) + 8px);
    right: auto;
    width: calc(var(--mobile-layout-width) - 16px);
  }
}

/*
  iOSの文字キーボードはvisualViewportだけを横長にし、CSSのorientation判定まで
  landscapeへ変えることがある。端末向きから付けたmobile-layoutを優先し、
  初回名前入力だけは縦画面構成を維持する。
*/
@media (max-width: 1100px) {
  body.mobile-layout .title-screen.first-launch-opening-open {
    grid-template-columns: minmax(0, 1fr);
    align-content: stretch;
    justify-items: stretch;
    width: 100dvw;
    max-width: 100dvw;
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.mobile-layout .title-screen.first-launch-opening-open.first-launch-name-editing {
    top: var(--mobile-viewport-offset-top, 0px);
    left: var(--mobile-viewport-offset-left, 0px);
    right: auto;
    bottom: auto;
    width: var(--mobile-viewport-width, 100dvw);
    height: var(--mobile-viewport-height, 100dvh);
    overflow: hidden;
  }

  body.mobile-layout .first-launch-opening.is-name-editing {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: start;
    align-self: start;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: calc(
      var(--mobile-viewport-height, 100dvh)
      - max(16px, env(safe-area-inset-top))
      - max(16px, env(safe-area-inset-bottom))
    );
    min-height: 0;
    max-height: 100%;
    border-radius: 10px;
    overflow: hidden;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-portrait-wrap {
    display: none;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-dialog {
    align-self: stretch;
    align-content: start;
    width: auto;
    min-width: 0;
    max-width: calc(100% - 12px);
    min-height: 0;
    max-height: 100%;
    margin: 0 6px 8px;
    padding: 17px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-wrap: anywhere;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-dialog h2 {
    font-size: clamp(20px, 6.5vw, 27px);
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-content {
    margin-top: 13px;
    font-size: 14px;
    line-height: 1.6;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-name-field {
    margin-top: 12px;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-name-field input {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-actions {
    min-width: 0;
    margin-top: 16px;
  }

  body.mobile-layout .first-launch-opening.is-name-editing .first-launch-action {
    min-height: 46px;
    font-size: 13px;
  }
}

/*
  iPad縦の初回案内はスマホ用の全幅配置を引き伸ばさず、中央の読みやすい幅に収める。
  ナビ側には画面高を使い、入力時は縮んだvisualViewport内で本文だけをスクロールする。
*/
@media (min-width: 621px) and (max-width: 1100px) and (orientation: portrait) {
  body.mobile-layout .title-screen.first-launch-opening-open {
    place-items: center;
    align-content: center;
    padding:
      max(20px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .first-launch-opening:not(.is-name-editing) {
    grid-template-rows: clamp(360px, 38dvh, 480px) auto;
    align-self: center;
    width: min(780px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
    min-height: 0;
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 40px);
    border-radius: 16px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-portrait-wrap {
    min-height: 0;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-portrait {
    bottom: -62px;
    width: min(520px, 72dvw);
    height: calc(100% + 76px);
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-dialog {
    justify-self: center;
    width: min(680px, calc(100% - 48px));
    max-width: min(680px, calc(100% - 48px));
    margin: 0 auto clamp(18px, 2dvh, 26px);
    padding: clamp(24px, 2.4dvh, 32px);
    border-radius: 13px;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-kicker {
    font-size: 13px;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-dialog h2 {
    font-size: clamp(28px, 2.6dvh, 34px);
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-content {
    margin-top: 17px;
    font-size: clamp(16px, 1.45dvh, 18px);
    line-height: 1.68;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-actions {
    justify-self: center;
    width: min(520px, 100%);
    max-width: 520px;
    gap: 12px;
    margin-top: 21px;
  }

  body.mobile-layout .title-screen.first-launch-opening-open .first-launch-action {
    min-height: 50px;
    font-size: clamp(16px, 1.4dvh, 18px);
  }

  body.mobile-layout .title-screen.first-launch-opening-open.first-launch-name-editing {
    place-items: center;
    align-content: center;
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .first-launch-opening.is-name-editing {
    align-self: center;
    width: min(680px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
    height: min(680px, calc(var(--mobile-viewport-height, 100dvh) - 40px));
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 40px);
    border-radius: 16px;
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .first-launch-opening.is-name-editing .first-launch-dialog {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: clamp(24px, 2.4dvh, 32px);
  }

  body.mobile-layout .title-screen.title-match-setup-open {
    justify-items: center;
  }

  body.mobile-layout .title-screen.title-match-setup-open :is(.player-match-setup:not(.is-trade-mode), .player-communication) {
    --player-match-character-icon-size: clamp(96px, 12dvw, 128px);
    --tablet-match-setup-card-width: clamp(140px, 20dvw, 210px);
    width: min(1000px, calc(var(--app-usable-width) - 40px));
  }

  /* 縦の交換画面は候補一覧に合わせた既存の幅・人物サイズを保つ。 */
  body.mobile-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode {
    --player-match-character-icon-size: clamp(88px, 11dvw, 116px);
    width: min(920px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode .player-match-trade-opponent-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode :is(.player-match-trade-candidates, .player-match-trade-empty) {
    --trade-candidate-width: clamp(132px, calc((100cqw - 30px) / 4.5), 190px);
    height: calc(var(--trade-candidate-width) + 72px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode .player-match-trade-candidate > strong {
    min-height: 2.5em;
    padding: 6px 4px;
    font-size: clamp(13px, 1.5dvw, 16px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode :is(.player-match-trade-empty span, .player-match-trade-candidate-note, .player-match-opponent-wins, .player-match-start-summary) {
    font-size: clamp(12px, 1.4dvw, 15px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode :is(.player-match-setup-deck-link, .player-match-setup-trade, .player-match-trade-empty strong) {
    font-size: clamp(14px, 1.6dvw, 17px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode .player-match-setup-trade {
    width: auto;
    min-width: 120px;
    min-height: 44px;
    padding-inline: 10px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode .player-match-opponents {
    container-type: size;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup.is-trade-mode .player-match-trade-detail-card {
    width: min(100%, clamp(320px, calc((100cqh - 112px) * 2 / 3), 520px));
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup, .player-shop, .player-communication) .player-match-setup-header h2 {
    font-size: clamp(17px, 2dvw, 20px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup, .player-communication) .player-match-section-head h3 {
    font-size: clamp(15px, 1.65dvw, 17px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) .player-match-setup-card {
    width: min(100%, var(--tablet-match-setup-card-width));
    height: auto;
    max-height: none;
    aspect-ratio: 118 / 150;
  }

  /* 900px境界の旧480px上限を外し、先鋒・ライフも画面幅へ連続して追従させる。 */
  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) .player-match-setup-cards {
    max-width: none;
    gap: clamp(8px, 1.2dvw, 14px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) .player-match-setup-card-name {
    font-size: clamp(13px, 1.7dvw, 18px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) .player-match-setup-card-role {
    font-size: clamp(11px, 1.3dvw, 14px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-opponent {
    min-height: clamp(150px, 18dvw, 184px);
    gap: 8px;
    font-size: clamp(14px, 1.6dvw, 17px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-opponent-name {
    font-size: clamp(14px, 1.6dvw, 17px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-group-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-final-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode)
    :is(
      .player-match-opponent-group-level4,
      .player-match-opponent-group-self,
      .player-match-opponent-group-random
    ) .player-match-opponent-group-list {
    grid-template-columns: minmax(0, 1fr);
  }

  /* カードだけでなく、選択欄と勝利数・解放条件もタブレットで読める大きさにする。 */
  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup, .player-shop, .player-communication):not(.is-trade-mode) .player-match-setup-header h2 {
    font-size: clamp(21px, 2.4dvw, 26px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup, .player-communication):not(.is-trade-mode) .player-match-section-head h3 {
    font-size: clamp(18px, 2dvw, 22px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) :is(.player-match-setup-header p, .player-match-section-head p, .player-match-opponent-wins, .player-match-opponent-unlock, .player-match-deck-character small, .player-match-setup-deck-link small, .player-match-setup-trade small),
  body.mobile-layout .title-screen.title-match-setup-open
    .player-communication .player-match-section-head p {
    font-size: clamp(12px, 1.3dvw, 14px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-group h4::before {
    font-size: 12px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) :is(.player-match-deck-select-wrap, .player-match-deck-character, .player-match-setup-footer p, .player-match-setup-deck-link, .player-match-extra-button, .player-match-setup-trade) {
    font-size: clamp(14px, 1.5dvw, 16px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    :is(.player-match-setup:not(.is-trade-mode), .player-communication) .player-match-deck-select-wrap select {
    min-height: 44px;
    font-size: 16px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) :is(.player-match-extra-button, .player-match-setup-trade) {
    width: auto;
    min-width: 120px;
    min-height: 44px;
    padding-inline: 10px;
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent {
    min-height: clamp(166px, 19.5dvw, 208px);
  }

  body.mobile-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-name {
    font-size: clamp(16px, 1.8dvw, 20px);
  }
}

/* 横画面共通レイアウト開始 */

/*
  横画面は実寸の3列を維持しながら、PC版より一段階だけ情報密度を上げる。
  transformやzoomはタップ座標をずらすため使わず、各要素の実寸を縮める。
*/
body.mobile-landscape-layout .title-screen {
  --landscape-menu-text-xs: clamp(9px, 2.2dvh, 10px);
  --landscape-menu-text-sm: clamp(10px, 2.5dvh, 11px);
  --landscape-menu-text-md: clamp(11px, 2.8dvh, 12px);
  --landscape-menu-text-lg: clamp(13px, 3.2dvh, 15px);
  --landscape-menu-text-xl: clamp(16px, 4dvh, 18px);
  top: var(--app-viewport-offset-top, 0px);
  left: var(--app-viewport-offset-left, 0px);
  right: auto;
  bottom: auto;
  width: var(--app-viewport-width, 100dvw);
  height: var(--app-viewport-height, 100dvh);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) {
  grid-template-columns: minmax(0, 1fr) minmax(350px, 52vw);
  gap: clamp(10px, 2vw, 22px);
  padding:
    max(clamp(10px, 2.4vw, 22px), env(safe-area-inset-top))
    max(clamp(10px, 2.4vw, 22px), env(safe-area-inset-right))
    max(clamp(10px, 2.4vw, 22px), env(safe-area-inset-bottom))
    max(clamp(10px, 2.4vw, 22px), env(safe-area-inset-left));
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-visual {
  min-height: 0;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-logo-art {
  width: min(34vw, 340px);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-panel {
  gap: 12px;
  width: min(480px, 100%);
  max-height: 100%;
  padding: clamp(16px, 2vw, 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-panel-stack {
  gap: 4px;
  width: min(480px, 100%);
  max-height: 100%;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-kicker {
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-actions {
  gap: 8px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-action {
  min-height: 46px;
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-load {
  gap: 6px;
  min-height: 38px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-load-head {
  gap: 6px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-load-head strong {
  font-size: var(--landscape-menu-text-lg);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-load-bar {
  height: 6px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-audio-note {
  gap: 6px;
  margin-top: -2px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-audio-toggle {
  min-width: 70px;
  min-height: 34px;
  padding: 4px 9px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-data-manager-button {
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  min-height: 34px;
  padding: 5px 11px;
  font-size: 12px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-public-beta-link {
  justify-self: end;
  margin: 0 4px;
  padding: 0 4px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-menu {
  gap: 8px;
  padding: 10px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-menu-head,
body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-list {
  gap: 6px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section {
  gap: 4px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section + .title-tutorial-section {
  padding-top: 6px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section-list {
  gap: 6px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section-head {
  gap: 6px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section-head strong {
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section-kicker,
body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-section-description {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-kicker,
body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-next {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-menu h2 {
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-copy strong {
  font-size: var(--landscape-menu-text-lg);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-copy span {
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) :is(.title-tutorial-back, .title-tutorial-rulebook) {
  min-height: 36px;
  padding: 5px 10px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-item {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 52px;
  gap: 7px;
  padding: 6px 8px;
}

body.mobile-landscape-layout .title-screen:not(.title-match-setup-open) .title-tutorial-number {
  width: 32px;
  height: 32px;
  font-size: var(--landscape-menu-text-lg);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  padding:
    max(5px, env(safe-area-inset-top))
    max(7px, env(safe-area-inset-right))
    max(5px, env(safe-area-inset-bottom))
    max(7px, env(safe-area-inset-left));
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-opening {
  grid-template-columns: minmax(165px, 0.62fr) minmax(360px, 1.38fr);
  width: min(880px, 100%);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  border-radius: 8px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-portrait-wrap {
  min-height: 0;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-portrait {
  bottom: -7%;
  width: min(375px, 180%);
  height: 114%;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-dialog {
  min-height: 0;
  max-height: calc(var(--mobile-viewport-height, 100dvh) - 22px);
  margin: 7px;
  padding: clamp(12px, 2.4dvh, 18px) clamp(15px, 2vw, 22px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-height: 620px) {
  /* ナビの列幅・縮尺は保ち、会話欄とボタンだけ横へ伸びすぎないようにする。 */
  body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-dialog {
    justify-self: start;
    width: calc(100% - 14px);
    max-width: 480px;
  }
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-kicker {
  margin-bottom: 3px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-dialog h2 {
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-content {
  margin-top: 9px;
  font-size: var(--landscape-menu-text-md);
  line-height: 1.5;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-name-field {
  gap: 3px;
  margin-top: 8px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-name-field input {
  min-height: 36px;
  padding: 5px 8px;
  /* フォーカス前から16pxを確保し、iOS Safariの入力時自動拡大を防ぐ。 */
  font-size: 16px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-character-list {
  gap: 7px;
  margin-top: 8px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-character {
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 52px;
  gap: 6px;
  padding: 5px 7px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-character img {
  width: 42px;
  height: 42px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-field-note {
  margin-top: 4px !important;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-summary {
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-summary img {
  width: 48px;
  height: 48px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-summary strong {
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-actions {
  gap: 7px;
  margin-top: 10px;
}

body.mobile-landscape-layout .title-screen.first-launch-opening-open .first-launch-action {
  min-height: 38px;
  font-size: var(--landscape-menu-text-md);
}

/*
  横向きの名前入力はナビを隠し、入力欄と決定ボタンを横に並べる。
  外枠が差し引いた余白を再度引かず、キーボード上の実表示領域を使う。
*/
.title-screen.first-launch-opening-open.first-launch-name-editing.first-launch-name-editing-landscape {
  align-content: stretch;
  align-items: stretch;
  justify-items: stretch;
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  overflow: hidden;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: start;
  align-self: start;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  border-radius: 10px;
  overflow: hidden;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-portrait-wrap {
  display: none;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-dialog {
  align-self: stretch;
  align-content: start;
  justify-self: center;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  width: calc(100% - 12px);
  min-width: 0;
  max-width: 480px;
  min-height: 0;
  max-height: 100%;
  margin: 0 6px 8px;
  padding: 8px 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
}

/* 入力中は名前の見出しを残し、説明の重複を省いてキーボード上に収める。 */
.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-kicker,
.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-content > p:first-child {
  display: none;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-dialog h2 {
  grid-column: 1 / -1;
  font-size: var(--landscape-menu-text-xl, 18px);
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-content {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  margin-top: 0;
  font-size: var(--landscape-menu-text-lg, 15px);
  line-height: 1.6;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-name-field {
  margin-top: 0;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-name-field input {
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  font-size: 16px;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-actions {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  min-width: 0;
  margin-top: 22px;
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-action {
  min-height: 46px;
  font-size: var(--landscape-menu-text-lg, 15px);
}

.title-screen.first-launch-opening-open .first-launch-opening.is-name-editing.is-landscape-name-editing .first-launch-error {
  grid-column: 1 / -1;
  margin: 0;
}

body.mobile-landscape-layout .navi-hint {
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  grid-template-columns: 48px minmax(0, 1fr) auto;
  width: min(430px, calc(100% - 16px));
  padding: 7px;
}

body.mobile-landscape-layout .navi-hint img {
  width: 48px;
  height: 48px;
}

body.mobile-landscape-layout .navi-hint p {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .navi-hint-placement-bottom-left {
  right: auto;
  left: max(8px, env(safe-area-inset-left));
}

body.mobile-landscape-layout .navi-hint-placement-top-right {
  top: max(8px, env(safe-area-inset-top));
  bottom: auto;
}

body.mobile-landscape-layout .navi-hint-placement-top-left {
  top: max(8px, env(safe-area-inset-top));
  right: auto;
  bottom: auto;
  left: max(8px, env(safe-area-inset-left));
}

/*
  スマホ横画面の対戦準備はPC型の左右2列を保ちつつ、実表示領域を使い切る。
  Safari/PWAの種別では分けず、visualViewportから付く共通classだけを使う。
*/
body.mobile-landscape-layout .title-screen.title-match-setup-open {
  align-items: stretch;
  padding:
    max(3px, env(safe-area-inset-top))
    max(4px, env(safe-area-inset-right))
    max(3px, env(safe-area-inset-bottom))
    max(4px, env(safe-area-inset-left));
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup {
  --player-match-character-icon-size: clamp(44px, 13.5dvh, 58px);
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  border-radius: 7px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-header {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 48px;
  padding: 4px 10px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-header p {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-header h2 {
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-back,
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-options {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-actions {
  gap: 4px;
}

body.mobile-landscape-layout .title-screen .player-trade-screen {
  inset: max(3px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  width: auto;
  height: auto;
  max-height: none;
  border-radius: 7px;
}

body.mobile-landscape-layout .title-screen .player-trade-header {
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  min-height: 48px;
  padding: 4px 10px;
}

body.mobile-landscape-layout .title-screen .player-trade-header h2 {
  font-size: var(--landscape-menu-text-xl);
}

body.mobile-landscape-layout .title-screen .player-trade-body {
  padding: 8px 10px;
}

body.mobile-landscape-layout .title-screen .player-trade-opponent-grid,
body.mobile-landscape-layout .title-screen .player-trade-target-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.mobile-landscape-layout .title-screen .player-trade-offer-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.mobile-landscape-layout .title-screen .player-trade-opponent {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 54px;
  padding: 5px 10px 5px 5px;
}

body.mobile-landscape-layout .title-screen .player-trade-opponent img {
  width: 44px;
  height: 44px;
}

body.mobile-landscape-layout .title-screen .player-trade-intro,
body.mobile-landscape-layout .title-screen .player-trade-target-head,
body.mobile-landscape-layout .title-screen .player-trade-receive-summary {
  margin-bottom: 8px;
  padding: 7px 10px;
}

body.mobile-landscape-layout .title-screen .player-trade-confirm-cards {
  grid-template-columns: minmax(0, 210px) 34px minmax(0, 210px);
  gap: 8px;
}

body.mobile-landscape-layout .title-screen .player-trade-confirm-face {
  --trade-confirm-card-max-width: 180px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-deck-link {
  min-height: 40px;
  padding: 6px 11px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-body {
  grid-template-columns: minmax(190px, 0.9fr) minmax(0, 1.25fr);
  min-height: 0;
  overflow: hidden;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-loadout,
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponents {
  min-height: 0;
  padding: 7px 10px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-loadout {
  border-right: 1px solid rgba(242, 219, 157, 0.16);
  border-bottom: 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-section-head {
  gap: 6px;
  margin-bottom: 6px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-section-head p {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-section-head h3 {
  font-size: var(--landscape-menu-text-lg);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-extra-button,
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-trade {
  width: 70px;
  min-width: 70px;
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 7px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-extra-button {
  font-size: var(--landscape-menu-text-xs);
  letter-spacing: 0.04em;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-trade {
  padding-inline: 4px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-trade small {
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-meta {
  min-height: 22px;
  padding: 2px 7px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-select-wrap {
  gap: 6px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-select-wrap select {
  min-height: 36px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-preview {
  grid-template-columns: calc(var(--player-match-character-icon-size) + 2px) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 0;
  margin-top: 6px;
  padding: 6px 0 3px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode .player-match-deck-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  min-height: 0;
  margin-top: 0;
  padding-top: 2px;
  overflow: visible;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode .player-match-loadout {
  padding-top: 3px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode .player-match-loadout > .player-match-section-head {
  gap: 2px;
  margin-bottom: 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode .player-match-deck-status {
  min-height: 20px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup.is-trade-mode .player-match-deck-meta {
  min-height: 20px;
  padding-block: 1px;
}

body.mobile-layout:not(.mobile-landscape-layout) .title-screen.title-match-setup-open:has(.player-match-setup.is-trade-mode) {
  overflow: clip;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode {
  min-height: 0;
  overflow: clip;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-setup-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: clip;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-loadout {
  padding: 0;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-opponents {
  /* 候補カードまでは固定し、相手一覧・詳細だけをスクロールする。 */
  min-height: 0;
  overflow: auto;
  overscroll-behavior-y: contain;
}

@media (max-width: 620px) {
  body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-opponents > .player-match-section-head {
    /* 詳細の所持枚数が増えても、戻るボタンの上端を揃える。 */
    align-items: start;
  }
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-loadout > .player-match-section-head {
  margin: 0;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(142, 216, 211, 0.2);
  background: #101d1b;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-deck-preview {
  container-type: inline-size;
  margin: 0 12px;
  padding-top: 8px;
  border-top: 0;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode :is(.player-match-trade-candidates, .player-match-trade-empty) {
  --trade-candidate-width: clamp(70px, calc((100cqw - 20px) / 3.7), 120px);
  height: calc(var(--trade-candidate-width) + 64px);
  min-height: 0;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-trade-candidates {
  /* 次の候補が少し見える1段表示にし、横へ送れることを伝える。 */
  grid-auto-flow: column;
  grid-auto-columns: var(--trade-candidate-width);
  grid-template-columns: none;
  grid-template-rows: minmax(0, 1fr);
  gap: 5px;
  padding: 4px 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-trade-candidates::-webkit-scrollbar {
  display: none;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-trade-empty {
  align-content: center;
  padding: 8px;
}

@media (max-width: 620px) {
  body.mobile-layout:not(.mobile-landscape-layout) .player-match-setup.is-trade-mode .player-match-loadout {
    /* 最小高さではなく枠の高さを固定し、相手欄の上端を一致させる。 */
    height: var(--match-loadout-height, auto);
    min-height: 0;
  }
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-candidate-note {
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-candidates {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-candidate > strong {
  min-height: calc(2.4em + 6px);
  padding: 3px 2px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-opponent-grid {
  grid-template-columns: repeat(5, minmax(46px, 1fr));
  gap: 4px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-opponent {
  min-height: 104px;
  gap: 4px;
  padding: 6px 2px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-detail {
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  min-height: 0;
  padding: 0 36px 2px 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-detail-card {
  --trade-detail-nav-width: 34px;
  --trade-detail-nav-gap: 4px;
  width: min(100%, 270px);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-detail-nav {
  display: grid;
  height: 46px;
  font-size: 18px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-detail-nav[hidden] {
  display: none;
}

body.mobile-layout:not(.mobile-landscape-layout) .player-match-trade-detail-nav {
  display: none;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-trade-card-meta {
  min-height: 20px;
  margin-top: 5px;
  padding: 2px 7px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-setup.has-trade-card-detail .player-match-opponents {
  display: grid;
  grid-template-columns: 78px minmax(220px, 1fr);
  align-content: start;
  align-items: start;
  gap: 8px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-setup.has-trade-card-detail .player-match-opponents > .player-match-section-head {
  display: grid;
  align-content: start;
  justify-content: stretch;
  gap: 8px;
  margin: 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-setup.has-trade-card-detail .player-match-mode-buttons {
  position: absolute;
  z-index: 4;
  top: 7px;
  right: 10px;
  margin-left: 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-setup.has-trade-card-detail .player-match-trade-detail {
  justify-items: start;
  padding-top: 0;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-setup.has-trade-card-detail .player-match-trade-detail-card {
  width: min(100%, 240px);
  justify-self: start;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-character {
  gap: 3px;
  padding: 3px 1px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-deck-character::after {
  top: calc(3px + var(--player-match-character-icon-size) - 17px);
  right: -1px;
  width: 22px;
  height: 22px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-cards {
  gap: 2px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-card {
  width: min(100%, 74px);
  max-height: min(94px, 24dvh);
  justify-self: center;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-card-role {
  top: 3px;
  left: 3px;
  padding: 1px 3px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-card-name {
  min-height: 2.5em;
  padding: 3px 2px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 6px;
}

/* 相手3人分の可読幅が足りない時は、グループを上下へ並べる。 */
@media (max-height: 600px) and (orientation: landscape) {
  body.mobile-landscape-layout .title-screen.title-match-setup-open
    #playerMatchSetup:not(.is-trade-mode) .player-match-opponent-list {
    --opponent-group-min-width: 250px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--opponent-group-min-width)), 1fr));
  }
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-final-row {
  gap: 5px;
}

/* Extra時も左側の星3グループと同じ行に保ち、右側の3枠内で収める。 */
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-final-row.is-extra {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-opponent-final-row.is-extra
  .player-match-opponent-group h4 {
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
  font-size: var(--landscape-menu-text-xs);
  letter-spacing: 0.02em;
}

body.mobile-landscape-layout:not(:lang(en)) .title-screen.title-match-setup-open
  .player-match-opponent-final-row.is-extra
  .player-match-opponent-group-level4 h4::before {
  display: none;
}

/* スマホ横だけ、星4も他の難易度と同じ見出しへ戻す。 */
@media (max-height: 600px) and (orientation: landscape) {
  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-opponent-final-row.is-extra
    .player-match-opponent-group-level4 h4 {
    justify-content: normal;
    gap: 4px;
    font-size: var(--landscape-menu-text-md);
    letter-spacing: 0.08em;
    flex-wrap: wrap;
    white-space: nowrap;
  }

  body.mobile-landscape-layout:not(:lang(en)) .title-screen.title-match-setup-open
    .player-match-opponent-final-row.is-extra
    .player-match-opponent-group-level4 h4::before {
    display: block;
  }
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group {
  padding: 4px 0 1px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group h4 {
  gap: 4px;
  margin-bottom: 4px;
  font-size: var(--landscape-menu-text-md);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group:not(.player-match-opponent-group-self) h4::before {
  font-size: var(--landscape-menu-text-xs);
}

body:is(.mobile-layout, .mobile-landscape-layout):lang(en) #academyExtraHeading {
  flex-wrap: nowrap;
  white-space: nowrap;
}

body:is(.mobile-layout, .mobile-landscape-layout):lang(en) #academyExtraHeading::before {
  display: none;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group-list {
  grid-template-columns: repeat(3, minmax(42px, 1fr));
  gap: 4px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group-level4 .player-match-opponent-group-list,
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group-self .player-match-opponent-group-list,
body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-group-random .player-match-opponent-group-list {
  grid-template-columns: 1fr;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open
  .player-match-opponent-final-row.is-extra
  .player-match-opponent {
  --player-match-opponent-portrait-size: clamp(32px, 8.5dvh, 40px);
  min-height: clamp(66px, 17dvh, 78px);
  padding-inline: 2px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open :is(.player-match-opponent, .player-academy-story-opponent) {
  --player-match-opponent-portrait-size: clamp(36px, 9.5dvh, 46px);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent {
  min-height: clamp(68px, 18dvh, 82px);
  gap: 3px;
  padding: 4px 3px;
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-extra-badge {
  top: 3px;
  left: 50%;
  padding: 1px 4px;
  font-size: var(--landscape-menu-text-xs);
  line-height: 1.1;
  white-space: nowrap;
  transform: translateX(-50%);
}

@media (max-height: 600px) and (orientation: landscape) {
  body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-extra-badge {
    padding: 1px 3px;
    font-size: 8px;
    line-height: 1.05;
    letter-spacing: 0.02em;
  }
}

/* 3列で縦に送るスマホ横では、顔を見分けやすい大きさへ戻す。 */
@media (orientation: landscape) and (max-height: 500px),
  (orientation: landscape) and (max-width: 900px) and (max-height: 600px) {
  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) :is(.player-match-opponent, .player-academy-story-opponent) {
    --player-match-opponent-portrait-size: clamp(44px, 13dvh, 60px);
  }
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-random :is(
  .player-match-opponent-streak,
  .player-match-opponent-best-streak
) {
  min-width: 0;
  max-width: 100%;
  font-size: var(--landscape-menu-text-xs);
  white-space: normal;
  text-align: center;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-name {
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-base-name {
  min-height: 0;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent-attribute {
  left: -1px;
  bottom: -1px;
  width: 15px;
  height: 15px;
  font-size: var(--landscape-menu-text-xs);
}

body.mobile-landscape-layout:lang(en) .title-screen.title-match-setup-open .player-match-opponent-attribute {
  width: max-content;
  padding-inline: 3px;
  font-size: 8px;
  white-space: nowrap;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-opponent.is-selected::after {
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  content: "✓";
  font-size: var(--landscape-menu-text-sm);
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-footer {
  grid-template-columns: minmax(0, 1fr) minmax(170px, 230px);
  gap: 8px;
  min-height: 56px;
  padding: 6px 10px;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup-footer p {
  font-size: var(--landscape-menu-text-sm);
  line-height: 1.25;
}

body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-start-button {
  min-height: 44px;
  font-size: var(--landscape-menu-text-lg);
}

/*
  スマホ横画面はPC版と同じ「自分｜選択・戦闘｜相手」の3列にする。
  visualViewportで判定したclassを表示条件にも使い、Safariのバー状態や
  回転途中にmedia queryとJSの判定が食い違わないようにする。
*/
  body.mobile-landscape-layout {
    --landscape-control-column-width:
      clamp(168px, calc(var(--mobile-viewport-width, 100dvw) * 0.28), 300px);
    --landscape-text-xs: clamp(8px, 1.9dvh, 9px);
    --landscape-text-sm: clamp(9px, 2.2dvh, 10px);
    --landscape-text-md: clamp(10px, 2.5dvh, 11px);
    --landscape-text-lg: clamp(11px, 2.8dvh, 12.5px);
    --landscape-text-xl: clamp(13px, 3.4dvh, 15px);
    /* 盤面カードと調整済みのナビ本文には、従来の小型密度を残す。 */
    --landscape-zone-text-xs: clamp(6px, 1.4dvh, 7px);
    --landscape-zone-text-sm: clamp(7px, 1.65dvh, 8px);
    --landscape-zone-text-md: clamp(8px, 1.9dvh, 9px);
    --landscape-zone-text-lg: clamp(9px, 2.2dvh, 10.5px);
    --landscape-tutorial-text-sm: clamp(7px, 1.65dvh, 8px);
    --landscape-tutorial-text-lg: clamp(9px, 2.2dvh, 10.5px);
    --landscape-tutorial-text-xl: clamp(11px, 2.75dvh, 13px);
    --landscape-empty-emblem-bottom: 3px;
    --landscape-player-head-height:
      clamp(32px, calc(var(--mobile-viewport-height, 100dvh) * 0.09), 42px);
    --field-front-bg:
      radial-gradient(ellipse at 50% 106%, rgba(255, 238, 174, 0.09), transparent 58%),
      radial-gradient(ellipse at 50% 104%, var(--field-front-glow), transparent 70%),
      radial-gradient(circle at 18% 42%, rgba(121, 196, 138, 0.13), transparent 44%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%, rgba(0, 0, 0, 0.14)),
      linear-gradient(90deg, rgba(60, 111, 82, 0.36), rgba(46, 83, 63, 0.13) 62%, rgba(12, 16, 14, 0.08)),
      rgba(18, 27, 21, 0.26);
    --field-back-bg:
      radial-gradient(ellipse at 50% 112%, rgba(174, 231, 255, 0.045), transparent 64%),
      radial-gradient(ellipse at 50% 104%, var(--field-back-glow), transparent 72%),
      radial-gradient(circle at 18% 42%, rgba(133, 211, 204, 0.085), transparent 44%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.026), transparent 42%, rgba(0, 0, 0, 0.09)),
      linear-gradient(90deg, rgba(66, 82, 116, 0.25), rgba(51, 65, 92, 0.095) 62%, rgba(12, 16, 14, 0.065)),
      rgba(20, 25, 34, 0.2);
    font-size: var(--landscape-text-md);
    width: var(--mobile-viewport-width, 100dvw);
    height: var(--mobile-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout {
    --landscape-inline-start: max(4px, var(--app-safe-left));
    --landscape-inline-end: max(4px, var(--app-safe-right));
    --compact-card-min-width: 39px;
    --compact-card-max-width: 48px;
    --landscape-zone-card-width:
      clamp(
        var(--compact-card-min-width),
        calc(var(--mobile-viewport-width, 100dvw) * 0.052),
        var(--compact-card-max-width)
      );
    --compact-card-height:
      calc(
        var(--landscape-zone-card-width)
        * var(--compact-card-aspect-height)
        / var(--compact-card-aspect-width)
      );
    --landscape-board-card-height:
      clamp(60px, calc(var(--mobile-viewport-height, 100dvh) * 0.185), 82px);
    --landscape-lane-height: calc(var(--landscape-board-card-height) + 6px);
    --landscape-lane-gap: 4px;
    --landscape-board-height:
      calc(var(--landscape-lane-height) + var(--landscape-lane-height) + var(--landscape-lane-gap));
    --compact-row-height: calc(var(--compact-card-height) + 14px);
    --landscape-hand-row-height: calc(var(--compact-card-height) + 24px);
    --landscape-stage-min-height:
      calc(
        var(--landscape-player-head-height)
        + var(--landscape-board-height)
        + var(--compact-row-height)
        + var(--landscape-hand-row-height)
      );
    --landscape-control-height: min(var(--landscape-stage-min-height), calc(var(--app-usable-height) - 2px));
    --landscape-avatar-size:
      clamp(26px, calc(var(--landscape-player-head-height) - 6px), 30px);
    --landscape-header-tool-width:
      clamp(23px, calc(var(--landscape-avatar-size) - 3px), 27px);
    --landscape-header-tool-height:
      clamp(25px, calc(var(--landscape-player-head-height) - 8px), 30px);
    /* 長押し詳細も、通常時の局面欄と下端操作の間に収まる寸法へ揃える。 */
    --landscape-selection-state-height: clamp(56px, 16dvh, 80px);
    --landscape-selection-preview-top: calc(clamp(44px, 10dvh, 56px) + 4px);
    --landscape-selection-preview-bottom-space: calc(clamp(38px, 8dvh, 46px) + 4px);
    --landscape-selection-preview-height:
      calc(
        var(--landscape-control-height)
        - var(--landscape-selection-preview-top)
        - var(--landscape-selection-preview-bottom-space)
      );
    --landscape-attack-choice-width: 56px;
    --landscape-battle-choice-width: var(--landscape-attack-choice-width);
    --landscape-battle-gap:
      clamp(4px, calc(var(--mobile-viewport-height, 100dvh) * 0.013), 6px);
    --landscape-battle-center-width:
      clamp(32px, calc(var(--mobile-viewport-height, 100dvh) * 0.092), 40px);
    /* 横幅だけで戦闘カードを拡大すると、Safariのバー表示時に計算欄が縦へ溢れる。
       実表示高でも上限を持たせ、武器と演出を同じ比率で縮める。 */
    --landscape-battle-unit-width:
      min(
        clamp(
          44px,
          calc(
            (
              var(--landscape-control-column-width)
              - var(--landscape-battle-center-width)
              - var(--landscape-battle-gap)
              - var(--landscape-battle-gap)
              - 32px
            ) * 0.5
          ),
          76px
        ),
        clamp(58px, calc(var(--mobile-viewport-height, 100dvh) * 0.19), 76px)
      );
    --landscape-battle-stage-height:
      clamp(108px, calc(var(--landscape-battle-unit-width) * 1.5 + 22px), 142px);
    --landscape-battle-step-height:
      clamp(16px, calc(var(--mobile-viewport-height, 100dvh) * 0.046), 20px);
    --landscape-battle-head-height:
      max(
        clamp(32px, calc(var(--mobile-viewport-height, 100dvh) * 0.092), 40px),
        calc(var(--landscape-text-xl) * 1.2 + var(--landscape-text-lg) * 1.35 + 7px)
      );
    --landscape-battle-weapon-width:
      calc(var(--landscape-battle-unit-width) * 0.5132);
    --landscape-battle-weapon-art-width:
      calc(var(--landscape-battle-unit-width) * 0.8553);
    --landscape-battle-weapon-art-aspect: 65 / 94;
    --landscape-battle-book-width:
      calc(var(--landscape-battle-unit-width) * 0.7895);
    --landscape-battle-book-aspect: 60 / 85;
    --landscape-battle-spell-width:
      calc(var(--landscape-battle-unit-width) * 1.0526);
    --landscape-battle-spell-aspect: 80 / 98;
    --landscape-battle-circle-size: var(--landscape-battle-spell-width);
    --landscape-battle-spell-circle-size:
      calc(var(--landscape-battle-unit-width) * 1.1711);
    --landscape-battle-effect-max-size:
      min(
        calc(var(--landscape-control-column-width) * 0.68),
        calc(var(--landscape-battle-stage-height) * 1.1)
      );
    --unit-row-reserved-height: 0px;
    --status-panel-min-height: 0px;
    --selection-panel-height: auto;
    --landscape-font-xs: var(--landscape-text-xs);
    --landscape-font-sm: var(--landscape-text-sm);
    --landscape-font-md: var(--landscape-text-md);
    --landscape-font-lg: var(--landscape-text-lg);
    position: fixed;
    top: var(--app-viewport-offset-top);
    left: var(--app-viewport-offset-left);
    right: auto;
    bottom: auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: var(--app-viewport-width);
    max-width: none;
    height: var(--app-viewport-height);
    min-height: 0;
    margin: 0;
    padding:
      max(1px, var(--app-safe-top))
      var(--landscape-inline-end)
      max(1px, var(--app-safe-bottom))
      var(--landscape-inline-start);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    transform: none;
    touch-action: manipulation;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .card,
  body.mobile-landscape-layout .app.mobile-landscape-layout .unit {
    will-change: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout.match-screen-player {
    grid-template-rows: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout.match-screen-player > .topbar,
  body.mobile-landscape-layout .app.mobile-landscape-layout.match-screen-player > .header-show-button {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .table {
    display: grid;
    grid-template-columns:
      minmax(0, 1fr)
      var(--landscape-control-column-width)
      minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "self control opponent";
    gap: 4px;
    align-self: start;
    align-items: start;
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: var(--landscape-stage-min-height);
    padding: 0;
    /* 見切れは保ちつつ、中央操作欄のsticky基準を縦スクロールするappまで通す。 */
    overflow: clip;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #player1 {
    grid-area: self;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #controlPanel {
    grid-area: control;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #player2 {
    grid-area: opponent;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #player1.player-panel,
  body.mobile-landscape-layout .app.mobile-landscape-layout #player2.player-panel {
    order: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows:
      var(--landscape-player-head-height)
      var(--landscape-board-height)
      var(--compact-row-height)
      var(--landscape-hand-row-height);
    grid-template-areas: none;
    align-self: start;
    height: auto;
    min-width: 0;
    min-height: 0;
    border-color: transparent;
    border-radius: 6px;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --player-header-ornament-width: 14px;
    grid-area: auto;
    display: grid;
    grid-template-columns: var(--landscape-avatar-size) minmax(0, 1fr) auto;
    align-items: center;
    gap: 3px;
    height: var(--landscape-player-head-height);
    min-height: var(--landscape-player-head-height);
    padding: 2px var(--player-header-ornament-width);
    overflow: visible;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head > .player-identity {
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .avatar-icon {
    width: var(--landscape-avatar-size);
    height: var(--landscape-avatar-size);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name-row {
    gap: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name {
    overflow: hidden;
    font-size: var(--landscape-font-lg);
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-flags {
    overflow: hidden;
    font-size: var(--landscape-font-sm);
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-surrender-button:not([hidden]) {
    display: inline-grid;
    min-height: 0;
    place-items: center;
    padding: 2px 4px;
    font-size: var(--landscape-font-xs);
    line-height: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-surrender-button[hidden] {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-state-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .fallen-badge {
    padding: 2px 4px;
    font-size: var(--landscape-font-xs);
  }


  body.mobile-landscape-layout .app.mobile-landscape-layout .pile-stats {
    --pile-stat-gap: 2px;
    display: flex;
    align-self: stretch;
    align-items: center;
    gap: var(--pile-stat-gap);
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile {
    display: grid;
    align-content: center;
    justify-items: center;
    align-self: stretch;
    height: 100%;
    min-width: 24px;
    min-height: 0;
    max-height: 100%;
    padding: 1px 2px;
    border-radius: 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile strong {
    font-size: var(--landscape-font-md);
    line-height: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile span {
    font-size: var(--landscape-font-xs);
    line-height: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-pile {
    min-width: 34px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-icons {
    --life-icon-width: 6px;
    --life-icon-height: 9px;
    --life-icon-gap: 1px;
    min-width: var(--life-icon-height);
    height: 9px;
    min-height: 9px;
    gap: var(--life-icon-gap);
    margin-bottom: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-icon {
    width: var(--life-icon-width);
    height: var(--life-icon-height);
    border-radius: 2px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-icons .life-empty-mark {
    width: var(--life-icon-height);
    height: var(--life-icon-height);
    flex: 0 0 auto;
    font-size: min(10px, calc(var(--life-icon-height) - 3px));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-header-tool {
    align-self: flex-start;
    width: var(--landscape-header-tool-width);
    min-width: var(--landscape-header-tool-width);
    height: var(--landscape-header-tool-height);
    min-height: var(--landscape-header-tool-height);
    padding: 0;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-options-tool .mobile-header-tool-icon {
    font-size: 1em;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-log-tool .mobile-header-tool-icon {
    transform: translateY(-1.5px);
  }

/* スマホ横は名前と降参を同じ行に置き、状態欄と枚数枠を独立させる。 */
@media (max-height: 620px) {
  body.mobile-landscape-layout {
    --player-surrender-width: 16px;
    --player-surrender-height: 14px;
    --player-surrender-icon-size: 12px;
    --player-surrender-hit-inset: -8px -1px -8px -8px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --player-header-ornament-width: 10px;
    --player-header-ornament-scale: 115%;
    --landscape-avatar-size: 24px;
    --landscape-header-tool-width: 24px;
    --landscape-header-tool-height: 26px;
    --landscape-font-lg: clamp(10px, 2.65dvh, 11px);
    --landscape-font-sm: clamp(8px, 2.05dvh, 9px);
    --landscape-font-md: 11px;
    --landscape-font-xs: 8px;
    grid-template-columns: var(--landscape-avatar-size) minmax(calc(var(--landscape-font-lg) * 5), 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    column-gap: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head > .player-avatar {
    grid-area: 1 / 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-avatar .player-state-badges {
    bottom: -3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .player-state-badge {
    width: max-content;
    max-width: none;
    padding: 1px 0;
    font-size: calc((var(--landscape-avatar-size) + 4px) / 4);
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    transform: translateX(-1px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head > .player-identity {
    grid-area: 1 / 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 1px 2px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name-row {
    display: contents;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name {
    grid-area: 1 / 1;
    font-size: var(--landscape-font-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name.is-long-name {
    font-size: max(8px, calc(var(--landscape-font-lg) - 1.2px));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-flags {
    grid-area: 2 / 1 / 3 / -1;
    font-size: max(7px, calc(var(--landscape-font-sm) - 0.5px));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-surrender-button:not([hidden]) {
    grid-area: 1 / 2;
    height: 14px;
    padding: 1px 3px;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile-stats {
    grid-area: 1 / 3;
    display: grid;
    grid-template-columns: 24px 36px repeat(2, 22px);
    grid-template-rows: minmax(0, 1fr);
    gap: 2px;
    min-width: 0;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .pile-stats {
    grid-template-columns: 24px 36px 22px 30px;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .pile-stats > .deck-pile {
    padding-inline: 0;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .player-head {
    grid-template-columns: var(--landscape-avatar-size) minmax(calc(var(--landscape-font-lg) * 4), 1fr) auto;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .player-surrender-button:not([hidden]) {
    padding-inline: 1px;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .player-head {
    padding-inline: max(1px, calc(var(--player-header-ornament-width) - 3px));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head > .player-identity {
    overflow: visible;
  }

  /* 覚醒名とラベルにはカードの外枠まで幅を戻し、英単語の途中切れを防ぐ。 */
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .hand .card.awakened-warrior-card .card-info {
    width: calc(100% + 6px);
    max-width: none;
    margin-left: -3px;
    padding-inline: 0;
    overflow: visible;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .hand .card.awakened-warrior-card .name {
    display: -webkit-box;
    min-width: 5.7em;
    overflow-wrap: normal;
    -webkit-line-clamp: 2;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .hand .card.awakened-warrior-card .type-label {
    padding-inline: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile-stats > .pile {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    contain: layout;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .pile-count-roll {
    width: 100%;
    height: 11px;
    margin-inline: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .life-icons {
    --life-icon-width: 8px;
    --life-icon-height: 12px;
    height: var(--life-icon-height);
    min-height: var(--life-icon-height);
    margin-bottom: 2px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-header-tool {
    align-self: center;
    border-radius: 5px;
    font-size: 13px;
  }
}

@media (max-width: 780px) and (max-height: 620px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --player-header-ornament-width: 5px;
    --player-header-ornament-scale: 80%;
    --landscape-avatar-size: 20px;
    --landscape-font-lg: 9px;
    column-gap: 2px;
  }
}

@media (max-width: 680px) and (max-height: 500px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --player-header-ornament-width: 1px;
    --landscape-avatar-size: 16px;
    column-gap: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .player-name:lang(ja) {
    font-size: clamp(8px, 1.4dvw, 9px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .pile-stats {
    grid-template-columns: 20px 28px 22px 25px;
    gap: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .pile-stats > .pile {
    padding-inline: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .mobile-header-tool {
    width: 20px;
    min-width: 20px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .life-icons {
    --life-icon-width: 6px;
    --life-icon-height: 10px;
  }
}

  body.mobile-landscape-layout .app.mobile-landscape-layout .zone {
    min-width: 0;
    min-height: 0;
    padding: 2px 3px;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .board,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone {
    --landscape-font-xs: var(--landscape-zone-text-xs);
    --landscape-font-sm: var(--landscape-zone-text-sm);
    --landscape-font-md: var(--landscape-zone-text-md);
    --landscape-font-lg: var(--landscape-zone-text-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .board {
    grid-area: auto;
    display: grid;
    grid-template-rows: repeat(2, var(--landscape-lane-height));
    gap: var(--landscape-lane-gap);
    height: var(--landscape-board-height);
    min-height: 0;
    padding: 0 3px;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .lane {
    grid-area: auto;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    min-width: 0;
    height: var(--landscape-lane-height);
    min-height: var(--landscape-lane-height);
    gap: 0;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .lane-label {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 4;
    min-width: 28px;
    height: 14px;
    padding: 0 4px;
    writing-mode: horizontal-tb;
    border-radius: 999px;
    font-size: var(--landscape-font-sm);
    pointer-events: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    column-gap: 6px;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 6px 3px 2px 38px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row > .unit,
  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row > .empty {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    height: var(--landscape-board-card-height);
    min-height: 0;
    max-height: var(--landscape-board-card-height);
    aspect-ratio: var(--board-card-aspect-width) / var(--board-card-aspect-height);
    scroll-snap-align: start;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row > .unit {
    padding: var(--unit-frame-padding);
    overflow: visible;
    background-position: center top;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row > .empty {
    font-size: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit.has-card-art .card-info {
    flex: 0 1 auto;
    width: 100%;
    max-width: 100%;
    max-height: calc(100% - 16px);
    margin-left: 0;
    padding: 2px;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .name {
    display: -webkit-box;
    width: 7em;
    max-width: 100%;
    min-height: 2.24em;
    max-height: 2.24em;
    overflow: hidden;
    font-size: min(var(--landscape-font-xs), calc((var(--landscape-board-card-height) * var(--board-card-aspect-width) / var(--board-card-aspect-height) - 12px) / 7));
    line-height: 1.12;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .unit .name {
    word-break: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .unit-stat-line,
  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .stat-line {
    margin-top: 1px;
    overflow: hidden;
    font-size: var(--landscape-font-xs);
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .stat-delta {
    margin-left: 1px;
    font-size: inherit;
    font-weight: 700;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .tag-line,
  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .effect-line {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .hpbar {
    display: block;
    height: 4px;
    min-height: 4px;
    margin-top: 2px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .tiny {
    display: block;
    min-height: 7px;
    margin-top: 1px;
    overflow: hidden;
    font-size: var(--landscape-font-xs);
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .tiny:empty {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .level-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .level-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .level-badge {
    top: -3px;
    left: -3px;
    width: 15px;
    height: 15px;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .commander-badge {
    top: -4px;
    min-width: 24px;
    padding: 1px 4px;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .rest-badge {
    top: 1px;
    right: 1px;
    padding: 1px 3px;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-role-badges {
    top: -4px;
    right: -3px;
    gap: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .attack-role-badge {
    min-width: 24px;
    padding: 1px 4px 2px;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone {
    grid-area: auto;
    display: grid;
    grid-template-rows: 9px minmax(0, 1fr);
    gap: 0;
    padding: 1px 3px;
  }

  /* 短い横画面はカード・見出しを縮めず、段間と手札の余白だけで高さを節約する。 */
  @media (max-height: 620px) {
    body.mobile-landscape-layout .app.mobile-landscape-layout {
      --landscape-lane-gap: 1px;
      --compact-row-height: calc(var(--compact-card-height) + 13px);
      --landscape-hand-row-height: calc(var(--compact-card-height) + 18px);
    }

    /* 透明な外枠の上下2pxを段間へ回し、全体高とカード寸法を保つ。 */
    body.mobile-landscape-layout .app.mobile-landscape-layout .player-panel {
      border-block-width: 0;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone {
      border-top-width: 0;
      padding-top: 1px;
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .zone-title {
    min-height: 0;
    font-size: var(--landscape-font-sm);
    line-height: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .zone-count {
    min-height: 9px;
    padding: 1px 3px;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone .zone-title {
    flex-wrap: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone .zone-title > span {
    display: inline;
    flex: none;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-payable-full {
    display: inline;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-payable-compact {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-payable-count {
    position: relative;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cards {
    min-height: 0;
    height: 100%;
    padding: 3px 1px 0;
    column-gap: 3px;
    row-gap: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    column-gap: 1px;
    margin-top: 0;
    padding-left: 1px;
    padding-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand {
    justify-content: safe center;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost {
    justify-content: flex-start;
  }

  /* スマホ横の先頭レベル表示が切れないよう、列の左側だけ2px広げる。 */
  @media (max-height: 620px) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .cost {
      padding-left: 3px;
    }
  }

  @supports selector(.hand:has(> .card:nth-child(6):last-child)) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(6):last-child) {
      --landscape-hand-card-count: 6;
      --landscape-hand-overlap-share: 0.2;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(7):last-child) {
      --landscape-hand-card-count: 7;
      --landscape-hand-overlap-share: 0.1666667;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(8):last-child) {
      --landscape-hand-card-count: 8;
      --landscape-hand-overlap-share: 0.1428571;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(6):last-child) .card + .card,
    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(7):last-child) .card + .card,
    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(8):last-child) .card + .card {
      margin-left:
        min(
          0px,
          calc(
            (
              100%
              - 6px
              - (
                var(--landscape-zone-card-width)
                * var(--landscape-hand-card-count)
              )
              - (
                (var(--landscape-hand-card-count) - 1)
                * var(--landscape-zone-card-gap, 1px)
              )
            )
            * var(--landscape-hand-overlap-share)
          )
        );
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(9)) {
      justify-content: flex-start;
      scroll-padding-inline: 3px;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card:nth-child(9)) .card + .card {
      margin-left: calc(-1 * var(--landscape-zone-card-width) * 0.18);
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .cost:has(> .card:nth-child(5)) .card + .card {
      margin-left:
        calc(
          -1
          * (
            var(--cost-card-overlap-x, 0px)
            + var(--landscape-zone-card-width) * 0.125
          )
        );
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .card {
    flex: 0 0 var(--landscape-zone-card-width);
    width: var(--landscape-zone-card-width);
    min-width: var(--landscape-zone-card-width);
    max-width: var(--landscape-zone-card-width);
    height: var(--compact-card-height);
    min-height: var(--compact-card-height);
    max-height: var(--compact-card-height);
    aspect-ratio: var(--compact-card-aspect-width) / var(--compact-card-aspect-height);
    padding: 2px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand > .empty,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost > .empty {
    flex-basis: var(--landscape-zone-card-width);
    width: var(--landscape-zone-card-width);
    min-width: var(--landscape-zone-card-width);
    max-width: var(--landscape-zone-card-width);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand > .empty {
    font-size: var(--landscape-font-lg);
  }

  @supports selector(.hand-zone:has(.card.selected)) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .player-panel:has(.hand .card.selected),
    body.mobile-landscape-layout .app.mobile-landscape-layout .player-panel:has(.cost .card.selected),
    body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone:has(.card.selected),
    body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone:has(.card.selected) {
      overflow: visible;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .player-panel:has(.hand .card.selected),
    body.mobile-landscape-layout .app.mobile-landscape-layout .player-panel:has(.cost .card.selected) {
      z-index: 72;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone:has(.card.selected),
    body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone:has(.card.selected) {
      z-index: 74;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone:has(.card.selected) .hand {
      /* 選択カードの前面表示は親のz-indexで行い、手札列の横幅計算は通常時から変えない。 */
      overflow-x: auto;
      overflow-y: hidden;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card.selected,
    body.mobile-landscape-layout .app.mobile-landscape-layout .cost .card.selected {
      z-index: 76;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card.selected .level-badge,
    body.mobile-landscape-layout .app.mobile-landscape-layout .cost .card.selected .level-badge {
      z-index: 78;
    }
  }

  /* 横スクロールは保ち、手札誘導の揺れとレベル表示だけが上へ出られる余白を作る。 */
  @supports selector(.hand:has(> .card.tutorial-highlight)) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone:has(.hand > .card.tutorial-highlight) {
      overflow: visible;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card.tutorial-highlight) {
      --tutorial-hand-overflow-space: 24px;
      height: calc(100% + var(--tutorial-hand-overflow-space));
      margin-top: calc(-1 * var(--tutorial-hand-overflow-space));
      padding-top: calc(3px + var(--tutorial-hand-overflow-space));
      overflow-x: auto;
      overflow-y: hidden;
      /* 広げた透明部分は背後のコストカードの入力を遮らない。 */
      pointer-events: none;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .hand:has(> .card.tutorial-highlight) > .card:not(:disabled) {
      pointer-events: auto;
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .card.selected {
    transform: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card:active:not(:disabled),
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card.selected,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card.selected:active:not(:disabled) {
    transform:
      translateY(calc(var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)))
      rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
      scale(1);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit.selected,
  body.mobile-landscape-layout .app.mobile-landscape-layout .unit.targeted {
    transform: translateY(0) scale(1.012);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .card .card-info,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .card .card-info {
    flex: 0 1 auto;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    margin-left: 0;
    padding: 2px;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .name,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .name {
    display: block;
    min-height: 2.1em;
    max-height: 2.1em;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: var(--landscape-font-sm);
    line-height: 1.05;
    text-overflow: clip;
    white-space: normal;
    -webkit-line-clamp: unset;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .stat-line:not(.type-label),
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .tag-line,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .effect-line,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .stat-line:not(.type-label),
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .tag-line,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .effect-line {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .type-label,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .type-label {
    margin-top: 1px;
    font-size: var(--landscape-font-xs);
    line-height: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel {
    order: 0;
    position: sticky;
    top: 0;
    bottom: auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 4px;
    /* 局面と詳細は上へ置き、フェイズ進行操作だけ盤面の下端へ寄せる。 */
    align-content: stretch;
    align-self: start;
    width: 100%;
    height: var(--landscape-control-height);
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  @supports selector(.control-panel:has(.mobile-progress-tips.show)) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel:has(.mobile-progress-tips.show) {
      z-index: 146;
      overflow: visible;
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-progress-tips {
    position: absolute;
    z-index: 147;
    /* フェイズ欄の3行目へ上端を重ね、詳細欄を覆う量を減らす。 */
    top: calc(var(--landscape-selection-state-height) - 12px);
    right: 3px;
    left: 3px;
    width: auto;
    padding: 6px 8px;
    overflow: visible;
    font-size: var(--landscape-font-lg);
    line-height: 1.34;
    white-space: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-progress-warning-line {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-progress-tips .rule-context-link {
    width: 30px;
    min-width: 30px;
    min-height: 28px;
    font-size: var(--landscape-font-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-progress-tips.has-rule-link {
    grid-template-columns: minmax(0, 1fr) 30px;
    column-gap: 2px;
    padding-right: 1px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .status {
    --phase-status-height: var(--landscape-selection-state-height);
    display: block;
    padding: 4px 5px;
    overflow: visible;
    border-color: var(--phase-accent-soft);
    border-radius: 7px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 42%),
      rgba(21, 27, 22, 0.88);
    box-shadow:
      inset 0 2px 0 var(--phase-accent),
      0 5px 14px rgba(0, 0, 0, 0.2);
    font-size: var(--landscape-font-lg);
    line-height: 1.24;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection {
    --card-detail-label-font-size: var(--landscape-font-lg);
    --card-detail-awaken-font-size: var(--landscape-font-lg);
    grid-area: auto;
    display: block;
    height: 100%;
    min-height: 0;
    max-height: none;
    padding: 5px;
    border-color: color-mix(in srgb, var(--phase-accent-soft) 66%, rgba(111, 121, 101, 0.42));
    border-radius: 7px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 38%),
      rgba(24, 29, 24, 0.86);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      0 5px 14px rgba(0, 0, 0, 0.18);
    font-size: var(--landscape-font-lg);
    line-height: 1.25;
    overflow: hidden;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-empty-guide {
    gap: 3px;
    padding: 5px 6px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-empty-guide strong {
    font-size: var(--landscape-font-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-empty-guide span {
    font-size: var(--landscape-font-md);
    line-height: 1.35;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .control-panel:not(.has-pending-battle) .selection.is-empty {
    position: relative;
    isolation: isolate;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .control-panel:not(.has-pending-battle) .selection.is-empty::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: auto;
    right: 50%;
    bottom: var(--landscape-empty-emblem-bottom);
    left: auto;
    width: min(220px, calc(100% - 14px));
    height: 330px;
    transform: translateX(50%);
    pointer-events: none;
    opacity: 0.14;
    background: url("../assets/backgrounds/emblem.webp?v=app-cache-20261118-3") center bottom / contain no-repeat;
    mix-blend-mode: screen;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .control-panel:not(.has-pending-battle) .selection.is-empty > * {
    position: relative;
    z-index: 1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .status .status-progress-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection .status-progress-badge {
    padding: 2px 5px;
    font-size: var(--landscape-font-md);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .status .status-warning-line {
    font-size: var(--landscape-font-md);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 100%;
    border-radius: 5px;
    overflow: hidden;
    isolation: isolate;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 4px;
    place-items: stretch center;
    overflow: hidden;
    border-radius: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal::after {
    content: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal .selection-card-face-host {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    justify-self: stretch;
    align-items: center;
    justify-content: center;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal .selection-card-face-host > .card-face {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    cursor: zoom-in;
    touch-action: manipulation;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal .selection-current-state {
    display: grid;
    gap: 2px;
    padding: 3px 5px;
    border-radius: 5px;
    font-size: var(--landscape-font-sm);
    line-height: 1.2;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__header {
    gap: 2px 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__label {
    padding: 0.12em 0.42em;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__summary,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__stats {
    gap: 2px 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__level,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__position,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__activity,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__hp {
    padding: 0.14em 0.38em;
    font-size: var(--landscape-font-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__hp {
    min-width: 66px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__stats,
  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-current-state__stack {
    padding: 0.18em 0.4em;
  }

  /* スマホ横のフェイズ欄は3行分を予約する。 */
  @media (max-height: 620px) {
    body.mobile-landscape-layout .app.mobile-landscape-layout {
      /* 進行度を含む上段と案内2行を基準にし、画面高だけで余白を増やさない。 */
      --landscape-selection-state-height:
        calc(var(--landscape-text-md) * 1.24 + var(--landscape-text-lg) * 2.48 + 15px);
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .status {
      padding-block: 3px;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--formal
      :is(.selection-current-state__stat-seal, .selection-current-state__attribute-seal) {
      padding-block: 0.18em;
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail:not(.selection-detail--formal)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
      linear-gradient(180deg, rgba(9, 12, 10, 0.02) 0 46%, rgba(9, 12, 10, 0.28) 72%, rgba(9, 12, 10, 0.66) 100%),
      linear-gradient(90deg, rgba(9, 12, 10, 0.16), transparent 16% 84%, rgba(9, 12, 10, 0.16));
    pointer-events: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail .selection-text {
    position: absolute;
    z-index: 2;
    right: 6px;
    bottom: 6px;
    left: 6px;
    box-sizing: border-box;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: 46%;
    margin: 0;
    padding: 7px 8px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(239, 220, 163, 0.3);
    border-radius: 6px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 48%),
      rgba(12, 15, 13, 0.84);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      0 6px 18px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(5px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
    scrollbar-gutter: stable;
  }

  @media (max-height: 620px) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail--compact .selection-text {
      /* 末尾1行と文字描画差の余裕を足し、外枠やイラストの寸法は変えない。 */
      max-height: calc(46% + 2em);
      --card-detail-label-font-size: calc(var(--landscape-font-lg) - 1px);
      --card-detail-awaken-font-size: calc(var(--landscape-font-lg) - 1px);
      font-size: 11px;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-progress-tips {
      font-size: var(--landscape-font-md);
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-text .card-detail-warrior-mobile-separator {
    display: inline;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-text .card-detail-warrior-stat-break {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-art-card {
    --warrior-portrait-position: center 24%;
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border: 0;
    border-radius: inherit;
    background-position: center 24%;
    background-size: cover;
    box-shadow: none;
    opacity: 0.94;
    cursor: zoom-in;
    touch-action: manipulation;
  }

  @supports selector(.selection:has(.selection-detail)) {
    body.mobile-landscape-layout .app.mobile-landscape-layout .selection:has(.selection-detail) {
      overflow: hidden;
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .actions {
    grid-area: auto;
    order: 0;
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .actions button {
    min-height: 38px;
    padding: 3px 5px;
    border-radius: 7px;
    font-size: var(--landscape-text-xl);
    line-height: 1.12;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .operation-hints {
    display: none !important;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .log-wrap {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle {
    --landscape-battle-frame-padding: 3px;
    --landscape-battle-frame-bottom-padding: var(--landscape-battle-frame-padding);
    --landscape-battle-frame-block-padding:
      calc(var(--landscape-battle-frame-padding) + var(--landscape-battle-frame-bottom-padding));
    --landscape-battle-height-limit:
      calc(var(--app-viewport-height) - max(1px, var(--app-safe-top)) - max(1px, var(--app-safe-bottom)));
    display: block;
    height: var(--landscape-control-height);
    min-height: 0;
    padding: var(--landscape-battle-frame-padding);
    padding-block-end: var(--landscape-battle-frame-bottom-padding);
    overflow: visible;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle > .status,
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle > .selection,
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle > .actions,
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle > .operation-hints,
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle > .log-wrap {
    display: none;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle.card-text-hold-preview > .selection {
    --landscape-selection-preview-top: var(--landscape-battle-frame-padding);
    --landscape-selection-preview-height:
      calc(var(--landscape-control-height) - var(--landscape-battle-frame-block-padding));
    position: absolute;
    z-index: 160;
    top: var(--landscape-selection-preview-top);
    right: 3px;
    bottom: auto;
    left: 3px;
    display: block;
    width: auto;
    height: var(--landscape-selection-preview-height);
    min-height: var(--landscape-selection-preview-height);
    max-height: var(--landscape-selection-preview-height);
    border-color: var(--ui-active-border);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 48%),
      linear-gradient(180deg, var(--phase-tint), transparent 34%),
      rgba(20, 24, 20, 0.97);
    backdrop-filter: blur(8px);
    box-shadow:
      0 0 0 1px rgba(224, 184, 78, 0.24),
      0 12px 28px rgba(0, 0, 0, 0.34);
    pointer-events: none;
  }

  /* 戦闘中は下端操作分を空けず、正式カードを上、現在値を下へ積んで中央欄を使い切る。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout
    .selection-detail--hold-preview.selection-detail--with-current-state {
    grid-template-rows: minmax(0, 1fr) minmax(0, min(30%, var(--landscape-selection-state-height)));
  }

  /* 背の低い横画面では、長い本文に中央の詳細欄の横幅も使う。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout
    .selection-detail--hold-preview .selection-card-face-host > .card-face--full-text {
    width: 100%;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .selection-detail--hold-preview > .selection-current-state {
    height: 100%;
    min-height: 0;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle .battle-panel {
    --battle-step-row: var(--landscape-battle-step-height);
    position: relative;
    inset: auto;
    z-index: auto;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    padding: 0;
    overflow: auto;
    overflow-x: hidden;
    scroll-padding-block: 4px 48px;
    overscroll-behavior: contain;
    container: battle-viewport / inline-size;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 処理開始から計算欄を予約した共通高を使い、縮尺と外枠を保つ。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle:has(
    > .battle-panel:is([data-mode="processing"], [data-mode="damage-preview"], [data-mode="result"])
  ) {
    height: auto;
    min-height: var(--landscape-control-height);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle
    > .battle-panel:is([data-mode="processing"], [data-mode="damage-preview"], [data-mode="result"]) {
    container: battle-viewport / size;
    height: auto;
    min-height: calc(var(--landscape-control-height) - var(--landscape-battle-frame-block-padding));
    max-height: calc(var(--landscape-battle-height-limit) - var(--landscape-battle-frame-block-padding));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout :is(.battle-attack-actions, .battle-block-resolve, .battle-weapon-resolve) {
    position: sticky;
    bottom: 0;
    z-index: 12;
    min-height: 36px;
    box-shadow: 0 -4px 10px rgba(10, 15, 13, 0.55);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-actions {
    align-items: stretch;
    gap: 3px;
    background: rgba(18, 24, 21, 0.97);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-actions button {
    padding-inline: 3px;
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-panel,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-panel,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-panel {
    gap: 4px;
    min-height: 100%;
    padding: 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card {
    flex-basis: var(--landscape-battle-choice-width);
    min-height: 36px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-list {
    padding: 4px 2px 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-columns {
    grid-template-columns:
      minmax(calc(var(--landscape-battle-choice-width) + 12px), var(--attack-front-track, 1fr))
      minmax(calc(var(--landscape-battle-choice-width) + 12px), var(--attack-back-track, 1fr));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-group {
    padding: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-group .battle-choice-list {
    min-height: 66px;
    padding: 4px 2px 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-group .battle-choice-empty {
    min-height: 56px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel button,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel select,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel [role="button"] {
    min-height: 36px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result {
    gap: 5px;
    padding: 5px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) {
    --battle-head-row: var(--landscape-battle-head-height);
    --battle-stage-row-min: var(--landscape-battle-stage-height);
  }

  @media (orientation: landscape) and (max-height: 620px) {
    body.mobile-landscape-layout .app.mobile-landscape-layout {
      /* 大きめの決着見出しと本文2行を、戦闘処理から同じ高さで確保する。 */
      --landscape-battle-head-height:
        calc((var(--landscape-text-xl) + 2px) * 1.2 + var(--landscape-text-md) * 7 / 3 + 6px);
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result.direct-attack,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result.battle-interrupt {
    min-height:
      clamp(210px, calc(var(--mobile-viewport-height, 100dvh) * 0.615), 260px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result.battle-interrupt.final-blow {
    min-height:
      clamp(238px, calc(var(--mobile-viewport-height, 100dvh) * 0.692), 292px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-head-stack {
    min-height: var(--landscape-battle-head-height);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-stage {
    grid-template-columns:
      minmax(0, 1fr)
      var(--landscape-battle-center-width)
      minmax(0, 1fr);
    gap: var(--landscape-battle-gap);
    min-height: var(--landscape-battle-stage-height);
    padding: 5px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .battle-result.has-stage-special-choice {
    isolation: isolate;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .battle-result.has-stage-special-choice .battle-stage {
    z-index: 10;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout
    .battle-result.has-stage-special-choice .battle-calc-stack {
    z-index: 0;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-stage-direct {
    min-height: calc(var(--landscape-battle-stage-height) + 6px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-stage .battle-special-wait-choice-overlay {
    z-index: 90;
    top: 12px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    /* body直下の戦闘外候補とも幅を揃える。 */
    width: min(var(--special-wait-landscape-width, 366px), calc(100vw - 24px));
    max-height: min(260px, 70dvh);
    overflow: auto;
    background:
      linear-gradient(180deg, rgba(255, 231, 154, 0.14), transparent 42%),
      rgba(16, 13, 7, 0.96);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
    isolation: isolate;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-unit-wrap {
    width: min(var(--landscape-battle-unit-width), 100%);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-commander-badge {
    top: -6px;
    padding: 2px 7px;
    font-size: var(--landscape-text-md);
    line-height: 1;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-anchor {
    width: min(var(--landscape-battle-unit-width), 100%);
    --battle-magic-circle-hand-offset:
      clamp(3px, calc(var(--landscape-battle-unit-width) * 0.0526), 4px);
    --battle-magic-spell-impact-x:
      calc(var(--landscape-battle-unit-width) * 0.7763);
    --battle-magic-spell-cast-y:
      calc(var(--landscape-battle-unit-width) * -0.1053);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-layer {
    inset: 5px;
    grid-template-columns:
      minmax(0, 1fr)
      var(--landscape-battle-center-width)
      minmax(0, 1fr);
    gap: var(--landscape-battle-gap);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-card {
    bottom: calc(var(--landscape-battle-unit-width) * 0.2632);
    width: var(--landscape-battle-weapon-width);
    border-left-width: 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-left {
    right: calc(var(--landscape-battle-unit-width) * -0.1842);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-right {
    left: calc(var(--landscape-battle-unit-width) * -0.1447);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-card.has-card-art {
    bottom: calc(var(--landscape-battle-unit-width) * 0.1579);
    width: var(--landscape-battle-weapon-art-width);
    height: auto;
    aspect-ratio: var(--landscape-battle-weapon-art-aspect);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-left.has-card-art {
    right: calc(var(--landscape-battle-unit-width) * -0.4737);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-right.has-card-art {
    left: calc(var(--landscape-battle-unit-width) * -0.4737);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-card.battle-magic-book.has-card-art {
    bottom: calc(var(--landscape-battle-unit-width) * 0.1842);
    width: var(--landscape-battle-book-width);
    height: auto;
    aspect-ratio: var(--landscape-battle-book-aspect);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-card.battle-magic-spell.has-card-art {
    bottom: calc(var(--landscape-battle-unit-width) * 0.0789);
    width: var(--landscape-battle-spell-width);
    height: auto;
    aspect-ratio: var(--landscape-battle-spell-aspect);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-left.battle-magic-spell.has-card-art {
    right: calc(var(--landscape-battle-unit-width) * -0.5658);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-right.battle-magic-spell.has-card-art {
    left: calc(var(--landscape-battle-unit-width) * -0.5658);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-magic-circle {
    width: var(--landscape-battle-circle-size);
    height: var(--landscape-battle-circle-size);
    margin:
      calc(var(--landscape-battle-circle-size) * -0.5)
      0
      0
      calc(var(--landscape-battle-circle-size) * -0.5);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-magic-circle-spell {
    width: var(--landscape-battle-spell-circle-size);
    height: var(--landscape-battle-spell-circle-size);
    margin:
      calc(var(--landscape-battle-spell-circle-size) * -0.5)
      0
      0
      calc(var(--landscape-battle-spell-circle-size) * -0.5);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-magic-circle-book::after {
    width: calc(var(--landscape-battle-unit-width) * 0.8158);
    height: 7px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attribute-effects {
    --effect-render-size:
      min(var(--effect-mobile-size, 138px), var(--landscape-battle-effect-max-size));
    inset: var(--landscape-battle-gap);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attribute-image-effect-arrow {
    width:
      min(
        calc(var(--effect-render-size) * 1.45),
        calc(var(--landscape-control-column-width) * 0.92)
      );
    height:
      min(
        calc(var(--effect-render-size) * 1.45),
        calc(var(--landscape-control-column-width) * 0.92)
      );
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-route-placeholder span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-term em {
    font-size: var(--landscape-text-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-empty,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-call-caption,
  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-labels,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-plus {
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-title,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-route-placeholder strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-special-wait-choice-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-wait,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-interrupt-detail span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-title > span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-term strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-total {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-process-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-correction-head strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-interrupt-detail strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-labels strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-title strong {
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .final-blow .battle-result-head strong {
    font-size: calc(var(--landscape-text-xl) + 2px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info strong {
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate strong {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-cancel,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-special-wait-skip {
    font-size: var(--landscape-text-xl);
    font-weight: 800;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-damage {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-result.damage-calc-staged .battle-result-head span {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-process-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-correction-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-head small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-head small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-head small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-position-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-special-wait-choice-head span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-ko {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-step-trail span {
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-step-trail {
    grid-template-columns: repeat(5, auto);
    gap: 2px;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-step-trail span {
    padding-inline: 1px;
    letter-spacing: 0;
    font-size: var(--landscape-text-sm);
  }

  @container battle-viewport (max-width: 210px) {
    .battle-panel > * {
      --battle-step-row: 36px;
    }

    body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel .battle-step-trail {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      grid-template-rows: repeat(2, minmax(0, 1fr));
    }
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-attack-position-columns {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--landscape-battle-choice-width) + 12px)), 1fr));
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .cost-payable-full {
    display: none;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .cost-payable-compact {
    display: inline;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-labels {
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    gap: 2px;
    font-size: clamp(9px, 3.6cqi, 12px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-labels strong {
    font-size: 1.35em;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-damage {
    box-sizing: border-box;
    max-width: 100%;
    padding-inline: 3px;
    font-size: inherit;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .clash-ko {
    font-size: inherit;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .phase-status-heading {
    flex-wrap: wrap;
    row-gap: 0;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-attack-position-head {
    flex-wrap: wrap;
    gap: 2px;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-name {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-card-name {
    right: 3px;
    bottom: 3px;
    left: 3px;
    padding: 2px 3px;
    overflow: visible;
    font-size: var(--landscape-text-sm);
    line-height: 1.1;
    text-overflow: clip;
    white-space: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-avatar-target span {
    right: 3px;
    bottom: 3px;
    left: 3px;
    padding: 2px 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-no-weapon {
    padding: 2px 4px;
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-name {
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-columns,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-formula-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-route {
    grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr);
    gap: 3px;
    padding: 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-route .battle-choice-card,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-route .battle-route-placeholder {
    width: 100%;
    min-width: 0;
    max-width: var(--landscape-battle-choice-width);
    justify-self: center;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-route-arrow {
    width: 20px;
    height: 20px;
    font-size: var(--landscape-text-xl);
  }

/* 背の低いスマホ横は攻撃候補まわりの余白だけを詰める。 */
@media (orientation: landscape) and (max-height: 530px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-attack-panel:has(> .battle-attack-choice-section) {
    grid-template-rows: repeat(4, auto) 1fr;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-attack-choice-section {
    --attack-choice-vertical-space: clamp(1px, calc((var(--landscape-control-height) - 320px) / 28), 4px);
    row-gap: calc(var(--attack-choice-vertical-space) + 1px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-attack-position-group {
    row-gap: var(--attack-choice-vertical-space);
    padding-block-end: min(3px, var(--attack-choice-vertical-space));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-attack-position-head {
    min-height: calc(16px + var(--attack-choice-vertical-space));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-attack-position-group .battle-choice-list {
    padding-block-end: min(3px, var(--attack-choice-vertical-space));
  }
}

/* スマホ横の特殊ウェイトと、英語の選択候補の幅を調整する。 */
@media (orientation: landscape) and (max-height: 620px) {
  body.mobile-landscape-layout {
    /* 中央の操作枠より左右8pxずつ広げ、端末幅に追従させる。 */
    --special-wait-landscape-width: calc(var(--landscape-control-column-width) + 16px);
  }

  body.mobile-landscape-layout > .nonbattle-special-wait-panel {
    left: calc(
      var(--app-viewport-offset-left) + var(--app-viewport-width) * 0.5
      + (max(4px, var(--app-safe-left)) - max(4px, var(--app-safe-right))) * 0.5
    );
  }

  body.mobile-landscape-layout .battle-special-wait-choice-head:has(> .friend-choice-deadline) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 2px;
  }

  body.mobile-landscape-layout .battle-special-wait-choice-head > .friend-choice-deadline {
    grid-column: 1 / -1;
    justify-self: end;
    margin-inline-start: 0;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout {
    --landscape-battle-choice-width: 76px;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-choice-card {
    flex-basis: var(--landscape-battle-choice-width);
  }

  /* 武器選択の文字は盤面カード用の縮小を適用せず、元の戦闘UIサイズに戻す。 */
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-card-info strong,
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-empty {
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-card-info span,
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-card-info small,
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-estimate span,
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-estimate small {
    font-size: var(--landscape-text-xs);
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .battle-weapon-panel .battle-choice-estimate strong {
    font-size: var(--landscape-text-lg);
  }
}

/* スマホ横の戦闘枠は安全域の手前まで伸ばす。 */
@media (orientation: landscape) and (max-height: 500px),
  (orientation: landscape) and (max-width: 900px) and (max-height: 620px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel.has-pending-battle {
    --landscape-control-height: var(--landscape-battle-height-limit);
    --landscape-battle-frame-bottom-padding: 0px;
  }

  #app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] {
    --landscape-battle-choice-width: var(--landscape-attack-choice-width);
  }

  #app.mobile-landscape-layout:lang(en) #battlePanel[data-mode="attack-choice"] .battle-attack-position-columns {
    grid-template-columns:
      minmax(calc(var(--landscape-battle-choice-width) + 12px), var(--attack-front-track, 1fr))
      minmax(calc(var(--landscape-battle-choice-width) + 12px), var(--attack-back-track, 1fr));
  }

  #app.mobile-landscape-layout:lang(en) #battlePanel[data-mode="attack-choice"] .battle-attack-head > small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #app.mobile-landscape-layout:lang(en) #battlePanel[data-mode="attack-choice"] .battle-choice-card .battle-choice-commander-badge {
    left: auto;
    right: 0;
    padding-inline: 1px;
    font-size: 5px;
    transform: none;
  }

  #app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-route-placeholder {
    padding-inline: 4px;
  }

  #app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"]
    :is(.battle-route-placeholder > span, .battle-choice-empty) {
    font-size: var(--landscape-text-md);
  }

  #app.mobile-landscape-layout #battlePanel[data-mode="attack-choice"] .battle-route-placeholder > strong {
    font-size: var(--landscape-text-lg);
    text-wrap: balance;
  }

  #app.mobile-landscape-layout .battle-blocker-choice-section .battle-choice-none .battle-choice-card-info > strong {
    font-size: 8px;
  }
}

/* 「ブロックしない」は選択肢の意味が分かるように全文を表示する。 */
@media (orientation: portrait) and (max-width: 620px),
  (orientation: landscape) and (max-height: 500px),
  (orientation: landscape) and (max-width: 900px) and (max-height: 620px) {
  #app:is(.mobile-layout, .mobile-landscape-layout) .battle-blocker-choice-section .battle-choice-none .battle-choice-card-info > strong {
    white-space: normal;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }
}

/* スマホ横は、武器を構えた演出の下に並ぶ左右の説明欄を日英共通で一段小さくする。 */
@media (orientation: landscape) and (max-height: 620px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-process-only .battle-process-detail .battle-process-weapon {
    font-size: clamp(9px, calc(2.5cqi - 2px), 15px);
  }
}

/* スマホ横のカード内文字だけを詰め、確定操作はフェイズ操作と揃える。 */
@media (orientation: landscape) and (max-height: 620px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-card-name,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-avatar-target span {
    font-size: calc(var(--landscape-text-sm) - 0.5px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info strong,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card-info small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-empty,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate small,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card .battle-commander-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-route-placeholder span,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-route-placeholder strong {
    font-size: var(--landscape-zone-text-xs);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-estimate strong {
    font-size: calc(var(--landscape-text-lg) - 1px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-commander-badge {
    font-size: calc(var(--landscape-text-md) - 1px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-commander-badge {
    min-width: 0;
    padding-inline: 5px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-actions button {
    font-size: var(--landscape-text-xl);
    line-height: 1.12;
  }
}

  /*
    非戦闘特殊の候補はプレイヤーパネルの追加行にせず、盤面上の小型オーバーレイにする。
  */
  body.mobile-landscape-layout .app.mobile-landscape-layout .nonbattle-special-wait-panel {
    position: absolute;
    z-index: 89;
    top: calc(var(--landscape-player-head-height) + 4px);
    left: 4px;
    right: 4px;
    max-height: calc(100% - var(--landscape-player-head-height) - 8px);
    overflow: auto;
    pointer-events: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .nonbattle-special-wait-panel .battle-special-wait-choice-panel {
    max-height: 150px;
    padding: 5px;
    overflow: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .nonbattle-special-wait-panel .battle-choice-list {
    max-height: 94px;
    overflow: auto;
  }

  body.mobile-landscape-layout .phase-notice {
    top:
      calc(
        var(--mobile-viewport-offset-top, 0px)
        + max(1px, env(safe-area-inset-top))
        + var(--landscape-player-head-height, 36px)
        + 4px
      );
    right: max(8px, env(safe-area-inset-right));
    bottom: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  body.mobile-landscape-layout .phase-notice.notice-special-wait {
    z-index: 1500;
    top:
      calc(
        var(--mobile-viewport-offset-top, 0px)
        + max(1px, env(safe-area-inset-top))
      );
  }

  body.mobile-landscape-layout .phase-card {
    min-width:
      min(300px, calc(var(--mobile-viewport-width, 100dvw) - 24px));
    padding: 8px 12px;
  }

  body.mobile-landscape-layout .phase-notice.notice-special-wait .phase-card {
    width: clamp(160px, 26dvw, 220px);
    min-width: 0;
    padding: 7px 9px;
  }

  body.mobile-landscape-layout .phase-card-with-art {
    width:
      min(340px, calc(var(--mobile-viewport-width, 100dvw) - 24px));
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 14px;
    padding: 7px 11px 7px 7px;
  }

  body.mobile-landscape-layout .notice-card-art,
  body.mobile-landscape-layout .notice-player-avatar {
    width: 60px;
  }

  body.mobile-landscape-layout .phase-copy > span {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .phase-card strong {
    margin-top: 2px;
    font-size: calc(var(--landscape-text-xl) + 4px);
  }

  body.mobile-landscape-layout .phase-card em,
  body.mobile-landscape-layout .phase-card small {
    margin-top: 4px;
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .game-start-copy {
    gap: 1px;
    padding: 7px 26px 9px;
  }

  body.mobile-landscape-layout .game-start-copy span {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .game-start-copy strong,
  body.mobile-landscape-layout .finish-duel-notice .game-start-copy strong {
    font-size: clamp(42px, 14dvh, 58px);
  }

  body.mobile-landscape-layout .game-start-copy em {
    margin-top: 5px;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .finish-overlay {
    --finish-inset-top: max(10px, var(--app-safe-top));
    --finish-inset-bottom: max(10px, var(--app-safe-bottom));
    top: var(--mobile-viewport-offset-top, 0px);
    right: auto;
    bottom: auto;
    left: var(--mobile-viewport-offset-left, 0px);
    width: var(--mobile-viewport-width, 100dvw);
    height: var(--mobile-viewport-height, 100dvh);
    align-items: center;
    padding:
      var(--finish-inset-top)
      max(12px, var(--app-safe-right))
      var(--finish-inset-bottom)
      max(12px, var(--app-safe-left));
  }

  body.mobile-landscape-layout .finish-overlay-panel {
    width: min(420px, calc(var(--mobile-viewport-width, 100dvw) - 24px));
    max-height: calc(var(--app-viewport-height) - var(--finish-inset-top) - var(--finish-inset-bottom));
    gap: 7px;
    padding: 11px 13px 12px;
  }

  body.mobile-landscape-layout .finish-overlay-kicker {
    font-size: clamp(11px, 3dvh, 13px);
  }

  body.mobile-landscape-layout .finish-overlay h2 {
    font-size: clamp(30px, 10dvh, 42px);
  }

  body.mobile-landscape-layout .finish-overlay-detail {
    font-size: clamp(13px, 3.6dvh, 15px);
  }

  body.mobile-landscape-layout .finish-overlay-button {
    min-height: 40px;
    padding: 7px 10px;
    font-size: clamp(14px, 4dvh, 16px);
  }

  body.mobile-landscape-layout .tutorial-guide,
  body.mobile-landscape-layout .tutorial-guide-complete {
    --landscape-tutorial-control-width:
      clamp(168px, calc(var(--mobile-viewport-width, 100dvw) * 0.28), 300px);
    --landscape-tutorial-field-width:
      calc(
        (
          var(--mobile-viewport-width, 100dvw)
          - var(--landscape-tutorial-control-width)
          - max(4px, env(safe-area-inset-left))
          - max(4px, env(safe-area-inset-right))
        ) * 0.5
      );
    --landscape-tutorial-content-inset: 14px;
    --landscape-tutorial-bubble-height: 122px;
    bottom: max(10px, env(safe-area-inset-bottom));
    right: max(4px, env(safe-area-inset-right));
    left: auto;
    width: var(--landscape-tutorial-field-width);
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    height: 140px;
    min-height: 140px;
    max-height: 140px;
    padding-right: 0;
    transform: none;
  }

  body.mobile-landscape-layout .tutorial-guide-complete {
    grid-template-rows: minmax(0, 1fr);
    height: 170px;
    min-height: 170px;
    max-height: 170px;
  }

  body.mobile-landscape-layout .tutorial-guide-portrait {
    position: absolute;
    right: var(--landscape-tutorial-content-inset);
    left: auto;
    bottom: calc(var(--landscape-tutorial-bubble-height) + 4px);
    width: 98px;
    height: 140px;
    max-height: 140px;
    margin: 0;
    transform: none;
  }

  body.mobile-landscape-layout .tutorial-guide-bubble,
  body.mobile-landscape-layout .tutorial-guide-complete .tutorial-guide-bubble {
    align-self: end;
    width: 100%;
    height: var(--landscape-tutorial-bubble-height);
    min-height: var(--landscape-tutorial-bubble-height);
    max-height: var(--landscape-tutorial-bubble-height);
    padding: 8px 32px 8px 10px;
  }

  body.mobile-landscape-layout .tutorial-guide-head {
    gap: 5px;
    margin-bottom: 3px;
    font-size: var(--landscape-tutorial-text-sm);
  }

  body.mobile-landscape-layout .tutorial-guide-bubble strong {
    font-size: calc(var(--landscape-tutorial-text-xl) + 1px);
  }

  body.mobile-landscape-layout .tutorial-guide-bubble p {
    margin-top: 3px;
    font-size: calc(var(--landscape-tutorial-text-lg) + 1px);
    line-height: 1.32;
  }

  body.mobile-landscape-layout .tutorial-guide-actions {
    gap: 6px;
    margin-top: 5px;
  }

  body.mobile-landscape-layout .tutorial-guide-complete-actions {
    position: absolute;
    grid-column: 1;
    grid-row: 1;
    right: calc(var(--landscape-tutorial-content-inset) + 104px);
    bottom: calc(var(--landscape-tutorial-bubble-height) + 6px);
    left: 8px;
    justify-content: flex-start;
    margin-top: 0;
  }

  body.mobile-landscape-layout .tutorial-guide-complete:has(.tutorial-guide-actions-with-match) .tutorial-guide-portrait {
    bottom: calc(var(--landscape-tutorial-bubble-height) + 46px);
  }

  body.mobile-landscape-layout .tutorial-guide-complete-actions.tutorial-guide-actions-with-match {
    right: 0;
    left: auto;
    width: max-content;
  }

  body.mobile-landscape-layout .tutorial-guide-next {
    min-width: 94px;
    min-height: 36px;
    padding: 5px 10px;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .tutorial-guide-next-icon {
    right: 7px;
    bottom: 6px;
    width: 20px;
    height: 20px;
    font-size: var(--landscape-text-sm);
  }

  body.mobile-landscape-layout .grave-modal,
  body.mobile-landscape-layout .cost-modal,
  body.mobile-landscape-layout .mobile-utility-modal {
    --utility-modal-gutter: 8px;
  }

  body.mobile-landscape-layout .grave-modal-panel,
  body.mobile-landscape-layout .cost-modal-panel,
  body.mobile-landscape-layout .mobile-utility-panel {
    max-height: var(--utility-modal-available-height);
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
  }

  body.mobile-landscape-layout .grave-modal-panel,
  body.mobile-landscape-layout .cost-modal-panel {
    width: min(520px, 86dvw);
  }

  body.mobile-landscape-layout .mobile-options-modal .mobile-utility-panel,
  body.mobile-landscape-layout .mobile-log-modal .mobile-utility-panel {
    width: min(540px, 86dvw);
  }

  body.mobile-landscape-layout .mobile-utility-head h2,
  body.mobile-landscape-layout .grave-modal-head h2,
  body.mobile-landscape-layout .cost-modal-head h2 {
    font-size: calc(var(--landscape-text-xl) + 2px);
  }

  body.mobile-landscape-layout .grave-modal-close,
  body.mobile-landscape-layout .cost-modal-close,
  body.mobile-landscape-layout .mobile-utility-close {
    min-height: 36px;
    padding: 5px 10px;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .mobile-log-modal .log-head {
    justify-content: flex-end;
    padding-block: 5px;
  }

  body.mobile-landscape-layout .mobile-log-modal .log-head h2 {
    display: none;
  }

  body.mobile-landscape-layout .grave-modal-list,
  body.mobile-landscape-layout .cost-modal-body,
  body.mobile-landscape-layout .mobile-utility-body {
    min-height: 0;
    gap: 6px;
  }

  body.mobile-landscape-layout .mobile-options-body {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 6px;
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .mobile-options-body :is(
    .toggle-option,
    .volume-option,
    .speed-mode-group,
    .match-autosave-option,
    .player-setup-field
  ) {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .mobile-options-body :is(button, select, .topbar-link) {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .mobile-log-modal .log {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .mobile-log-modal .log-head button {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .mobile-options-body .option-section {
    gap: 6px;
    padding: 7px;
  }

  body.mobile-landscape-layout .mobile-options-body .option-sound-list,
  body.mobile-landscape-layout .mobile-options-body .option-play-list {
    gap: 6px;
  }

  body.mobile-landscape-layout .option-section-title {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .grave-card-row {
    grid-template-columns: 26px 42px minmax(0, 1fr);
    gap: 7px;
    padding: 6px;
  }

  body.mobile-landscape-layout .grave-order {
    width: 24px;
    height: 24px;
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .grave-thumb {
    width: 40px;
  }

  body.mobile-landscape-layout .grave-card-text strong {
    font-size: var(--landscape-text-lg);
  }

  body.mobile-landscape-layout .grave-card-meta,
  body.mobile-landscape-layout .grave-modal-head p,
  body.mobile-landscape-layout .cost-modal-head p {
    font-size: var(--landscape-text-sm);
  }

  /* クリック表示は、開いた時に計測した中央詳細欄と同じ寸法へ揃える。 */
  body.mobile-landscape-layout .art-modal {
    inset: auto;
    top: var(--app-viewport-offset-top);
    left: var(--app-viewport-offset-left);
    width: var(--app-viewport-width);
    height: var(--app-viewport-height);
    padding: var(--app-safe-top) var(--app-safe-right) var(--app-safe-bottom) var(--app-safe-left);
  }

  body.mobile-landscape-layout .art-modal-card {
    --card-detail-label-font-size: var(--landscape-font-lg);
    --card-detail-awaken-font-size: var(--landscape-font-lg);
    width: var(--art-modal-source-width, clamp(168px, calc(var(--mobile-viewport-width, 100dvw) * 0.28), 300px));
    height: var(--art-modal-source-height, calc(var(--mobile-viewport-height, 100dvh) - 92px));
    min-height: 0;
    max-width: var(--app-usable-width);
    max-height: calc(var(--app-usable-height) - 16px);
    padding: 5px;
    border-radius: var(--card-corner-radius);
  }

  body.mobile-landscape-layout .art-modal-text {
    right: 11px;
    bottom: 11px;
    left: 11px;
    max-height: 46%;
    padding: 7px 8px 8px;
    border-radius: 6px;
    font-size: var(--landscape-font-lg);
    line-height: 1.25;
  }

  body.mobile-landscape-layout .art-modal-close {
    position: absolute;
    top: max(6px, var(--app-safe-top));
    right: max(8px, var(--app-safe-right));
    min-width: 52px;
    min-height: 30px;
    padding: 4px 9px;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout > .special-stack-panel,
  body.mobile-landscape-layout > .special-stack-panel.special-stack-frozen {
    --floating-special-bottom-inset: max(8px, var(--app-safe-bottom));
    position: fixed;
    top: calc(var(--app-viewport-offset-top) + var(--app-viewport-height) - var(--floating-special-bottom-inset));
    right: auto;
    bottom: auto;
    left: calc(var(--app-viewport-offset-left) + var(--app-viewport-width) - max(8px, var(--app-safe-right)));
    z-index: 1600;
    display: grid;
    grid-template-rows: auto;
    grid-area: auto;
    width: max-content;
    max-width: calc(var(--app-usable-width) - 16px);
    min-width: 0;
    height: auto;
    min-height: 0;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transform: translate(-100%, -100%);
    pointer-events: none;
  }

  body.mobile-landscape-layout > .special-stack-panel .special-wait-option,
  body.mobile-landscape-layout > .special-stack-panel.special-stack-frozen .special-wait-option {
    position: relative;
    width: auto;
    height: auto;
    min-width: 72px;
    min-height: 36px;
    padding: 5px 7px;
    border: 1px solid rgba(170, 156, 255, 0.48);
    border-radius: 8px;
    background:
      linear-gradient(180deg, rgba(94, 82, 150, 0.28), rgba(22, 18, 39, 0.76)),
      rgba(31, 27, 49, 0.76);
    backdrop-filter: blur(5px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    pointer-events: auto;
  }

  body.mobile-landscape-layout > .special-stack-panel .special-wait-label {
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout > .special-stack-panel .special-wait-state {
    min-width: 26px;
    padding: 2px 7px;
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout:has(.grave-modal.show) > .special-stack-panel,
  body.mobile-landscape-layout:has(.cost-modal.show) > .special-stack-panel,
  body.mobile-landscape-layout:has(.mobile-utility-modal.show) > .special-stack-panel {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

/*
  タブレット横画面は3列を保ち、3体の戦士が収まる横幅から倍率を決める。
  手札・コストは余白を保って5枚が収まる幅と戦士の高さを上限にする。
*/
@media (orientation: landscape) and (min-height: 621px) and (max-height: 1100px) and (max-width: 1400px),
  (orientation: landscape) and (min-width: 901px) and (min-height: 501px) and (max-height: 620px) and (max-width: 1400px) {
  body.mobile-landscape-layout {
    /* ブラウザのバーで高さが減っても、PC型の盤面を横へ引き伸ばしすぎない。 */
    --tablet-landscape-layout-width: min(var(--app-usable-width), calc(var(--app-usable-height) * 1.9));
    --tablet-landscape-row-inset: 52px;
    --landscape-text-xs: clamp(12px, 1.5dvh, 15px);
    --landscape-text-sm: clamp(13px, 1.7dvh, 17px);
    --landscape-text-md: clamp(14px, 1.9dvh, 19px);
    --landscape-text-lg: clamp(16px, 2.2dvh, 22px);
    --landscape-text-xl: clamp(20px, 2.7dvh, 27px);
    --tablet-landscape-button-text: clamp(16px, calc(1.8dvh + 1px), 19px);
    --landscape-zone-text-xs: var(--landscape-text-xs);
    --landscape-zone-text-sm: var(--landscape-text-sm);
    --landscape-zone-text-md: var(--landscape-text-md);
    --landscape-zone-text-lg: var(--landscape-text-lg);
    --landscape-tutorial-text-sm: var(--landscape-text-sm);
    --landscape-tutorial-text-lg: var(--landscape-text-lg);
    --landscape-tutorial-text-xl: var(--landscape-text-xl);
    --landscape-empty-emblem-bottom: 7px;
    --landscape-player-head-height:
      clamp(52px, calc(var(--app-usable-height) * 0.08), 84px);
    --tablet-landscape-control-width: clamp(300px, calc(var(--tablet-landscape-layout-width) * 0.28), 396px);
    --tablet-landscape-zone-card-width:
      min(
        calc((var(--app-usable-height) - var(--landscape-player-head-height) - (var(--tablet-landscape-board-card-height) + 10px) * 2 - 70px) / 2 * var(--compact-card-aspect-width) / var(--compact-card-aspect-height)),
        /* 外枠2px・ゾーン10px・手札20pxの左右余白と、カード間6px×4を確保する。 */
        calc(((var(--tablet-landscape-layout-width) - var(--tablet-landscape-control-width) - 16px) / 2 - 56px) / 5),
        calc(var(--tablet-landscape-board-card-height) * var(--compact-card-aspect-width) / var(--compact-card-aspect-height))
      );
    --tablet-landscape-card-height:
      calc(
        var(--tablet-landscape-zone-card-width)
        * var(--compact-card-aspect-height)
        / var(--compact-card-aspect-width)
      );
    --tablet-landscape-board-card-height:
      min(
        calc(var(--app-usable-height) * 0.195),
        calc(((var(--tablet-landscape-layout-width) - var(--tablet-landscape-control-width) - 16px) / 2 - var(--tablet-landscape-row-inset) - 33px) / 3 * var(--board-card-aspect-height) / var(--board-card-aspect-width))
      );
    --tablet-landscape-stage-height:
      calc(
        var(--landscape-player-head-height)
        + (var(--tablet-landscape-board-card-height) + 10px) * 2
        + 4px
        + var(--tablet-landscape-card-height) * 2
        + 48px
      );
    --tablet-landscape-stage-offset:
      max(
        0px,
        calc(
          (
            var(--mobile-viewport-height, 100dvh)
            - var(--tablet-landscape-stage-height)
          ) / 2
        )
      );
  }

  body.mobile-landscape-layout:lang(en) {
    --tablet-landscape-row-inset: max(52px, calc(var(--landscape-zone-text-sm) * 3.5 + 20px));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .first-launch-opening:not(.is-name-editing) .first-launch-dialog {
    align-self: start;
    margin: clamp(96px, 17dvh, 148px) 7px 7px;
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open {
    align-items: start;
    justify-items: center;
    padding:
      max(20px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .first-launch-opening:not(.is-name-editing) {
    width: min(920px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
    height:
      min(
        clamp(600px, 78dvh, 680px),
        calc(var(--mobile-viewport-height, 100dvh) - 40px)
      );
    min-height: 0;
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 40px);
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .first-launch-opening.is-name-editing {
    align-self: start;
    width: min(680px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
    height: min(560px, calc(var(--mobile-viewport-height, 100dvh) - 40px));
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 40px);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open {
    place-items: start center;
    padding:
      max(20px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup {
    --tablet-match-opponent-card-width: clamp(82px, 10.5dvh, 96px);
    align-self: start;
    width: min(1040px, calc(var(--mobile-viewport-width, 100dvw) - 40px));
    height:
      min(
        clamp(480px, 64dvh, 560px),
        calc(var(--mobile-viewport-height, 100dvh) - 40px)
      );
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 40px);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-opponent-group-list {
    grid-template-columns: repeat(3, var(--tablet-match-opponent-card-width));
    justify-content: start;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    :is(
      .player-match-opponent-group-level4,
      .player-match-opponent-group-self,
      .player-match-opponent-group-random
    ) .player-match-opponent-group-list {
    grid-template-columns: var(--tablet-match-opponent-card-width);
  }

  /* 横の交換は既存の外枠・倍率を保ち、相手を6体ずつ見渡せる密度にする。 */
  body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup {
    --player-match-character-icon-size: clamp(68px, 6dvw, 82px);
    --landscape-menu-text-xs: 12px;
    --landscape-menu-text-sm: 13px;
    --landscape-menu-text-md: 14px;
    --landscape-menu-text-lg: 16px;
    --landscape-menu-text-xl: 20px;
    width: min(1160px, calc(var(--app-usable-width) - 40px));
    height: min(640px, calc(var(--app-usable-height) - 40px));
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-setup-body {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup :is(.player-match-loadout, .player-match-opponents) {
    padding: 12px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-deck-preview {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup :is(.player-match-extra-button, .player-match-setup-trade) {
    width: 104px;
    min-width: 104px;
    min-height: 44px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-deck-character {
    justify-self: center;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-setup-cards {
    gap: 10px;
    max-width: none;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-setup-card {
    width: min(100%, clamp(120px, 12dvw, 168px));
    height: auto;
    max-height: none;
    aspect-ratio: 118 / 150;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) :is(.player-match-opponent-group-list, .player-match-opponent-final-row) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-final-row .player-match-opponent-group-list {
    grid-template-columns: minmax(0, 1fr);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup :is(.player-match-opponent, .player-academy-story-opponent) {
    --player-match-opponent-portrait-size: clamp(52px, 5dvw, 68px);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-opponent {
    min-height: 112px;
    gap: 5px;
    padding: 8px 3px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-opponent-name {
    font-size: 13px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup .player-match-trade-opponent-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open:has(.player-match-setup:not(.is-trade-mode)) {
    place-items: center;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open .player-match-setup:not(.is-trade-mode) {
    --player-match-character-icon-size: clamp(88px, 11dvh, 116px);
    --landscape-menu-text-xs: clamp(12px, 1.4dvh, 14px);
    --landscape-menu-text-sm: clamp(14px, 1.6dvh, 16px);
    --landscape-menu-text-md: clamp(16px, 1.8dvh, 18px);
    --landscape-menu-text-lg: clamp(18px, 2.2dvh, 22px);
    --landscape-menu-text-xl: clamp(23px, 2.7dvh, 28px);
    align-self: center;
    width: min(1320px, calc(var(--app-usable-width) - 40px));
    height: min(800px, calc(var(--app-usable-height) - 40px));
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) :is(.player-match-opponent, .player-academy-story-opponent) {
    --player-match-opponent-portrait-size: clamp(72px, 9.5dvh, 100px);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent {
    min-height: clamp(150px, 20dvh, 190px);
    gap: 8px;
    padding-block: 12px;
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-opponent-name {
    font-size: var(--landscape-menu-text-md);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) :is(.player-match-opponent-wins, .player-match-opponent-unlock, .player-match-deck-character small, .player-match-setup-deck-link small) {
    font-size: var(--landscape-menu-text-xs);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-setup-card-name {
    font-size: var(--landscape-menu-text-sm);
  }

  body.mobile-landscape-layout .title-screen.title-match-setup-open
    .player-match-setup:not(.is-trade-mode) .player-match-deck-select-wrap select {
    min-height: 44px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout {
    --compact-card-min-width: 72px;
    --compact-card-max-width: 96px;
    --landscape-zone-card-width: var(--tablet-landscape-zone-card-width);
    --landscape-control-column-width: var(--tablet-landscape-control-width);
    --landscape-board-card-height: var(--tablet-landscape-board-card-height);
    --tablet-landscape-board-card-width: calc(var(--landscape-board-card-height) * var(--board-card-aspect-width) / var(--board-card-aspect-height));
    --tablet-landscape-unit-name-size: calc((var(--tablet-landscape-board-card-width) - 14px) / 7);
    --landscape-lane-height: calc(var(--landscape-board-card-height) + 10px);
    --compact-row-height: calc(var(--compact-card-height) + 18px);
    --landscape-hand-row-height: calc(var(--compact-card-height) + 30px);
    --landscape-avatar-size:
      clamp(42px, calc(var(--landscape-player-head-height) - 10px), 68px);
    --landscape-header-tool-width:
      clamp(34px, calc(var(--landscape-avatar-size) - 4px), 44px);
    --landscape-header-tool-height:
      clamp(38px, calc(var(--landscape-player-head-height) - 10px), 48px);
    --landscape-battle-choice-width: 92px;
    --landscape-battle-gap: 8px;
    --landscape-battle-center-width: 54px;
    --landscape-battle-unit-width:
      clamp(
        76px,
        calc(
          (
            var(--landscape-control-column-width)
            - var(--landscape-battle-center-width)
            - var(--landscape-battle-gap)
            - var(--landscape-battle-gap)
            - 40px
          ) * 0.5
        ),
        150px
      );
    --landscape-battle-stage-height:
      calc(var(--landscape-battle-unit-width) * 1.5 + 34px);
    --landscape-battle-step-height: 24px;
    --landscape-battle-head-height: max(100px, calc(var(--landscape-text-xl) * 1.2 + var(--landscape-text-md) * 5 + 12px));
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + (var(--app-usable-width) - var(--tablet-landscape-layout-width)) / 2);
    width: var(--tablet-landscape-layout-width);
    overflow-y: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .table {
    align-self: start;
    align-items: start;
    height: auto;
    min-height: var(--landscape-stage-min-height);
    margin-block: auto;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head,
  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .player-head {
    --landscape-font-lg: var(--tablet-hud-title-font);
    --landscape-font-sm: var(--tablet-hud-meta-font);
    padding-right: max(10px, var(--player-header-ornament-width));
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --landscape-header-tool-width: clamp(34px, calc(var(--landscape-avatar-size) - 4px), 44px);
    --landscape-header-tool-height: clamp(38px, calc(var(--landscape-player-head-height) - 10px), 48px);
    --player-surrender-width: 28px;
    --player-surrender-height: 28px;
    --player-surrender-icon-size: 16px;
    --player-surrender-hit-inset: -8px 0 -8px -16px;
  }

  /* 低いタブレット枠でも、白旗をスマホ用グリッドの右端へ離さない。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head > .player-identity {
    display: block;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .player-name-row {
    display: flex;
    gap: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .mobile-log-tool {
    font-size: 20px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-name {
    line-height: 1.2;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-flags {
    line-height: 1.25;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .pile-stats {
    /* 低い横画面でも、スマホ用の狭い列幅で墓地欄を右端へ押し出さない。 */
    grid-template-columns: var(--landscape-header-tool-width) 48px repeat(2, 34px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .pile-stats > .pile {
    min-width: 34px;
    padding-inline: 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-pile {
    min-width: 48px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-icons {
    --life-icon-width: 9px;
    --life-icon-height: 13px;
    --life-icon-gap: 2px;
    height: 13px;
    min-height: 13px;
    gap: var(--life-icon-gap);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .life-icon {
    width: var(--life-icon-width);
    height: var(--life-icon-height);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .mobile-header-tool {
    font-size: var(--landscape-text-xl);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .lane-label {
    top: 5px;
    left: 5px;
    min-width: 40px;
    height: 20px;
    padding-inline: 6px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit-row {
    column-gap: 8px;
    padding: 8px 5px 3px var(--tablet-landscape-row-inset);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit.has-card-art .card-info {
    max-height: calc(100% - 22px);
    padding: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .name {
    width: 7em;
    max-width: 100%;
    min-height: 2.24em;
    max-height: 2.24em;
    font-size: var(--tablet-landscape-unit-name-size);
    line-height: 1.12;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  body.mobile-landscape-layout:lang(en) .app.mobile-landscape-layout .unit .name {
    word-break: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit :is(.unit-stat-line, .stat-line, .tiny) {
    font-size: clamp(11px, calc(var(--tablet-landscape-board-card-width) * 0.095), 18px);
    line-height: 1.1;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .hpbar {
    height: 6px;
    min-height: 6px;
    margin-top: 3px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand .level-badge,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost .level-badge {
    width: clamp(16px, calc(var(--tablet-landscape-zone-card-width) * 0.26), 28px);
    height: clamp(16px, calc(var(--tablet-landscape-zone-card-width) * 0.26), 28px);
    font-size: clamp(8px, calc(var(--tablet-landscape-zone-card-width) * 0.13), 14px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-compact-meta {
    font-size: 0.95em;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .unit .level-badge {
    width: clamp(18px, calc(var(--tablet-landscape-board-card-width) * 0.21), 35px);
    height: clamp(18px, calc(var(--tablet-landscape-board-card-width) * 0.21), 35px);
    font-size: clamp(9px, calc(var(--tablet-landscape-board-card-width) * 0.1), 18px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .cost-zone,
  body.mobile-landscape-layout .app.mobile-landscape-layout .hand-zone {
    grid-template-rows: 14px minmax(0, 1fr);
    padding: 2px 5px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .zone-count {
    min-height: 13px;
    padding: 2px 4px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .control-panel {
    gap: 6px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .status {
    --phase-status-height: max(var(--landscape-selection-state-height), calc(var(--tablet-hud-title-font) * 4 + 16px));
    padding: 7px 8px;
    /* 中央欄は名前・操作ボタンより控えめにし、通常の状況見出しを折り返しにくくする。 */
    font-size: min(var(--tablet-hud-body-font), 20px);
  }

  @media (min-height: 560px) {
    @container battle-viewport (min-width: 264px) {
      .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) > .battle-head-stack:has(.battle-turn-status) {
        /* 見出しの予約済みの行に収め、戦士・武器の行を動かさない。 */
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 3px;
        overflow: hidden;
      }

      .battle-head-stack:has(.battle-turn-status) > .battle-head-copy {
        display: block;
        position: relative;
        min-width: 0;
        overflow: auto;
      }

      .battle-head-stack > .battle-turn-status {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding: 3px 6px;
        border: 1px solid rgba(166, 199, 208, 0.25);
        border-radius: 5px;
        background: rgba(35, 52, 58, 0.82);
        color: #dce9ed;
        font-size: 12px;
        line-height: 1.2;
        white-space: nowrap;
      }

      .battle-turn-status > strong {
        min-width: 0;
        margin-inline-end: auto;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .phase-status-heading {
    flex-wrap: wrap;
    white-space: normal;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .phase-status-heading strong {
    max-width: 100%;
    white-space: nowrap;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection {
    padding: 7px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .selection-detail .selection-text {
    right: 9px;
    bottom: 9px;
    left: 9px;
    padding: 10px 11px 11px;
    font-size: clamp(14px, 1.2dvw, 16px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .actions {
    gap: 6px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .actions button {
    min-height: 50px;
    padding: 6px 8px;
    font-size: var(--tablet-hud-title-font);
  }

  body.mobile-landscape-layout > .special-stack-panel .special-wait-label {
    font-size: var(--tablet-hud-body-font);
    line-height: 1.2;
  }

  /* タブレット横の中央列は狭いため、戦闘欄だけ日英共通で文字を抑える。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel {
    --landscape-text-xs: clamp(10px, 1.2dvh, 12px);
    --landscape-text-sm: clamp(11px, 1.35dvh, 14px);
    --landscape-text-md: clamp(12px, 1.5dvh, 15px);
    --landscape-text-lg: clamp(14px, 1.8dvh, 18px);
    --landscape-text-xl: clamp(17px, 2.2dvh, 22px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-choice-card {
    min-height: 50px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-process-only .battle-process-detail .battle-process-weapon {
    font-size: clamp(10px, calc(2.5cqi - 2px), 15px);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .formula-line {
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand {
    padding-inline: 10px;
    scroll-padding-inline: 10px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .hand,
  body.mobile-landscape-layout .app.mobile-landscape-layout .cost {
    --landscape-zone-card-gap: 6px;
    column-gap: var(--landscape-zone-card-gap);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel button,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel select,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-panel [role="button"] {
    min-height: 46px;
  }

  /* 高さに余裕のあるタブレットでは、WebKitで描画が欠けるstickyを使わず確定ボタンを並べる。 */
  body.mobile-landscape-layout .app.mobile-landscape-layout :is(.battle-attack-actions, .battle-weapon-resolve, .battle-block-resolve) {
    position: relative;
    bottom: auto;
    justify-self: stretch;
    width: 100%;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-actions button {
    font-size: var(--tablet-landscape-button-text);
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-cancel,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-attack-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-weapon-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-block-resolve,
  body.mobile-landscape-layout .app.mobile-landscape-layout .battle-special-wait-skip {
    font-size: var(--tablet-landscape-button-text);
  }

  body.mobile-landscape-layout .tutorial-guide,
  body.mobile-landscape-layout .tutorial-guide-complete {
    --landscape-tutorial-control-width:
      clamp(286px, calc(var(--mobile-viewport-width, 100dvw) * 0.29), 390px);
    --landscape-tutorial-content-inset: 20px;
    --landscape-tutorial-bubble-height: 168px;
    right: max(6px, env(safe-area-inset-right));
    bottom:
      calc(
        var(--tablet-landscape-stage-offset)
        + max(8px, env(safe-area-inset-bottom))
      );
    height: 196px;
    min-height: 196px;
    max-height: 196px;
  }

  body.mobile-landscape-layout .tutorial-guide-complete {
    height: 226px;
    min-height: 226px;
    max-height: 226px;
  }

  body.mobile-landscape-layout .tutorial-guide-portrait {
    bottom: calc(var(--landscape-tutorial-bubble-height) + 6px);
    width: 136px;
    height: 196px;
    max-height: 196px;
  }

  body.mobile-landscape-layout .tutorial-guide-bubble,
  body.mobile-landscape-layout .tutorial-guide-complete .tutorial-guide-bubble {
    padding: 11px 44px 11px 14px;
  }

  body.mobile-landscape-layout .tutorial-guide-complete-actions {
    right: calc(var(--landscape-tutorial-content-inset) + 144px);
    bottom: calc(var(--landscape-tutorial-bubble-height) + 8px);
    left: 12px;
  }

  body.mobile-landscape-layout .tutorial-guide-next {
    min-width: 126px;
    min-height: 46px;
    padding: 7px 14px;
    font-size: var(--tablet-landscape-button-text);
  }

  body.mobile-landscape-layout .tutorial-guide-next-icon {
    right: 10px;
    bottom: 9px;
    width: 26px;
    height: 26px;
    font-size: var(--landscape-text-md);
  }

  body.mobile-landscape-layout .phase-notice {
    top:
      calc(
        var(--mobile-viewport-offset-top, 0px)
        + var(--tablet-landscape-stage-offset)
        + max(1px, env(safe-area-inset-top))
        + var(--landscape-player-head-height)
        + 6px
      );
  }

  body.mobile-landscape-layout .phase-notice.notice-special-wait {
    top:
      calc(
        var(--mobile-viewport-offset-top, 0px)
        + var(--tablet-landscape-stage-offset)
        + max(1px, env(safe-area-inset-top))
      );
  }

  body.mobile-landscape-layout > .special-stack-panel,
  body.mobile-landscape-layout > .special-stack-panel.special-stack-frozen {
    --floating-special-bottom-inset:
      calc(
        var(--tablet-landscape-stage-offset)
        + max(8px, var(--app-safe-bottom))
      );
  }
}

/* 横画面共通レイアウト終了 */

/*
  対戦準備の名前入力は、iOSの自動拡大を避けつつvisualViewport内へ固定する。
  入力中は他の設定を畳み、縦横とも名前欄だけを安定して操作できるようにする。
*/
body.mobile-layout .mobile-options-modal.match-setup-options-open .option-character-name-grid input,
body.mobile-landscape-layout .mobile-options-modal.match-setup-options-open .option-character-name-grid input {
  min-height: 44px;
  font-size: 16px;
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing {
  top: var(--mobile-viewport-offset-top, 0px);
  right: auto;
  bottom: auto;
  left: var(--mobile-viewport-offset-left, 0px);
  width: var(--mobile-viewport-width, 100dvw);
  height: var(--mobile-viewport-height, 100dvh);
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  overflow: hidden;
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing .mobile-utility-panel {
  align-self: stretch;
  justify-self: center;
  width: min(640px, 100%);
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

/* 設定名は一行で保ち、狭い画面では項目全体を次の行へ送る。 */
body:is(.mobile-layout, .mobile-landscape-layout) .mobile-options-body .option-play-list {
  display: flex;
  flex-wrap: wrap;
}

body:is(.mobile-layout, .mobile-landscape-layout) .mobile-options-body .option-play-list > .toggle-option {
  flex: 1 1 calc(50% - 4px);
  align-self: stretch;
  min-width: max-content;
  width: auto;
  white-space: nowrap;
}

body:is(.mobile-layout, .mobile-landscape-layout) .special-wait-switch-label {
  gap: 4px;
}

body:is(.mobile-layout, .mobile-landscape-layout) .option-play-list > .toggle-option input {
  margin: 0;
}

body:is(.mobile-layout, .mobile-landscape-layout) .mobile-options-body .option-play-list > .special-wait-switch-setting {
  grid-template-columns: minmax(max-content, 1fr) 44px;
}

body:is(.mobile-layout, .mobile-landscape-layout) .mobile-options-body .option-play-list > :is(.speed-mode-group, .screen-orientation-group) {
  flex-basis: 100%;
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing .mobile-options-body {
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 10px;
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing .mobile-options-body > :not(.option-character-name-section) {
  display: none !important;
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing:not(.is-landscape-character-name-editing) .option-character-name-grid {
  grid-template-columns: minmax(0, 1fr);
}

.mobile-options-modal.is-character-name-editing.is-mobile-character-name-editing .option-character-name-section {
  grid-column: 1 / -1;
  align-self: start;
}

/* 横向きキーボードで実表示高が狭い時も、見出しと2つの入力欄を一画面へ収める。 */
.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .mobile-utility-panel {
  gap: 4px;
  padding: 6px 8px;
}

.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .mobile-utility-head {
  min-height: 32px;
  padding-right: 60px;
}

.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .mobile-utility-head h2 {
  font-size: 14px;
}

.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .mobile-utility-close {
  top: 4px;
  right: 6px;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 12px;
}

.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .option-character-name-section {
  gap: 4px;
  padding: 6px;
}

.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .option-character-name-section .option-section-head,
.mobile-options-modal.is-character-name-editing.is-landscape-character-name-editing .option-character-settings > label:has(select) {
  display: none;
}

/* EDの会話は初回案内の比率を使い、クレジットだけを画面全体の1列表示へ切り替える。 */
body.mobile-layout .title-ending-button {
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  min-height: 34px;
  padding: 5px 11px;
  font-size: 12px;
}

body.mobile-landscape-layout .title-ending-button {
  right: max(10px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  min-height: 34px;
  padding: 5px 11px;
  font-size: 12px;
}

body.mobile-safari-layout .title-ending-button {
  bottom: max(4px, calc(env(safe-area-inset-bottom) - 6px));
}

body.mobile-fullscreen-layout .title-ending-button {
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
}

/* 縦画面のチュートリアル一覧では、左右下の補助ボタンを隠して項目との重なりを避ける。 */
body.mobile-layout .title-screen.title-tutorial-menu-open > :is(.title-data-manager-button, .title-ending-button) {
  display: none;
}

body.mobile-layout .title-screen.first-launch-opening-open .prologue-ending:is(.is-credits, .is-final),
body.mobile-landscape-layout .title-screen.first-launch-opening-open .prologue-ending:is(.is-credits, .is-final) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(980px, 100%);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body.mobile-layout .prologue-ending-credits-viewport,
body.mobile-landscape-layout .prologue-ending-credits-viewport {
  padding:
    max(42px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

body.mobile-layout .prologue-ending-credits-page,
body.mobile-landscape-layout .prologue-ending-credits-page {
  width: min(760px, 100%);
}

body.mobile-layout .prologue-ending-final,
body.mobile-landscape-layout .prologue-ending-final {
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

body.mobile-layout .prologue-ending-credits-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

body.mobile-layout .prologue-ending-credit-section {
  gap: 4px;
}

body.mobile-layout .prologue-ending-credit-section h3 {
  margin-bottom: 3px;
}

body.mobile-layout .prologue-ending-credit-lines {
  gap: 2px;
}

body.mobile-layout .prologue-ending-credit-section.is-music .prologue-ending-credit-lines {
  grid-template-columns: minmax(0, 1fr);
}

body.mobile-layout .prologue-ending-credit-section.is-music p {
  font-size: clamp(10px, 3.1vw, 13px);
  line-height: 1.35;
}

body.mobile-landscape-layout .prologue-ending-credits-page > h2 {
  margin-bottom: 12px;
  font-size: clamp(23px, 5vh, 32px);
}

body.mobile-landscape-layout .prologue-ending-credits-grid {
  gap: 14px;
}

body.mobile-landscape-layout .prologue-ending-credit-section {
  gap: 4px;
}

body.mobile-landscape-layout .prologue-ending-credit-section h3 {
  margin-bottom: 2px;
  font-size: clamp(11px, 2.8vh, 14px);
}

body.mobile-landscape-layout .prologue-ending-credit-lines {
  gap: 1px;
}

body.mobile-landscape-layout .prologue-ending-credit-section p {
  font-size: clamp(9px, 2.35vh, 12px);
  line-height: 1.3;
}

/* タブレットタイトル・ED共通倍率 開始 */
/*
  タブレットはスマホ向けの上限値でタイトルだけが小さく止まりやすい。
  transform/zoomは入力座標とEDの登場演出へ干渉するため使わず、同じ倍率を
  各部品の実寸へ反映して、通常タイトルとEDだけを均等に拡大する。
*/
@media (min-width: 621px) and (max-width: 1100px) and (orientation: portrait) {
  body.mobile-layout .title-screen {
    --title-tablet-scale: 1.18;
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, auto) minmax(0, auto);
    align-content: center;
    gap: calc(14px * var(--title-tablet-scale));
    padding:
      max(calc(18px * var(--title-tablet-scale)), env(safe-area-inset-top))
      calc(18px * var(--title-tablet-scale))
      max(calc(54px * var(--title-tablet-scale)), calc(env(safe-area-inset-bottom) + 44px));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-visual {
    min-height: 0;
    height: clamp(
      calc(100px * var(--title-tablet-scale)),
      calc(var(--app-viewport-height, 100dvh) * 0.3 * var(--title-tablet-scale)),
      calc(214px * var(--title-tablet-scale))
    );
    max-height: 100%;
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-logo-art {
    width: min(96vw, calc(430px * var(--title-tablet-scale)));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-panel-stack {
    justify-self: center;
    gap: calc(6px * var(--title-tablet-scale));
    max-width: min(
      calc(560px * var(--title-tablet-scale)),
      calc(var(--mobile-viewport-width, 100dvw) - 42px)
    );
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-panel {
    gap: calc(16px * var(--title-tablet-scale));
    padding: calc(20px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-kicker {
    font-size: calc(13px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-actions {
    gap: calc(10px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-action {
    min-height: calc(50px * var(--title-tablet-scale));
    border-radius: calc(8px * var(--title-tablet-scale));
    font-size: calc(16px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load {
    gap: calc(8px * var(--title-tablet-scale));
    min-height: calc(46px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load-head {
    gap: calc(10px * var(--title-tablet-scale));
    font-size: calc(12px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load-head strong {
    font-size: calc(16px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load-bar {
    height: calc(8px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-audio-note {
    gap: calc(10px * var(--title-tablet-scale));
    font-size: calc(11px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-audio-toggle {
    min-width: calc(74px * var(--title-tablet-scale));
    min-height: calc(28px * var(--title-tablet-scale));
    padding: calc(3px * var(--title-tablet-scale)) calc(10px * var(--title-tablet-scale));
    font-size: calc(11px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    :is(.title-data-manager-button, .title-ending-button) {
    min-height: calc(34px * var(--title-tablet-scale));
    padding: calc(5px * var(--title-tablet-scale)) calc(11px * var(--title-tablet-scale));
    font-size: calc(12px * var(--title-tablet-scale));
  }

  body.mobile-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-public-beta-link {
    font-size: calc(11px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) {
    grid-template-rows:
      clamp(
        calc(360px * var(--title-tablet-scale)),
        44.8dvh,
        calc(480px * var(--title-tablet-scale))
      )
      auto;
    width: min(
      calc(780px * var(--title-tablet-scale)),
      calc(var(--mobile-viewport-width, 100dvw) - 40px)
    );
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-portrait {
    bottom: calc(-62px * var(--title-tablet-scale));
    width: min(calc(520px * var(--title-tablet-scale)), 72dvw);
    height: calc(100% + 90px);
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-dialog {
    width: min(calc(680px * var(--title-tablet-scale)), calc(100% - 48px));
    max-width: min(calc(680px * var(--title-tablet-scale)), calc(100% - 48px));
    padding: calc(27px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-kicker {
    font-size: calc(13px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-dialog h2 {
    font-size: calc(30px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-content {
    margin-top: calc(17px * var(--title-tablet-scale));
    font-size: calc(17px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-actions {
    width: min(calc(520px * var(--title-tablet-scale)), 100%);
    max-width: calc(520px * var(--title-tablet-scale));
    gap: calc(12px * var(--title-tablet-scale));
    margin-top: calc(21px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-action {
    min-height: calc(50px * var(--title-tablet-scale));
    font-size: calc(17px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credits-page {
    width: min(calc(760px * var(--title-tablet-scale)), 100%);
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credits-page > h2 {
    font-size: calc(44px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credit-section h3 {
    font-size: calc(18px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credit-section p,
  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credit-section.is-music p {
    font-size: calc(13px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final-brand {
    font-size: calc(70px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final-subtitle {
    font-size: calc(24px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final .first-launch-actions {
    width: min(calc(360px * var(--title-tablet-scale)), 100%);
    margin-top: calc(76px * var(--title-tablet-scale));
  }

  body.mobile-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final .first-launch-action {
    min-height: calc(50px * var(--title-tablet-scale));
    font-size: calc(15px * var(--title-tablet-scale));
  }
}

@media (orientation: landscape) and (min-width: 900px) and (min-height: 621px) and (max-height: 1100px) and (max-width: 1400px) {
  body.mobile-landscape-layout .title-screen {
    --title-tablet-scale: 1.18;
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open) {
    --landscape-menu-text-xs: calc(10px * var(--title-tablet-scale));
    --landscape-menu-text-sm: calc(11px * var(--title-tablet-scale));
    --landscape-menu-text-md: calc(12px * var(--title-tablet-scale));
    --landscape-menu-text-lg: calc(15px * var(--title-tablet-scale));
    --landscape-menu-text-xl: calc(18px * var(--title-tablet-scale));
    grid-template-columns: minmax(0, 1fr) minmax(calc(350px * var(--title-tablet-scale)), 52vw);
    gap: calc(22px * var(--title-tablet-scale));
    padding:
      max(calc(22px * var(--title-tablet-scale)), env(safe-area-inset-top))
      max(calc(22px * var(--title-tablet-scale)), env(safe-area-inset-right))
      max(calc(22px * var(--title-tablet-scale)), env(safe-area-inset-bottom))
      max(calc(22px * var(--title-tablet-scale)), env(safe-area-inset-left));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-logo-art {
    width: min(
      calc(34vw * var(--title-tablet-scale)),
      calc(340px * var(--title-tablet-scale))
    );
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-visual {
    min-height: 0;
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    :is(.title-panel, .title-panel-stack) {
    width: min(calc(480px * var(--title-tablet-scale)), 100%);
    max-width: calc(480px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-panel {
    gap: calc(12px * var(--title-tablet-scale));
    padding: calc(18px * var(--title-tablet-scale)) calc(20px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-panel-stack {
    gap: calc(4px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-action {
    min-height: calc(46px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load {
    gap: calc(6px * var(--title-tablet-scale));
    min-height: calc(38px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-load-bar {
    height: calc(6px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    .title-audio-toggle {
    min-width: calc(70px * var(--title-tablet-scale));
    min-height: calc(34px * var(--title-tablet-scale));
    padding: calc(4px * var(--title-tablet-scale)) calc(9px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout
    .title-screen:not(.title-match-setup-open):not(.title-tutorial-menu-open):not(.first-launch-opening-open)
    :is(.title-data-manager-button, .title-ending-button) {
    min-height: calc(34px * var(--title-tablet-scale));
    padding: calc(5px * var(--title-tablet-scale)) calc(11px * var(--title-tablet-scale));
    font-size: calc(12px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) {
    --landscape-menu-text-xs: calc(10px * var(--title-tablet-scale));
    --landscape-menu-text-sm: calc(11px * var(--title-tablet-scale));
    --landscape-menu-text-md: calc(12px * var(--title-tablet-scale));
    --landscape-menu-text-lg: calc(15px * var(--title-tablet-scale));
    --landscape-menu-text-xl: calc(18px * var(--title-tablet-scale));
    width: min(
      calc(920px * var(--title-tablet-scale)),
      calc(var(--mobile-viewport-width, 100dvw) - 40px)
    );
    height: min(
      calc(680px * var(--title-tablet-scale)),
      calc(var(--mobile-viewport-height, 100dvh) - 40px)
    );
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-portrait {
    width: min(calc(375px * var(--title-tablet-scale)), 180%);
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-dialog {
    padding:
      calc(16px * var(--title-tablet-scale))
      calc(20px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-actions {
    gap: calc(7px * var(--title-tablet-scale));
    margin-top: calc(10px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending:not(.is-credits):not(.is-final) .first-launch-action {
    min-height: calc(38px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credits-page {
    width: min(calc(760px * var(--title-tablet-scale)), 100%);
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credits-page > h2 {
    margin-bottom: calc(12px * var(--title-tablet-scale));
    font-size: calc(32px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credits-grid {
    gap: calc(14px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credit-section h3 {
    font-size: calc(14px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-credits .prologue-ending-credit-section p {
    font-size: calc(12px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final-brand {
    font-size: calc(70px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final-subtitle {
    font-size: calc(24px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final .first-launch-actions {
    width: min(calc(360px * var(--title-tablet-scale)), 100%);
    margin-top: calc(76px * var(--title-tablet-scale));
  }

  body.mobile-landscape-layout .title-screen.first-launch-opening-open
    .prologue-ending.is-final .prologue-ending-final .first-launch-action {
    min-height: calc(50px * var(--title-tablet-scale));
    font-size: calc(15px * var(--title-tablet-scale));
  }
}
/* タブレットタイトル・ED共通倍率 終了 */

/* タブレットの固定詳細は、小型の元カードではなく閲覧できる画面高に合わせる。 */
@media (min-width: 621px) and (min-height: 621px) and (max-width: 1400px) and (max-height: 1400px) and (any-pointer: coarse) {
  .card-collection-modal {
    --card-modal-inset-top: max(64px, calc(var(--app-safe-top) + 56px));
    --card-modal-inset-bottom: max(24px, var(--app-safe-bottom));
  }

  .card-collection-modal-card.card-collection-modal-card--formal {
    width: min(680px, calc(var(--app-usable-width) - 96px), calc((var(--card-modal-available-height) - 64px) * 2 / 3 + 22px));
    max-height: var(--card-modal-available-height);
    padding: 10px;
    gap: 8px;
  }

  .card-collection-modal-card--formal .card-collection-formal-card {
    width: 100%;
  }

  .card-collection-modal.is-art-only .card-collection-modal-card--formal {
    width: min(680px, calc(var(--app-usable-width) - 96px), calc(var(--card-modal-available-height) * 2 / 3));
    padding: 0;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .art-modal {
    place-items: center;
    padding: max(64px, calc(var(--app-safe-top) + 56px)) var(--app-safe-right) max(24px, var(--app-safe-bottom)) var(--app-safe-left);
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .art-modal.show .art-modal-card.has-formal-card {
    position: relative;
    top: auto;
    left: auto;
    width: min(680px, calc(var(--app-usable-width) - 48px), calc((var(--app-usable-height) - 88px) * 2 / 3));
    height: auto;
    min-height: 0;
    max-height: calc(var(--app-usable-height) - 88px);
    aspect-ratio: 2 / 3;
    transform: none;
  }
}

/* 画面内の助言はそのままに、独立したヒントだけを右下の読み物サイズにする。 */
@media (min-width: 621px) {
  body > #naviHint {
    top: auto;
    left: auto;
    right: max(16px, var(--app-safe-right));
    bottom: max(16px, var(--app-safe-bottom));
    width: min(560px, calc(var(--app-usable-width) - 32px));
    max-height: calc(var(--app-usable-height) - 32px);
    overflow: auto;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 12px;
  }

  body > #naviHint img { width: 76px; height: 76px; }
  body > #naviHint strong { font-size: 17px; }
  body > #naviHint p { font-size: 15px; line-height: 1.55; }
  body > #naviHint .navi-hint-close { min-width: 44px; min-height: 44px; font-size: 20px; }
  body > #naviHint .navi-hint-action { min-height: 44px; font-size: 14px; }
}

@media (min-width: 621px) and (min-height: 501px) {
  body:not(.mobile-layout):not(.mobile-landscape-layout) > #naviHint[data-hint-id="first-launch-tutorial-guide"] {
    width: min(576px, calc(var(--app-usable-width) - 32px));
  }
}

@media (min-width: 621px) and (max-height: 500px) {
  body > #naviHint {
    width: min(480px, calc(var(--app-usable-width) - 32px));
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  body > #naviHint img { width: 54px; height: 54px; }
  body > #naviHint strong { font-size: 15px; }
  body > #naviHint p { font-size: 13px; }
}

body:is(.mobile-layout, .mobile-landscape-layout) > #naviHint[data-first-battle-action-anchored] {
  bottom: var(--first-battle-guide-bottom);
  max-height: calc(var(--app-usable-height) - var(--first-battle-guide-bottom) - 8px);
  overflow: auto;
}

/* タブレットの通知は中央欄の幅に縛らず、本文に必要な幅を画面内で確保する。 */
@media (min-width: 621px) and (min-height: 621px) and (max-width: 1400px) and (max-height: 1400px) and (any-pointer: coarse) {
  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice {
    --tablet-notice-art-width: clamp(72px, 7.2dvmin, 92px);
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + 16px);
    right: auto;
    width: calc(var(--app-usable-width) - 32px);
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice .phase-card,
  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice.notice-special-wait .phase-card {
    width: max-content;
    min-width: min(520px, calc(var(--app-usable-width) - 32px));
    max-width: min(920px, calc(var(--app-usable-width) - 32px));
    padding: 14px 20px;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice .phase-card-with-art {
    grid-template-columns: var(--tablet-notice-art-width) minmax(0, 1fr);
    gap: 18px;
    padding: 12px 20px 12px 12px;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice :is(.notice-card-art, .notice-player-avatar) {
    width: var(--tablet-notice-art-width);
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice .phase-copy > span {
    font-size: clamp(14px, 1.8dvmin, 18px);
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice .phase-card strong {
    margin-top: 4px;
    font-size: clamp(24px, 2.4dvmin, 30px);
    line-height: 1.2;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .phase-notice .phase-card :is(em, small) {
    margin-top: 6px;
    font-size: clamp(15px, 1.6dvmin, 18px);
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
}

/* 重ね枚数は日英とも1行とし、HPバーの幅を保つため下に置く。 */
body:is(.mobile-layout, .mobile-landscape-layout) .app .unit .unit-health-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  margin-top: 1px;
}

body:is(.mobile-layout, .mobile-landscape-layout) .app .unit .unit-health-row .hpbar {
  flex: none;
  min-width: 0;
  margin-top: 0;
}

body:is(.mobile-layout, .mobile-landscape-layout) .app .unit .unit-health-row .unit-stack-count {
  flex: 0 0 auto;
  min-height: 0;
  margin: 0;
  overflow: visible;
  line-height: 1.2;
}

body:is(.mobile-layout, .mobile-landscape-layout) .unit .unit-stack-count:empty {
  display: none;
}

body:is(.mobile-layout, .mobile-landscape-layout) .app .unit:has(.unit-stack-count:not(:empty)) .unit-stat-line {
  margin-top: 0;
}

@media (orientation: portrait) and (max-width: 360px) and (max-height: 620px),
       (orientation: landscape) and (max-height: 400px) {
  body:is(.mobile-layout, .mobile-landscape-layout) .app:is(.mobile-layout, .mobile-landscape-layout) .unit.has-card-art .card-info {
    padding: 2px;
    max-height: calc(100% - 6px);
  }

  body.mobile-layout .app:is(.mobile-layout, .mobile-landscape-layout) .unit .name {
    display: block;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-layout .app:is(.mobile-layout, .mobile-landscape-layout) .unit .name br {
    display: none;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .app:is(.mobile-layout, .mobile-landscape-layout) .unit .unit-stat-line {
    margin-top: 1px;
  }

  body:is(.mobile-layout, .mobile-landscape-layout) .app:is(.mobile-layout, .mobile-landscape-layout) .unit .unit-attribute-line {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* 狭いタブレット横も名前を識別できるよう、ヘッダー内だけを詰める。 */
@media (orientation: landscape) and (min-width: 900px) and (max-width: 1100px) and (min-height: 501px) and (max-height: 1100px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head {
    --landscape-avatar-size: 44px;
    --landscape-header-tool-width: 34px;
    --player-surrender-width: 28px;
    --player-surrender-height: 28px;
    --player-surrender-icon-size: 16px;
    --player-surrender-hit-inset: -8px 0 -8px -16px;
    padding-inline: 8px;
  }

  body.mobile-landscape-layout .app.mobile-landscape-layout .player-head .player-name {
    font-size: 16px;
  }
}
