@media (max-width: 620px) and (orientation: portrait) {
  html,
  body,
  #app {
    height: 100dvh;
    min-height: 100dvh;
  }

  body {
    overflow: hidden;
  }

  .game {
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    padding: 3px;
    overflow: hidden;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 60px minmax(0, 1fr) 100px 82px;
    gap: 3px;
  }

  .left-rail {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 60px;
    gap: 4px;
    align-content: stretch;
  }

  .hud-panel {
    width: auto;
    min-height: 0;
    height: 60px;
    padding: 5px 7px;
    overflow: hidden;
  }

  .hud-panel.enemy {
    grid-column: 1;
  }

  .hud-panel.player {
    grid-column: 2;
  }

  .hud-title {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 6px;
    height: 26px;
    min-width: 0;
  }

  .hud-avatar {
    width: 30px;
    height: 30px;
  }

  .hud-avatar::before {
    inset: 5px 7px 7px;
  }

  .hud-avatar-core::before,
  .hud-avatar-core::after {
    top: 15px;
    width: 6px;
    height: 2px;
  }

  .hud-avatar-core::before {
    left: 12px;
  }

  .hud-avatar-core::after {
    right: 12px;
  }

  .faction-mark {
    right: -4px;
    bottom: -4px;
    width: 17px;
    height: 17px;
    font-size: 0.52rem;
  }

  .hud-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .hud-reactor {
    min-width: 20px;
    width: 20px;
    height: 20px;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .hud-reactor-label {
    display: none;
  }

  .hud-reactor .reactor-compact {
    width: 18px;
  }

  .stats {
    grid-template-columns: minmax(36px, 0.8fr) minmax(58px, 1.4fr);
    gap: 4px;
    margin-top: 3px;
  }

  .stat.deck-stat,
  .stat.discard-stat {
    display: none;
  }

  .stat {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 18px;
    padding: 2px 4px;
  }

  .stat-label {
    display: inline-flex;
    font-size: 0.44rem;
    line-height: 1;
  }

  .stat-word {
    display: none;
  }

  .stat-icon {
    display: inline;
  }

  .stat-value {
    margin-top: 0;
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
  }

  .hull-stat .stat-value {
    min-width: 0;
  }

  .hud-reactor-bar {
    min-height: 12px;
    margin-top: 3px;
    gap: 2px;
    padding: 1px;
  }

  .reactor-charge-cell {
    height: 10px;
  }

  .effects,
  .hint-panel,
  .log-panel {
    display: none;
  }

  .mobile-log-peek {
    position: absolute;
    z-index: 36;
    left: 8px;
    right: 8px;
    bottom: 188px;
    height: 38px;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid rgba(80, 200, 255, 0.56);
    background: linear-gradient(135deg, rgba(5, 18, 32, 0.94), rgba(3, 8, 15, 0.88));
    color: var(--text);
    box-shadow: 0 0 18px rgba(80, 200, 255, 0.2), 0 0 28px rgba(0, 0, 0, 0.45);
    clip-path: polygon(0 10px, 10px 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    text-align: left;
  }

  .mobile-log-peek.bot {
    border-color: rgba(255, 75, 67, 0.62);
    box-shadow: 0 0 18px rgba(255, 75, 67, 0.2), 0 0 28px rgba(0, 0, 0, 0.45);
  }

  .mobile-log-mark {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-left: 1px solid currentColor;
    border-right: 1px solid currentColor;
    color: var(--blue-soft);
    font-size: 0.72rem;
    font-weight: 900;
  }

  .mobile-log-peek.bot .mobile-log-mark {
    color: var(--red-soft);
  }

  .mobile-log-main {
    min-width: 0;
    display: grid;
    gap: 1px;
  }

  .mobile-log-label {
    color: var(--muted);
    font-size: 0.48rem;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
  }

  .mobile-log-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #eff9ff;
    font-size: 0.64rem;
    line-height: 1.12;
    font-weight: 900;
  }

  .mobile-log-time {
    color: var(--blue-soft);
    font-size: 0.54rem;
    font-weight: 900;
    white-space: nowrap;
  }

  .center-stage {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    gap: 4px;
    padding-left: 0;
    padding-right: 0;
    grid-template-rows: 0px minmax(0, 1fr);
  }

  .turn-banner {
    top: calc(50dvh - 42.5px);
    width: 174px;
    height: 45px;
    min-height: 0;
    aspect-ratio: auto;
    padding: 3px 18px 4px;
  }

  .turn-banner.is-action-ready {
    animation: hintBreathe 1.45s ease-in-out infinite;
    border-color: rgba(255, 226, 138, 0.82);
    box-shadow: 0 0 20px rgba(255, 226, 138, 0.26), inset 0 0 16px rgba(255, 226, 138, 0.1);
  }

  .turn-banner.is-action-ready.is-stage-intro {
    animation:
      turnBannerIntroZoom 960ms cubic-bezier(0.2, 0.92, 0.2, 1) 420ms both,
      hintBreathe 1.45s ease-in-out 1.48s infinite;
  }

  .turn-banner.is-action-ready::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 0 34%, rgba(255, 255, 255, 0.16) 48%, transparent 64% 100%);
    transform: translateX(-120%);
    animation: hintSweep 2.1s ease-in-out infinite;
  }

  .turn-banner.is-action-ready.is-stage-intro::after {
    animation-delay: 1.48s;
  }

  .turn-title {
    font-size: 1rem;
  }

  .turn-subtitle {
    margin-top: 1px;
    font-size: 0.68rem;
  }

  .turn-banner.is-status .turn-title {
    max-height: 2.2em;
    overflow: hidden;
    font-size: 0.68rem;
    line-height: 1.08;
  }

  .battlefield {
    min-height: 0;
    gap: 4px;
    padding: 0;
    grid-template-rows: minmax(0, 0.98fr) minmax(0, 1.02fr);
  }

  .waiting-match-panel {
    width: min(300px, calc(100% - 18px));
    padding: 12px;
    gap: 7px;
  }

  .waiting-match-kicker,
  .waiting-match-code {
    font-size: 0.62rem;
  }

  .waiting-match-panel h2 {
    font-size: 0.98rem;
  }

  .waiting-match-panel p {
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .waiting-match-actions {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .waiting-match-actions > * {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .action-callout {
    width: min(280px, 86%);
    padding: 7px 10px;
  }

  .action-callout-title {
    font-size: 0.82rem;
  }

  .action-callout-target {
    font-size: 0.66rem;
  }

  .ship-art {
    width: min(510px, 122%);
    max-height: 122px;
  }

  .ship-zone {
    --engineering-cell-size: clamp(32px, 8.4vw, 38px);
    --engineering-cell-gap: 3px;
  }

  .ship-engineering-bay {
    max-width: 96%;
  }

  .engineering-cell {
    padding: 5px 5px;
  }

  .engineering-cell-icon {
    font-size: 0.88rem;
  }

  .engineering-cell-value {
    min-width: 16px;
    max-width: calc(100% + 8px);
    padding: 2px 3px;
    font-size: 0.54rem;
  }

  .engineering-cell-label {
    display: none;
  }

  .ship-zone.enemy-zone .ship-art,
  .ship-zone.player-zone .ship-art {
    width: min(
      360px,
      calc(100% - var(--engineering-cell-size) - var(--engineering-cell-size))
    );
    height: auto;
    max-height: none;
  }

  .ship-zone.enemy-zone .ship-art {
    /*top: var(--ship-zone-edge-offset);*/
  }

  .ship-zone.enemy-zone .slot-row {
    position: absolute;
    left: 50%;
    top: var(--ship-zone-edge-offset);
    transform: translateX(-50%);
  }

  .ship-zone.enemy-zone .ship-normal-shield {
    top: calc(var(--ship-zone-edge-offset) + clamp(82px, 14.8vh, 106px) + 3px + 18px + 8px);
    bottom: auto;
  }

  .ship-zone.enemy-zone {
    --ship-zone-edge-offset: -6px;
    padding-top:20px;
  }

  .ship-zone.player-zone {
    --ship-zone-edge-offset: 39px;
    align-items: start;
    padding-top: 12px;
    padding-bottom: 20px;
  }

  .ship-zone.player-zone .ship-art {
    /*bottom: var(--ship-zone-edge-offset);*/
  }

  .ship-zone.player-zone .slot-row {
    position: absolute;
    left: 50%;
    bottom: var(--ship-zone-edge-offset);
    transform: translateX(-50%);
  }

  .ship-zone.player-zone .ship-normal-shield {
    top: auto;
    bottom: calc(var(--ship-zone-edge-offset) + 18px + 3px + clamp(82px, 14.8vh, 106px) + 8px);
  }

  .ship-zone.player-zone .ship-engineering-bay {
    bottom: 44px;
  }

  .slot-row {
    --battle-slot-wrap-width: clamp(82px, 23vw, 94px);
    --battle-slot-gap: clamp(8px, 2.5vw, 12px);
    width: 98%;
    grid-template-columns: repeat(3, var(--battle-slot-wrap-width));
    gap: var(--battle-slot-gap);
    justify-content: center;
    justify-items: center;
  }

  .slot-wrap {
    width: min(100%, var(--battle-slot-wrap-width));
    justify-self: center;
    grid-template-rows: auto;
    gap: 0;
    padding-top: 0;
  }

  .enemy-zone .slot-wrap {
    grid-template-rows: auto;
  }

  .slot-status-row {
    position: absolute;
    left: 0;
    top: calc(100% + 3px);
    width: 100%;
    grid-row: auto;
    height: 18px;
    min-height: 18px;
    gap: 3px;
  }

  .slot-button,
  .enemy-zone .slot-button {
    grid-row: 1;
  }

  .enemy-zone .slot-status-row {
    top: auto;
    bottom: calc(100% + 3px);
    grid-row: auto;
  }

  .slot-status-badge {
    flex-basis: 46px;
    width: 46px;
    height: 16px;
    padding: 0 3px;
    font-size: 0.43rem;
  }

  .slot-button {
    height: clamp(82px, 14.8vh, 106px);
    padding: 4px;
    gap: 3px;
  }

  .slot-layers {
    gap: 4px;
  }

  .layer {
    width: min(50px, 70%);
    min-width: 34px;
    min-height: 24px;
    grid-template-areas: "stack";
    gap: 2px;
    padding: 3px;
    font-size: 0.56rem;
    line-height: 1.05;
  }

  .layer-icon {
    width: auto;
    height: auto;
    font-size: 0.84rem;
  }

  .layer-value {
    min-width: 18px;
    padding: 2px 4px;
    font-size: 0.52rem;
  }

  .layer-marker {
    width: 15px;
    height: 15px;
    font-size: 0.5rem;
  }

  .slot-fx-label,
  .global-fx-chip {
    font-size: 0.56rem;
  }

}
