/* Compact player header; loaded after the existing mobile and home layouts. */
.mobile-player-header { display: none; }

body[data-mode=mobile],
body[data-mode=mobile][data-screen=game] { --header-height: 64px; }

body[data-mode=mobile] .app-header,
body[data-mode=mobile][data-screen=game] .app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 16px;
  background: #fff;
  border-bottom: 0;
  backdrop-filter: none;
  gap: 0;
}
body[data-mode=mobile] .app-header > .brand,
body[data-mode=mobile] .app-header > .header-context,
body[data-mode=mobile] .app-header > .header-actions { display: none; }

body[data-mode=mobile] .mobile-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-width: 0;
}
.mobile-player {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 9px;
  min-width: 0;
}
.mobile-player-avatar { display: block; flex: none; border-radius: 50%; }
.mobile-player-avatar .avatar { width: 33px; height: 33px; }
.mobile-player-copy { flex: 1; min-width: 0; }
.mobile-player-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}
.mobile-player-balance {
  display: block;
  max-width: 100%;
  min-height: 23px;
  padding: 1px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 14px;
  font-weight:600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: #929697;
}
.mobile-player-balance > span { font: inherit; }
.mobile-player-balance small { font-size: inherit; }
.mobile-phase-links {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 0 0 90px;
  min-width: 0;
  min-height: 38px;
  padding: 4px 24px 4px 8px;
  border-radius: 12px;
  background: #f0e9f1;
}
body[data-mode=mobile][data-screen=game] .primary-heading { display: none; }

/* One mobile panel: player header, heading, Redo and progress share one fill. */
body[data-mode=mobile][data-screen=game] { --header-height: 0px; }
body[data-mode=mobile][data-screen=game] > .app-header { display: none; }
body[data-mode=mobile][data-screen=game] .game-page { padding-top: 0; padding-inline: 0; }
body[data-mode=mobile][data-screen=game] .game-main {
  order: 0;
  background: linear-gradient(110deg, #f7fdff, #fff9fd 65%, #fff4fc);
  border-radius: 0 0 16px 16px;
  isolation: isolate;
}
body[data-mode=mobile][data-screen=game] .game-main > .mobile-player-header {
  flex: none;
  height: 64px;
  padding: 0 16px;
  position: relative;
  z-index: 2;
}
body[data-mode=mobile][data-screen=game] .mobile-player-copy { text-align: left; }
body[data-mode=mobile][data-screen=game] .game-hero {
  height: clamp(218px, calc(100svh - 64px - var(--mobile-game-controls-height) - var(--mobile-game-nav-height) - 180px), 320px);
  padding: 6px 16px 13px;
  background: transparent;
  border-radius: 0;
}
body[data-mode=mobile][data-screen=game] .game-summary { order: 1; margin: 4px 12px 0; }
body[data-mode=mobile][data-screen=game] .game-latest { order: 2; margin-inline: 12px; }
body[data-mode=mobile][data-screen=game] .game-investments { order: 3; margin-inline: 12px; }

/* Season and round details reuse the application's existing dialog. */
#dialog:has([data-header-panel]) {
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
body[data-mode=mobile] #dialog:has([data-header-panel]) {
  width: min(calc(var(--mobile-frame-width, 430px) - 24px), calc(100vw - 24px));
}
#dialog:has([data-header-panel]) h2 { margin: 6px 30px 18px 0; font-size: 23px; }
#dialog [data-header-panel] { min-width: 0; }
#dialog .phase-overview[data-header-panel] { min-width: 0; }
#dialog [data-header-panel] .phase-current {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(112deg, #effaff 0%, #faf9fd 55%, #f8effa 100%);
}
#dialog [data-header-panel] .phase-current > small {
  display: block;
  margin-bottom: 5px;
  color: #9275af;
  font-size: 10px;
  font-weight: 800;
}
#dialog [data-header-panel] .phase-current h3 { font-size: 19px; line-height: 1.25; font-weight: 900; }
#dialog [data-header-panel] .phase-current p { margin-top: 6px; font-size: 12px; line-height: 1.45; color: #88818f; }
#dialog [data-header-panel] .phase-section-label {
  display: block;
  margin: 18px 0 8px;
  color: #97909f;
  font-size: 11px;
  font-weight: 800;
}
#dialog [data-header-panel] .phase-list,
#dialog [data-header-panel] .phase-list ol { padding: 0; margin: 0; list-style: none; }
#dialog [data-header-panel] .phase-list li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) minmax(45px, auto);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: #faf9fb;
}
#dialog [data-header-panel] .phase-list li:last-child { margin-bottom: 0; }
#dialog [data-header-panel] .phase-list li.is-current { background: linear-gradient(105deg, #edf8fe, #f5edf9); }
#dialog [data-header-panel] .phase-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #f0edf4;
  color: #a491b2;
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
#dialog [data-header-panel] .is-current .phase-number { background: #fff; color: #9572b8; }
#dialog [data-header-panel] .is-complete .phase-number { background: #f1f4f1; color: #8da48a; }
#dialog [data-header-panel] .phase-copy { min-width: 0; }
#dialog [data-header-panel] .phase-copy strong,
#dialog [data-header-panel] .phase-copy small { display: block; overflow-wrap: anywhere; }
#dialog [data-header-panel] .phase-copy strong { font-size: 12px; line-height: 1.3; font-weight: 800; }
#dialog [data-header-panel] .phase-copy small { margin-top: 3px; color: #a397ad; font-size: 10px; line-height: 1.3; }
#dialog [data-header-panel] .is-current .phase-copy small { color: #9872b4; }
#dialog [data-header-panel] .is-future .phase-copy strong { color: #9d91a6; }
#dialog [data-header-panel] .phase-amount {
  min-width: 0;
  max-width: 110px;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.3;
  text-align: right;
  color: #92809e;
  font-variant-numeric: tabular-nums;
}
#dialog [data-header-panel] .is-current .phase-amount { color: #9470b1; }
#dialog [data-header-panel] .phase-note { margin-top: 12px; color: #a69bad; font-size: 11px; line-height: 1.45; }
#dialog [data-header-panel] .phase-next-season {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid #eee8f2;
  border-radius: 12px;
  color: #9d8aaa;
  font-size: 12px;
  line-height: 1.45;
}
#dialog [data-header-panel] .phase-next-season strong { display: block; margin-bottom: 3px; font-weight: 800; }
#dialog [data-header-panel] .phase-next-season > small { display: block; margin-top: 3px; font-size: 10px; color: #a396ac; }
#dialog [data-header-panel] .phase-next-season p { color: #a396ac; font-size: 11px; line-height: 1.45; }

@media (max-width: 360px) {
  body[data-mode=mobile] .mobile-player-header { gap: 8px; }
  .mobile-player { gap: 7px; }
  .mobile-player-avatar .avatar { width: 32px; height: 32px; }
  .mobile-player-name { font-size: 11px; }
  .mobile-player-balance { font-size: 12px; }
  .mobile-phase-links { flex-basis: 90px; }
  #dialog:has([data-header-panel]) { padding: 17px; }
  #dialog [data-header-panel] .phase-list li { grid-template-columns: 27px minmax(0, 1fr) minmax(40px, auto); gap: 8px; padding-inline: 8px; }
  #dialog [data-header-panel] .phase-number { width: 27px; height: 27px; }
  #dialog [data-header-panel] .phase-amount { max-width: 82px; font-size: 10px; }
}
