/*
 * Canonical Main / Stage utility controls.
 * The game owns its artwork and data; this file owns only Return, Settings,
 * language/audio placement, and their stable header geometry.
 */
.wp-shell-header {
  position: relative;
  z-index: 100;
  isolation: isolate;
}

.wp-main-shell-header {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 58px minmax(0, 1fr) 58px !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 56px;
  width: min(100%, 920px) !important;
  max-width: 920px !important;
  margin-inline: auto !important;
  padding: 4px 6px !important;
}

.wp-main-shell-header > :not(.wp-shell-return):not(.wp-shell-settings):not(.wp-shell-legacy-control) {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.wp-main-shell-header > :is(.top-nav-left, .top-nav-right) {
  display: contents !important;
}

.wp-main-shell-header > strong,
.wp-main-shell-header > h1,
.wp-main-shell-header > h2,
.wp-main-shell-header > div:not(.wp-shell-settings) {
  text-align: center;
}

.wp-main-shell-header > :is(.wp-generated-main-title, .wp-shell-main-title, h1, h2, strong) {
  position: absolute !important;
  grid-column: 1 / -1 !important;
  grid-row: 1 !important;
  inset-inline: 70px !important;
  left: 70px !important;
  width: auto !important;
  max-width: none !important;
  transform: none !important;
  text-align: center !important;
  margin: 0 !important;
}

.wp-main-shell-header > .wp-shell-main-title {
  font: 800 22px/1.2 system-ui, sans-serif !important;
  letter-spacing: 0 !important;
}

.wp-shell-return {
  box-sizing: border-box !important;
  grid-column: 1;
  justify-self: start;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 58px !important;
  min-width: 58px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  padding: 0 !important;
  border-radius: 12px !important;
}

.wp-shell-return > img {
  display: block;
  width: 23px !important;
  height: 23px !important;
  object-fit: contain;
}

.wp-shell-return-arrow {
  font: 900 22px/1 system-ui, sans-serif;
}

.wp-shell-settings {
  grid-column: 3;
  justify-self: end;
  position: relative;
  z-index: 40;
}

.wp-shell-settings-button {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 48px !important;
  min-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  padding: 0 !important;
  border: 1px solid color-mix(in srgb, currentColor 34%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, #071426 88%, transparent);
  color: #fff;
  box-shadow: 0 8px 22px #0005;
  cursor: pointer;
}

.wp-shell-settings-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.wp-shell-settings-button:focus-visible,
.wp-shell-settings-popover :is(button, select, input):focus-visible {
  outline: 3px solid #66e6bd;
  outline-offset: 2px;
}

.wp-shell-settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(280px, calc(100vw - 24px));
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #ffffff42;
  border-radius: 16px;
  background: #071426;
  color: #fff;
  box-shadow: 0 18px 45px #0009;
  text-align: start;
}

.wp-shell-settings-popover[hidden] {
  display: none !important;
}

.wp-shell-settings-title {
  font: 900 16px/1.2 system-ui, sans-serif;
}

.wp-shell-settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font: 800 13px/1.25 system-ui, sans-serif;
}

.wp-shell-settings-row[hidden] {
  display: none !important;
}

.wp-shell-settings-row > span:first-child {
  grid-column: 1;
  grid-row: 1;
}

.wp-shell-language-row > :not(span:first-child) {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  width: 144px !important;
  max-width: 144px !important;
}

.wp-shell-language-row > :not(span:first-child) > span {
  display: none !important;
}

.wp-shell-settings-row select {
  width: 144px !important;
  max-width: 144px !important;
  min-height: 44px !important;
  margin: 0 !important;
  border: 1px solid #ffffff42 !important;
  border-radius: 10px !important;
  background: #10233c !important;
  color: #fff !important;
  padding: 0 10px !important;
}

.wp-shell-volume-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.wp-shell-volume-control input[type="range"] {
  width: 100%;
  min-width: 0;
  height: 28px;
  margin: 0;
  accent-color: #66e6bd;
  cursor: pointer;
}

.wp-shell-volume-control output {
  color: #dffdf4;
  font: 800 12px/1 system-ui, sans-serif;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.wp-shell-combined-sound-row {
  grid-template-columns: minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
}

.wp-shell-combined-sound-toggle {
  position: relative;
  width: 52px;
  min-width: 52px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid #ffffff52;
  border-radius: 999px;
  background: #34445a;
  cursor: pointer;
}

.wp-shell-combined-sound-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px #0007;
  transition: transform 160ms ease;
}

.wp-shell-combined-sound-toggle[aria-checked="true"] {
  border-color: #66e6bd;
  background: #1f9b79;
}

.wp-shell-combined-sound-toggle[aria-checked="true"]::after {
  transform: translateX(22px);
}

/* Stage themes must not resize controls nested inside the Settings popover. */
.wp-stage-shell-header .wp-shell-settings-popover .wp-shell-settings-title {
  font: 900 16px/1.2 system-ui, sans-serif !important;
}

.wp-stage-shell-header .wp-shell-settings-popover .wp-shell-combined-sound-toggle {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 52px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

.wp-shell-legacy-control {
  display: none !important;
}

/* sound.js injects its rule after the static styles; keep the retired floating
   control hidden once Settings owns the combined sound switch. */
.sound-toggle.wp-shell-legacy-control {
  display: none !important;
}

.wp-shell-settings-extra {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  position: static !important;
}

.wp-stage-shell-header {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr) 48px !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  min-height: 56px !important;
  padding: 4px !important;
}

/* Battle screens without a recognized native header receive this overlay.
   It must never participate in the Battle grid, or the adopted return action
   can become a final row underneath the play controls. */
body.wp-shell-battle-active .wp-generated-battle-header {
  box-sizing: border-box !important;
  position: absolute !important;
  z-index: 90 !important;
  inset: 8px auto auto 8px !important;
  display: block !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

body.wp-shell-battle-active .wp-generated-battle-header > [data-wp-return="battle"] {
  position: static !important;
  inset: auto !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: auto;
}

.wp-stage-shell-header > :not(.wp-shell-return):not(.wp-shell-settings):not(.wp-shell-legacy-control) {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  margin: 0 !important;
  overflow: hidden;
  text-align: center !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-stage-shell-header > :is(h1, h2, strong) {
  font: 800 22px/1.2 system-ui, sans-serif !important;
  letter-spacing: 0 !important;
}

.wp-standard-main-screen {
  box-sizing: border-box !important;
  display: block;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  grid-template: none !important;
  width: min(100%, 920px) !important;
  max-width: 920px !important;
  height: auto !important;
  min-height: 0 !important;
  margin-inline: auto !important;
  padding: 0 !important;
  overflow: visible !important;
}

.wp-standard-main-flow-owner {
  box-sizing: border-box !important;
  display: block !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  height: auto !important;
  min-height: var(--wp-main-flow-min-height, 0px) !important;
  max-height: none !important;
  overflow: visible !important;
}

.wp-standard-main-flow-owner .wp-standard-main-flow-node {
  box-sizing: border-box !important;
  display: block !important;
  position: relative !important;
  inset: auto !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  transform-origin: center !important;
  width: 100% !important;
  max-width: 920px !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin-inline: auto !important;
  overflow: visible !important;
}

.wp-standard-main-composition {
  box-sizing: border-box;
  flex: 0 0 100% !important;
  grid-column: 1 / -1;
  width: 100%;
  display: grid !important;
  grid-template-columns: 420px minmax(0, 1fr) !important;
  align-items: center;
  gap: clamp(16px, 3vw, 28px);
  margin: 0 !important;
  padding: clamp(12px, 2.5vw, 22px) !important;
}

.wp-standard-main-poster {
  width: 420px;
  height: 420px;
  overflow: hidden;
  border-radius: 22px;
}

.wp-standard-main-poster-media,
.wp-standard-main-poster-media > img,
.wp-standard-main-poster > img {
  box-sizing: border-box !important;
  display: block !important;
  width: 420px !important;
  min-width: 420px !important;
  max-width: 420px !important;
  height: 420px !important;
  min-height: 420px !important;
  max-height: 420px !important;
  aspect-ratio: 1 !important;
  margin: 0 !important;
  object-fit: cover !important;
  border-radius: inherit;
}

.wp-standard-main-copy {
  min-width: 0;
  height: 420px;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  align-content: center;
  gap: 14px;
}

.wp-standard-main-copy > * {
  grid-column: 1 !important;
}

.wp-standard-main-summary {
  display: block !important;
  margin: 0 !important;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.55;
}

.wp-standard-main-progress {
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center;
  width: 100%;
  height: 44px !important;
  min-height: 0 !important;
  max-height: 44px !important;
  padding-block: 0 !important;
  overflow: hidden;
  margin: 0 !important;
}

.wp-standard-main-start,
.wp-standard-main-copy > [data-wp-main-start] {
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 52px !important;
  min-height: 52px !important;
  max-height: 52px !important;
  margin: 0 !important;
}

.wp-main-legacy-layout {
  display: none !important;
}

body:is(.wp-shell-stage-active, .wp-shell-battle-active) .wp-standard-main-composition {
  display: none !important;
}

body:is(.wp-shell-stage-active, .wp-shell-battle-active)
  :is(.game-page-info, .public-guide, .game-guide, .guide) {
  display: none !important;
}

.public-guide.guide {
  width: 100%;
  margin-top: 16px;
  padding: clamp(18px, 4vw, 32px);
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 22px;
  background: color-mix(in srgb, #071426 88%, transparent);
  color: #f8fafc;
  text-align: start;
}

.public-guide.guide h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4vw, 30px);
}

.public-guide.guide p {
  margin: 0;
  line-height: 1.65;
}

.wp-stage-shell-header > .wp-shell-settings {
  position: relative;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  top: auto;
  right: auto;
}

.wp-stage-shell-header > .wp-shell-settings .wp-shell-language-row {
  display: none;
}

@media (max-width: 699px) {
  .wp-main-shell-header > .wp-shell-main-title,
  .wp-stage-shell-header > :is(h1, h2, strong) {
    font-size: 20px !important;
  }

  .wp-main-shell-header {
    grid-template-columns: 58px minmax(0, 1fr) 58px !important;
    gap: 4px !important;
  }

  .wp-shell-return {
    width: 58px !important;
    min-width: 58px !important;
    height: 48px !important;
  }

  .wp-shell-settings-button {
    width: 48px;
    min-width: 48px;
  }

  .wp-standard-main-composition {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px;
    padding: 10px !important;
  }

  .wp-standard-main-poster {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .wp-standard-main-copy {
    height: auto;
  }

  .wp-standard-main-poster-media,
  .wp-standard-main-poster-media > img,
  .wp-standard-main-poster > img {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: 1 !important;
  }
}
