/* Mobile Play: reserve controls first; give remaining height to the coin. */
@media (max-width: 700px), (max-width: 950px) and (max-height: 500px) {
  :root {
    --mobile-top: calc(52px + env(safe-area-inset-top, 0px));
    --mobile-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-header {
    gap: 8px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .mobile-brand {
    flex-shrink: 0;
  }
  .mobile-header-actions {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    gap: 3px;
    align-items: center;
  }
  .mobile-header-actions > button,
  .mobile-header-actions > #mobile-help,
  .mobile-header-actions > #mobile-profile {
    display: grid;
    place-items: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 9px;
    margin: 0;
    background: transparent;
    position: relative;
  }
  #mobile-help svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  #mobile-help[aria-pressed='true'] {
    color: var(--lime);
    background: var(--website-surface-211-245-154-0_047058823529411764, #d3f59a0c);
  }
  .mobile-header-actions > .daily-mobile-button {
    font-size: 20px;
  }
  .mobile-header-actions .daily-mobile-button small {
    bottom: 1px;
    font-size: 7px;
    line-height: 9px;
    padding: 0 3px;
    left: 50%;
    translate: -50% 0;
  }
  #mobile-profile > .avatar-frame.frame-collection {
    --collection-size: 40px;
  }
  #mobile-profile > .avatar-frame:not(.frame-collection) {
    width: 32px;
    height: 32px;
  }
  #mobile-profile .avatar {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }
  .mobile-nav {
    padding-top: 5px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-nav a,
  .mobile-nav button {
    min-height: 50px;
    gap: 3px;
    font-size: 10px;
    padding: 4px 2px;
  }
  .mobile-nav svg {
    width: 21px;
    height: 21px;
  }
  body.play-page {
    height: var(--mobile-visible-height, 100dvh);
    min-height: 0;
    overflow: hidden;
    padding-bottom: var(--mobile-bottom);
  }
  body.play-page .workspace {
    height: calc(var(--mobile-visible-height, 100dvh) - var(--mobile-top) - var(--mobile-bottom));
    min-height: 0;
  }
  body.play-page main {
    height: 100%;
    padding: 6px 12px;
    min-height: 0;
  }
  body.play-page #view-play,
  body.play-page .play-layout,
  body.play-page .play-column {
    height: 100%;
    min-height: 0;
  }
  body.play-page .game-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 38px auto minmax(0, 1fr) 22px auto auto;
    gap: 3px;
    padding: 7px 8px;
    min-height: 0;
    height: 100%;
    overflow: visible;
  }
  body.play-page .game-card-top {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    align-items: center;
    min-height: 0;
    gap: 7px;
  }
  body.play-page .game-card-top .segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
    width: 100%;
    padding: 3px;
    gap: 3px;
    min-height: 38px;
    border-radius: 10px;
  }
  body.play-page .game-card-top .segmented button {
    min-width: 0;
    min-height: 30px;
    height: 30px;
    padding: 5px 8px;
    font-size: 12px;
    line-height: 18px;
    border-radius: 7px;
  }
  body.play-page .game-card-top .icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 10px;
    padding: 7px;
  }
  body.play-page .game-card-top .icon-button svg {
    width: 18px;
    height: 18px;
  }
  .play-page .game-card-top .mute-slash {
    left: 17px;
    top: 0;
    font-size: 25px;
  }
  body.play-page .mobile-game-summary {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    grid-template-rows: 12px 38px 13px;
    align-items: center;
    row-gap: 1px;
    padding: 5px 0 0;
    min-height: 0;
    overflow: visible;
  }
  body.play-page #mobile-streak-label {
    grid-column: 1/-1;
    grid-row: 1;
    font-size: 9px;
    line-height: 12px;
    letter-spacing: 1.7px;
    white-space: nowrap;
  }
  body.play-page.ranked-mode #mobile-streak-label {
    font-size: 10px;
    line-height: 12px;
    letter-spacing: 2px;
  }
  body.play-page.streak-enabled #mobile-streak,
  body.play-page #mobile-streak {
    grid-column: 2;
    grid-row: 2;
    font-size: 34px;
    line-height: 38px;
    margin: 0;
    min-height: 38px;
  }
  body.play-page .mobile-run-meta {
    display: contents;
  }
  .play-page .mobile-run-meta > span {
    font-size: 9px;
    line-height: 13px;
    color: var(--website-ink-156-169-141-1, #9ca98d);
    align-self: center;
  }
  .play-page .mobile-run-meta > span:first-child {
    grid-column: 1;
    grid-row: 2;
  }
  .play-page .mobile-run-meta > span:last-child {
    grid-column: 3;
    grid-row: 2;
  }
  .play-page .mobile-run-meta b {
    display: block;
    font-size: 13px;
    line-height: 17px;
  }
  body.play-page #mobile-play-note {
    grid-column: 1/-1;
    grid-row: 3;
    justify-self: center;
    display: block;
    font-size: 9px;
    line-height: 13px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  body.play-page .coin-stage {
    grid-column: 1;
    grid-row: 3;
    height: 100%;
    min-height: 0;
    padding: 0;
    margin: 0;
    container-type: size;
    display: grid;
    place-items: center;
    overflow: visible;
  }
  body.play-page.streak-enabled .coin-wrap,
  body.play-page .coin-wrap {
    width: min(330px, 90cqh, 80cqw);
    height: min(330px, 90cqh, 80cqw);
    max-width: none;
    min-width: 0;
  }
  body.play-page .coin-wrap.coin-frame-equipped {
    translate: 0 4%;
  }
  body.play-page .coin-caption {
    grid-column: 1;
    grid-row: 4;
    min-height: 22px;
    height: 22px;
    font-size: 10px;
    line-height: 18px;
    gap: 7px;
    margin: 0;
    justify-content: center;
    align-self: center;
  }
  body.play-page .coin-caption a {
    min-height: 22px;
    align-items: center;
  }
  body.play-page .game-controls {
    grid-column: 1;
    grid-row: 5;
    width: 100%;
    padding: 0;
    min-height: 0;
    align-self: stretch;
  }
  body.play-page .game-controls .choice-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    margin: 0;
  }
  body.play-page.streak-enabled .game-controls .choice,
  body.play-page .game-controls .choice {
    height: 38px;
    min-height: 38px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9px;
    gap: 6px;
    justify-content: center;
    line-height: 18px;
  }
  body.play-page .choice-symbol {
    font-size: 18px;
  }
  .play-page .choice-check {
    font-size: 10px;
    right: 9px;
  }
  body.play-page.streak-enabled .game-controls > .flip-button,
  body.play-page .game-controls > .flip-button {
    height: 42px;
    min-height: 42px;
    margin: 5px 0 0;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
    justify-content: center;
    line-height: 18px;
  }
  /* Keep the live result announcement accessible without reserving a text row. */
  body.play-page .game-controls #result-message {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  body.play-page .run-section {
    grid-column: 1;
    grid-row: 6;
    min-height: 0;
    padding: 0;
    margin: 3px 0 0;
  }
  body.play-page .run-header {
    margin: 0 0 4px !important;
  }
  .play-page.ranked-mode .run-header {
    font-size: 7px !important;
    line-height: 11px;
  }
  .play-page.ranked-mode .run-header .streak-score {
    font-size: 10px !important;
  }
  body.play-page.streak-enabled #flip-history {
    gap: 4px;
    margin: 0 0 5px;
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
  body.play-page.streak-enabled .flip-slot {
    height: 16px;
    line-height: 14px;
    font-size: 9px;
    border-radius: 4px;
  }
  body.play-page .run-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  body.play-page .run-footer button {
    height: 34px;
    min-height: 34px;
    padding: 6px 3px;
    font-size: 10px;
    border-radius: 8px;
    line-height: 16px;
    gap: 5px;
    justify-content: center;
  }
  .play-page .run-footer button svg {
    width: 14px;
    height: 14px;
  }
  body.play-page .coin-caption,
  body.play-page .game-controls,
  body.play-page .run-section {
    position: relative;
    top: -8px;
  }
  body.play-page .coin-caption {
    top: -14px;
  }
}
@media (max-width: 700px) and (max-height: 590px) {
  body.play-page .mobile-game-summary {
    grid-template-rows: 11px 36px 11px;
    padding-top: 3px;
  }
  .play-page #mobile-streak-label {
    line-height: 11px;
  }
  body.play-page.streak-enabled #mobile-streak,
  body.play-page #mobile-streak {
    font-size: 32px;
    line-height: 36px;
    min-height: 36px;
  }
  .play-page #mobile-play-note {
    font-size: 8px;
    line-height: 11px;
  }
  body.play-page .game-card {
    gap: 2px;
    padding: 6px 7px;
  }
  .play-page .run-header {
    line-height: 10px;
  }
  .play-page .flip-slot {
    height: 14px !important;
    font-size: 8px !important;
  }
}

@media (max-width: 700px), (max-width: 950px) and (max-height: 500px) {
  #mobile-help svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

/* Keep the same wired actions; relocate them only after Ranked is exhausted. */
.mobile-complete-actions {
  display: none;
}
@media (max-width: 700px), (max-width: 950px) and (max-height: 500px) {
  .toast {
    bottom: calc(var(--mobile-bottom) + 36px);
  }
  body.play-page .run-section .run-footer {
    display: none;
  }
  body.play-page.mobile-ranked-exhausted .game-controls .choice-buttons {
    display: none;
  }
  body.play-page.mobile-ranked-exhausted .mobile-complete-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
  }
  body.play-page .mobile-complete-actions > button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 38px;
    min-height: 38px;
    padding: 6px 4px;
    border: 1px solid var(--website-line-70-85-54-1, #465536);
    border-radius: 9px;
    background: var(--website-surface-32-37-29-1, #20251d);
    color: var(--text);
    font: inherit;
    font-size: 11px;
    line-height: 18px;
  }
  body.play-page .mobile-complete-actions > button svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }
  body.play-page .mobile-complete-actions > button:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 2px;
  }
}

/* Shared centerline for mission, fullscreen and profile controls. */
@media (max-width: 700px), (max-width: 950px) and (max-height: 500px) {
  .mobile-header-actions {
    align-items: center;
    justify-items: center;
  }
  .mobile-header-actions > button {
    align-self: center;
    line-height: 1;
  }
  .mobile-header-actions .daily-mobile-button [data-priority-icon] {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 20px;
  }
  #mobile-profile > .avatar-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin: 0;
    align-self: center;
  }
}

@media (max-width: 950px) and (max-height: 500px) {
  body.play-page {
    overflow: auto;
    height: auto;
    min-height: var(--mobile-visible-height, 100dvh);
  }
  body.play-page .workspace {
    height: auto;
    min-height: calc(
      var(--mobile-visible-height, 100dvh) - var(--mobile-top) - var(--mobile-bottom)
    );
  }
  body.play-page main {
    height: auto;
    padding-bottom: 12px;
  }
  body.play-page.streak-enabled .game-card,
  body.play-page .game-card {
    height: max(
      280px,
      calc(var(--mobile-visible-height, 100dvh) - var(--mobile-top) - var(--mobile-bottom) - 18px)
    );
    grid-template-columns: minmax(0, 1fr) minmax(200px, 0.9fr);
    grid-template-rows: 34px 60px 85px minmax(18px, 1fr);
  }
  body.play-page .game-card-top {
    grid-column: 1/-1;
    grid-row: 1;
    height: 34px;
    min-height: 0;
  }
  body.play-page .game-card-top .segmented {
    min-height: 32px;
    height: 32px;
  }
  body.play-page .game-card-top .segmented button {
    min-height: 26px;
    height: 26px;
    padding: 3px 8px;
  }
  body.play-page .game-card-top .icon-button {
    height: 32px;
    min-height: 32px;
  }
  body.play-page .mobile-game-summary {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    padding: 0;
    grid-template-rows: 10px 30px 11px;
  }
  body.play-page #mobile-streak {
    font-size: 28px !important;
    line-height: 30px !important;
    min-height: 30px !important;
  }
  body.play-page .coin-stage {
    grid-column: 1;
    grid-row: 2/5;
  }
  body.play-page .coin-caption {
    display: none;
  }
  body.play-page .game-controls {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
    top: 0;
  }
  body.play-page .run-section {
    grid-column: 2;
    grid-row: 4;
    top: 0;
    align-self: start;
  }
  body.play-page .run-footer {
    display: none;
  }
  body.play-page .coin-wrap {
    width: min(270px, 88cqh, 75cqw) !important;
    height: min(270px, 88cqh, 75cqw) !important;
  }
}
