/* Final mobile layer. Loaded last so desktop rules remain untouched. */
@media (max-width: 900px) {
  html {
    scroll-padding-top: 118px;
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  #content {
    width: 100%;
    padding: 0 8px 32px;
  }

  .dual-task-shell,
  .game-container,
  .game-container-colors,
  .dual-task-left-panel,
  .dual-task-right-panel,
  .game-description {
    min-width: 0;
    max-width: 100%;
  }

  .dual-task-shell {
    gap: 12px;
    margin-inline: auto;
  }

  .game-container,
  .game-container-colors,
  .dual-task-left-panel {
    padding: 10px;
    gap: 14px;
    border-radius: 18px;
  }

  .colors-main-row,
  .dual-task-play-area {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 14px;
  }

  .board-wrapper,
  .game-container-colors .board-wrapper {
    width: fit-content;
    max-width: 100%;
    padding: 8px;
    margin-inline: auto;
    border-radius: 18px;
    touch-action: manipulation;
  }

  .board-grid,
  .board-grid-color {
    max-width: 100%;
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .numbers-wrapper-dt,
  .game-container-colors .numbers-wrapper-dt {
    width: min(100%, 300px);
    max-width: 100%;
    padding: 12px;
    margin-inline: auto;
  }

  .number-pool-wrapper,
  .number-pool-wrapper-dual-task {
    max-width: 100%;
  }

  .number-header,
  .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    font-size: 18px;
    text-align: center;
  }

  .number,
  .number-dual-task,
  .color-token {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .number.mobile-selected,
  .number-dual-task.mobile-selected,
  .color-token.mobile-selected {
    outline: 3px solid #16788a;
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: 0 0 0 5px rgba(22, 120, 138, .15), 0 8px 18px rgba(0, 0, 0, .16);
  }

  .info-board {
    width: 100%;
    justify-content: center;
  }

  .mini-tile-debag {
    max-width: 100%;
  }

  .ui-btn,
  .mini-reset,
  .mini-reset-debag,
  .debug-btn,
  .start-button,
  .modal-btn,
  .game-results__continue {
    min-height: 48px;
    touch-action: manipulation;
  }

  .dual-task-right-panel {
    width: 100%;
    padding: 12px;
    border-radius: 18px;
  }

  .game-info-card,
  .debug-card {
    width: 100%;
  }

  .game-description {
    padding: 20px 10px;
    border-radius: 18px;
  }

  .icon-row {
    overflow-x: auto;
    justify-content: flex-start;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .icon-cell {
    flex: 0 0 112px;
    scroll-snap-align: start;
  }

  .panel-overlay,
  .modal-overlay {
    padding: 12px;
    align-items: center;
  }

  .panel,
  .modal {
    width: min(100%, 520px);
    height: auto;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 20px 16px;
  }

  .panel-title {
    font-size: 24px;
  }

  .panel-text {
    font-size: 18px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-btn {
    flex: 1 1 130px;
  }

  .video-demo__stage,
  .video-demo__video,
  .video-demo__poster,
  iframe {
    max-width: 100%;
  }

  .field-debug-summary {
    max-width: calc(100vw - 16px);
    overflow-wrap: anywhere;
  }
}

/* Mobile results overview: readable cards instead of a squeezed 9-column table. */
@media (max-width: 620px) {
  .game-results__comparison-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .game-results__comparison-table,
  .game-results__comparison-table tbody {
    display: block;
    width: 100%;
  }

  .game-results__comparison-table thead {
    display: none;
  }

  .game-results__comparison-table .game-results__summary-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--results-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 7px 20px rgb(15 23 42 / 6%);
  }

  .game-results__comparison-table .game-results__summary-row > td {
    display: flex;
    min-width: 0;
    min-height: 62px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 9px 8px;
    border-right: 1px solid #e7edf5;
    border-bottom: 1px solid #e7edf5;
    font-size: 13px;
    line-height: 1.2;
    overflow-wrap: normal;
    word-break: normal;
  }

  .game-results__comparison-table .game-results__summary-row > td:first-child {
    grid-column: 1 / -1;
    min-height: 58px;
    padding: 10px 12px;
    border-right: 0;
  }

  .game-results__comparison-table .game-results__summary-row > td:nth-child(5),
  .game-results__comparison-table .game-results__summary-row > td:nth-child(9) {
    border-right: 0;
  }

  .game-results__comparison-table .game-results__summary-row > td:nth-child(n+6) {
    border-bottom: 0;
  }

  .game-results__comparison-table .game-results__summary-row > td:not(:first-child)::before {
    color: var(--results-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .035em;
    line-height: 1.15;
    text-transform: uppercase;
  }

  html[lang="ru"] .game-results__summary-row > td:nth-child(2)::before { content: "Поле"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(3)::before { content: "Уровень"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(4)::before { content: "Попыток"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(5)::before { content: "Первый"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(6)::before { content: "Лучший"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(7)::before { content: "Финальный"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(8)::before { content: "Очки"; }
  html[lang="ru"] .game-results__summary-row > td:nth-child(9)::before { content: "Время"; }

  html[lang="en"] .game-results__summary-row > td:nth-child(2)::before { content: "Field"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(3)::before { content: "Level"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(4)::before { content: "Attempts"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(5)::before { content: "First"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(6)::before { content: "Best"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(7)::before { content: "Final"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(8)::before { content: "Points"; }
  html[lang="en"] .game-results__summary-row > td:nth-child(9)::before { content: "Time"; }

  .game-results__comparison-table .game-results__expand {
    gap: 8px;
  }

  .game-results__comparison-table .game-results__expand strong {
    font-size: 16px;
    word-break: normal;
  }

  .game-results__comparison-table .game-results__details-row:not([hidden]) {
    display: block;
    margin: -4px 0 12px;
    overflow: hidden;
    border: 1px solid var(--results-border);
    border-radius: 14px;
    background: #f8fbff;
  }

  .game-results__comparison-table .game-results__details-row > td {
    display: block;
    width: 100%;
    border: 0;
  }

  .game-results__details-content {
    padding: 14px 12px 16px;
    box-shadow: inset 3px 0 0 #93b8ff;
  }
}


/* Mobile Series modal: lock page interaction and keep the whole selector accessible. */
.series-modal-close,
.series-modal-backdrop {
  display: none;
}

@media (max-width: 620px) {
  body.series-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  #ad-site .series-modal-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 4998;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(25,48,57,.30);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    cursor: default;
  }

  #ad-site.series-modal-open #ad-series-panel.series-panel {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    z-index: 5000;
    display: block;
    width: auto;
    max-height: none;
    margin: 0;
    padding: 54px 8px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,.82);
    border-radius: 22px;
    background: rgba(239,248,251,.98);
    box-shadow: 0 24px 70px rgba(31,58,69,.28), inset 0 1px rgba(255,255,255,.86);
    -webkit-overflow-scrolling: touch;
  }

  #ad-site.series-modal-open .series-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.88);
    color: #26363d;
    font: 400 27px/1 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    box-shadow: 0 3px 13px rgba(47,79,91,.14);
  }

  #ad-site.series-modal-open .series-inner {
    display: grid;
    width: 100%;
    margin: 0;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #ad-site.series-modal-open .mode-section,
  #ad-site.series-modal-open .settings-section {
    padding: 10px;
    border-radius: 17px;
  }

  #ad-site.series-modal-open .section-title {
    margin-bottom: 7px;
    font-size: 14px;
  }

  #ad-site.series-modal-open .mode-grid {
    border-radius: 14px;
  }

  #ad-site.series-modal-open .mode-card {
    min-height: 52px;
    padding: 6px;
    font-size: 13px;
    line-height: 1.15;
  }

  #ad-site.series-modal-open .mode-description {
    margin-top: 7px;
    padding: 9px 11px;
    border-radius: 13px;
  }

  #ad-site.series-modal-open .mode-description strong {
    font-size: 15px;
  }

  #ad-site.series-modal-open .mode-description p {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.3;
  }

  #ad-site.series-modal-open .settings-group + .settings-group {
    margin-top: 9px;
  }

  #ad-site.series-modal-open .segments,
  #ad-site.series-modal-open .fixed-all {
    min-height: 42px;
    border-radius: 13px;
  }

  #ad-site.series-modal-open .segments button {
    min-height: 34px;
    font-size: 13px;
  }

  #ad-site.series-modal-open .start {
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    border-radius: 13px;
    font-size: 14px;
  }

  #ad-site.series-modal-open .selection {
    min-height: 16px;
    margin-top: 6px;
    font-size: 11px;
  }
}

/* One field surface on phones: the surrounding game card is the only glass
   plate; the board wrapper is now structural only. */
@media (max-width: 620px) {
  .game-container > .board-wrapper,
  .game-container-colors .board-wrapper,
  .dual-task-play-area > .board-wrapper {
    padding: 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Challenge: all three game modes stay visible as thumb-sized choices. */
@media (max-width: 620px) {
  #content:has(.card-top-challenge) {
    padding-inline: 5px;
  }

  .card-top-challenge.apple-card-challenger {
    width: calc(100vw - 10px);
    margin: 5px auto 12px;
    padding: 10px;
    gap: 12px;
    border-radius: 16px;
  }

  .card-top-challenge > .step:first-child {
    width: 100%;
  }

  .card-top-challenge .challenge-inline-title {
    display: none;
  }

  .card-top-challenge .step-title {
    margin-bottom: 7px;
    font-size: 15px;
    line-height: 1.2;
  }

  .card-top-challenge .game-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .card-top-challenge .game-card,
  .card-top-challenge .game-card + .game-card {
    min-width: 0;
    min-height: 82px;
    padding: 10px 4px 7px;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 13px;
    background: linear-gradient(135deg,var(--inactive-a),var(--inactive-b));
    box-shadow: inset 0 1px rgba(255,255,255,.72), 0 5px 13px rgba(63,87,101,.06);
  }

  .card-top-challenge .game-card.number-challenge-desc.selected {
    background: linear-gradient(135deg,var(--easy-a),var(--easy-b));
  }
  .card-top-challenge .game-card.color-challenge-desc.selected {
    background: linear-gradient(135deg,var(--medium-a),var(--medium-b));
  }
  .card-top-challenge .game-card.dual-challenge-desc.selected {
    background: linear-gradient(135deg,var(--hard-a),var(--hard-b));
  }

  .card-top-challenge .game-card .mode-icon,
  .card-top-challenge .game-card .dual-triangle {
    display: none;
  }

  .card-top-challenge .game-card h3 {
    min-height: 28px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(10px, 3vw, 12px);
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .card-top-challenge .game-card .check {
    top: 5px;
    right: 5px;
    width: 19px;
    height: 19px;
  }
  .card-top-challenge .game-card .check svg {
    width: 12px;
    height: 12px;
  }

  .card-top-challenge .game-card .mode-select-pill {
    min-width: 0;
    width: calc(100% - 8px);
    min-height: 26px;
    margin-top: 5px;
    padding: 0 3px;
    border-radius: 8px;
    font-size: clamp(8px, 2.4vw, 10px);
  }

  .card-top-challenge .settings-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card-top-challenge .settings-challenge-left {
    order: 1;
    min-height: 0;
    padding: 12px;
    gap: 14px;
    border-radius: 16px;
  }

  .card-top-challenge .description-step {
    order: 2;
  }

  .card-top-challenge .segmented {
    height: 46px;
    border-radius: 12px;
  }

  .card-top-challenge .segmented button {
    padding-inline: 2px;
    font-size: 12px;
  }

  .card-top-challenge .start-button {
    height: 50px;
    min-height: 50px;
  }

  .card-top-challenge .summary {
    margin-top: 7px;
    font-size: 11px;
  }

  .card-top-challenge .description-card {
    min-height: 0;
    height: auto;
    padding: 14px;
    border-radius: 16px;
  }

  .card-top-challenge .description-head {
    margin-bottom: 7px;
  }
  .card-top-challenge .description-head h3 { font-size: 17px; }
  .card-top-challenge .description-text {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
  }
  .card-top-challenge .demo-title {
    margin: 10px 0 7px;
    font-size: 13px;
  }
  .card-top-challenge .demo-preview {
    min-height: 180px;
    height: min(220px, 32dvh);
    border-radius: 13px;
  }
  .card-top-challenge .demo-preview .demo-placeholder {
    padding: 12px;
    font-size: 15px;
  }
}


/* Numbers mobile information drawer. Keep after all earlier mobile rules. */
.mobile-info-toggle,
.mobile-info-close,
.mobile-info-backdrop {
  display: none;
}

@media (max-width: 620px) {
  body.mobile-info-open {
    overflow: hidden;
  }

  .debug-header {
    grid-template-columns: minmax(0, 1fr) auto auto !important;
  }

  .mobile-info-toggle {
    display: inline-flex;
    width: 31px;
    min-width: 31px;
    height: 31px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,.74);
    border-radius: 8px;
    background: rgba(205,235,242,.76);
    color: #176979;
    font: 700 17px/1 Georgia, serif;
    box-shadow: inset 0 1px rgba(255,255,255,.82);
    touch-action: manipulation;
  }

  .mobile-info-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1290;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(24,47,56,.22);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  body.mobile-info-open .mobile-info-backdrop {
    display: block;
  }

  .dual-task-shell > .dual-task-right-panel#numbersGameInfo,
  .dual-task-shell > .dual-task-right-panel#colorsGameInfo,
  .dual-task-shell > .dual-task-right-panel#dualTaskGameInfo {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: 0;
    bottom: 0;
    z-index: 1300;
    display: flex;
    width: min(88vw, 390px);
    max-width: min(88vw, 390px);
    margin: 0;
    padding: 58px 12px max(18px, env(safe-area-inset-bottom));
    gap: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 22px 0 0 0;
    background: rgba(239,248,251,.98);
    box-shadow: -16px 0 38px rgba(40,72,84,.22);
    transform: translateX(105%);
    transition: transform .24s ease;
    visibility: hidden;
  }

  body.mobile-info-open .dual-task-shell > .dual-task-right-panel#numbersGameInfo,
  body.mobile-info-open .dual-task-shell > .dual-task-right-panel#colorsGameInfo,
  body.mobile-info-open .dual-task-shell > .dual-task-right-panel#dualTaskGameInfo {
    transform: translateX(0);
    visibility: visible;
  }

  #numbersGameInfo .mobile-info-close,
  #colorsGameInfo .mobile-info-close,
  #dualTaskGameInfo .mobile-info-close {
    position: absolute;
    top: 10px;
    right: 12px;
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.82);
    color: #26363d;
    font: 400 27px/1 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    box-shadow: 0 3px 13px rgba(47,79,91,.13);
    touch-action: manipulation;
  }

  #numbersGameInfo .game-info-card,
  #numbersGameInfo .debug-card,
  #numbersGameInfo .video-demo-card,
  #colorsGameInfo .game-info-card,
  #colorsGameInfo .debug-card,
  #colorsGameInfo .video-demo-card,
  #dualTaskGameInfo .game-info-card,
  #dualTaskGameInfo .debug-card,
  #dualTaskGameInfo .video-demo-card {
    width: 100%;
    margin: 0;
  }

  #numbersGameInfo .video-demo__stage,
  #colorsGameInfo .video-demo__stage,
  #dualTaskGameInfo .video-demo__stage {
    width: 100%;
  }

  body.has-game-demo-overlay > .game-demo-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    padding: max(58px, calc(env(safe-area-inset-top) + 48px)) 10px max(12px, env(safe-area-inset-bottom));
    border-radius: 0;
    background: rgba(232,243,248,.98);
  }

  body.has-game-demo-overlay > .game-demo-overlay .video-demo__video {
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 82px - env(safe-area-inset-bottom));
    border-radius: 14px;
  }

  body.has-game-demo-overlay > .game-demo-overlay .game-demo-overlay__close {
    top: max(8px, env(safe-area-inset-top));
    right: 10px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    color: #26363d;
    font: 400 28px/1 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    box-shadow: 0 4px 16px rgba(36,61,72,.17);
  }
}

/* Final cascade lock for the approved phone layout. Keep this block last. */
@media (max-width: 620px) {
  :root { --site-menus-height: 54px; --top-header-height: 54px; }

  #ad-site .site-header {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 34px auto;
    grid-template-rows: 1fr;
    gap: 7px;
    width: 100%;
    height: 54px;
    min-height: 54px;
    padding: 4px 8px;
    border-radius: 0 0 13px 13px;
  }
  #ad-site .brand-tools { min-width: 0; gap: 6px; }
  #ad-site .brand { width: 42px; height: 42px; }
  #ad-site .brand-icon { width: 36px; height: 36px; }
  #ad-site .brand-beta { top: -1px; left: -1px; font-size: 9px; }
  #ad-site .brand-name { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
  #ad-site .icon-board-cell.blocked::after { width: 11px; height: 11px; }
  #ad-site .icon-board-cell.num,
  #ad-site .icon-board-coef { font-size: 14px; }

  #ad-site .mobile-menu-toggle {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(255,255,255,.18);
    color: #29343d;
    box-shadow: inset 0 1px rgba(255,255,255,.55);
  }
  #ad-site .mobile-menu-toggle span { width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  #ad-site .lang-dropdown { margin: 0; }
  #ad-site .lang-toggle { min-height: 34px; padding: 3px 9px; gap: 5px; font-size: 12px; }

  #ad-site .site-header > .menu-links {
    position: absolute;
    top: calc(100% + 5px);
    right: 8px;
    z-index: 1200;
    display: none;
    width: min(250px, calc(100vw - 16px));
    min-height: 0;
    max-height: calc(100dvh - 70px);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 15px;
    background: rgba(247,251,253,.96);
    box-shadow: 0 18px 38px rgba(77,101,112,.16);
    backdrop-filter: blur(22px) saturate(120%);
  }
  #ad-site.mobile-nav-open .site-header > .menu-links { display: flex; }
  #ad-site .site-header > .menu-links a,
  #ad-site .site-header > .menu-links button {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: left;
    font-size: 14px;
  }
  #ad-site .menu-links .divider { display: none; }

  .apple-card.card-top { top: 54px; width: calc(100vw - 10px); padding: 3px 4px; border-radius: 0 0 11px 11px; }
  #content:has(.dual-task-shell) { gap: 4px; padding: 4px 5px 18px; }
  .header-title { display: none; }
  .debug-header, .board-meta { gap: 3px; }
  .board-meta-tile, .board-meta-mode, .debug-header .debug-timer {
    height: 31px; min-height: 31px; padding-inline: 5px; border-radius: 8px; font-size: 11px;
  }
  .board-meta-state { width: 32px; flex: 0 0 32px; }
  .board-meta-state svg { width: 18px; height: 18px; }
  .debug-header .debug-timer { min-width: 82px; }

  .dual-task-shell { padding: 3px; gap: 7px; }
  .game-container, .game-container-colors, .dual-task-left-panel { gap: 6px; padding: 7px; border-radius: 15px; }

  .patterns-card { width: 100%; margin: 0 !important; padding: 4px 6px; border-radius: 10px; }
  .patterns-header { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 7px; }
  .patterns-title { margin: 0; font-size: 11px; line-height: 1.05; }
  .patterns-list { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 4px; width: 100%; overflow: hidden; }
  .pattern-item { flex: 0 1 auto; gap: 2px; }
  .pattern-grid { grid-template-columns: repeat(2,12px); grid-template-rows: repeat(2,12px); }
  .pattern-cell { width: 12px; height: 12px; border-radius: 3px; }
  .pattern-score { min-width: 22px; height: 20px; padding-inline: 3px; font-size: 10px; }

  .game-container:not(:has(.score-details-board)),
  .game-container-colors:not(:has(.score-details-board)) {
    grid-template-columns: repeat(5, minmax(0,44px));
    justify-content: center;
    column-gap: 5px;
  }
  .game-container .mini-tile, .game-container-colors .mini-tile,
  .game-container .mini-reset, .game-container-colors .mini-reset,
  .game-container .mini-reset-debag, .game-container-colors .mini-reset-debag,
  .game-container .debug-btn, .game-container-colors .debug-btn {
    width: 44px; min-width: 44px; height: 36px; min-height: 36px; padding: 0; border-radius: 8px !important; font-size: 13px;
  }
  .game-container .mini-reset svg, .game-container-colors .mini-reset svg,
  .game-container .mini-reset-debag svg, .game-container-colors .mini-reset-debag svg,
  .game-container .debug-btn svg, .game-container-colors .debug-btn svg { width: 20px; height: 20px; }

  .board-wrapper, .game-container-colors .board-wrapper { padding: 5px; border-radius: 14px; }
  body.mobile-board-size-4x4, .dual-task-shell.board-size-4x4 { --cell-size: clamp(48px,15vw,56px); }
  body.mobile-board-size-5x5, .dual-task-shell.board-size-5x5 { --cell-size: clamp(39px,12vw,45px); }
  body.mobile-board-size-6x6, .dual-task-shell.board-size-6x6 { --cell-size: clamp(32px,9.9vw,37px); }
  .progress-wrap { margin-top: 3px; }
  .calm-track { height: 8px; }

  .number-header,
  .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    margin-bottom: 2px; font-size: 12px; line-height: 1.1; text-align: left;
  }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    width: 100%; max-width: calc(100vw - 24px); padding: 2px 0 3px;
  }
  #numberPool.number-pool, #numberPool.number-pool-dual-task, #numberPoolColor { gap: 6px !important; padding: 4px 7px 6px !important; }
  #numberPool.number-pool > .number,
  #numberPool.number-pool-dual-task > .number-dual-task,
  #numberPoolColor > .color-token {
    flex: 0 0 40px !important; width: 40px !important; height: 40px !important; font-size: 18px !important;
  }
  .number-pool-wrapper::after, .number-pool-wrapper-dual-task::after { margin-top: 0; font-size: 9px; }

  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child { width: min(100%,290px); }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag { width: 100%; height: 36px; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    min-width: 0; height: 36px; min-height: 36px; flex: 1 1 50%; padding: 0 8px; font-size: 11px;
  }
}

@media (max-width: 380px), (max-width: 620px) and (max-height: 720px) {
  body.mobile-board-size-4x4, .dual-task-shell.board-size-4x4 { --cell-size: min(13.5vw,7.4dvh); }
  body.mobile-board-size-5x5, .dual-task-shell.board-size-5x5 { --cell-size: min(11.2vw,6.2dvh); }
  body.mobile-board-size-6x6, .dual-task-shell.board-size-6x6 { --cell-size: min(9.3vw,5.3dvh); }
  #ad-site .brand-name { display: none; }
}

/* Numbers approved phone layout — final cascade lock. */
@media (max-width: 620px) {
  .game-container:not(:has(.score-details-board)) {
    width: 100%;
    grid-template-columns: 1.1fr 1.1fr repeat(3, 1fr);
    column-gap: 0;
  }

  .game-container .mini-tile,
  .game-container .mini-reset,
  .game-container .mini-reset-debag,
  .game-container .debug-btn {
    width: 100%;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    border-radius: 0 !important;
  }
  .game-container .mini-tile { font-size: 18px; font-weight: 700; }
  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }
  .game-container .mini-action > .mini-reset { border-radius: 0 10px 10px 0 !important; }

  .game-container .progress-wrap {
    width: 100%;
    margin: 6px auto 0;
  }
  .game-container .calm-track {
    width: 98%;
    height: 13px;
    margin: 5px auto 2px;
    border-radius: 999px;
  }
  .game-container #progressLabel { font-size: 10px; font-weight: 700; }

  .game-container > .numbers-wrapper-dt > .number-pool-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 5px 0 7px;
    overflow: visible;
    border-radius: 18px;
    background: rgba(238,249,252,.42);
    box-shadow: inset 0 1px rgba(255,255,255,.75);
  }
  .game-container .number-header {
    margin: 0 38px 5px;
    font-size: 18px;
    line-height: 1.15;
    text-align: center;
  }
  .number-pool-mobile-shell {
    display: grid;
    width: 100%;
    grid-template-columns: 32px minmax(0,1fr) 32px;
    align-items: center;
    gap: 5px;
    overflow: visible;
  }
  .number-pool-arrow {
    position: static;
    z-index: 3;
    display: inline-flex;
    width: 30px;
    height: 30px;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,.78);
    border-radius: 50%;
    background: rgba(245,251,252,.78);
    color: #176979;
    font: 500 0/1 -apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
    box-shadow: 0 3px 12px rgba(42,76,89,.15), inset 0 1px rgba(255,255,255,.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transform: none;
  }
  .number-pool-arrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
  }
  .number-pool-arrow--left::before { transform: translateX(1px) rotate(-135deg); }
  .number-pool-arrow--right::before { transform: translateX(-1px) rotate(45deg); }
  .number-pool-arrow:active { transform: scale(.95); }

  #numberPool.number-pool {
    width: 100% !important;
    min-width: 0;
    gap: 5px !important;
    padding: 5px 4px 8px !important;
    border-radius: 16px;
  }
  #numberPool.number-pool > .number {
    flex: 0 0 34px !important;
    width: 34px !important;
    height: 42px !important;
    font-size: 16px !important;
  }
  .game-container .number-pool-wrapper::after { display: none; }

  .game-container > .numbers-wrapper-dt > .info-board:last-child {
    width: 100%;
    margin: 0;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%;
    height: 48px;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    height: 48px;
    min-height: 48px;
    padding-inline: 12px;
    font-size: 15px;
    font-weight: 650;
  }
}

/* Approved Colors phone layout. Keep this block last. */
@media (max-width: 620px) {
  .game-container-colors:not(:has(.score-details-board)) {
    display: grid !important;
    width: 100%;
    grid-template-columns: 1.1fr 1.1fr repeat(3, 1fr) !important;
    column-gap: 0 !important;
    row-gap: 7px !important;
    justify-content: stretch !important;
  }

  .game-container-colors > .patterns-card {
    grid-column: 1 / -1;
    order: 0;
    width: 100%;
    padding: 4px 6px;
    border-radius: 10px;
  }

  .game-container-colors .patterns-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }

  .game-container-colors .patterns-title {
    margin: 0;
    font-size: 11px;
    line-height: 1.05;
    white-space: nowrap;
  }

  .game-container-colors .patterns-list {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 4px;
    overflow: hidden;
  }

  .game-container-colors .pattern-item { flex: 0 1 auto; gap: 2px; }
  .game-container-colors .pattern-grid {
    grid-template-columns: repeat(2, 12px);
    grid-template-rows: repeat(2, 12px);
  }
  .game-container-colors .pattern-cell { width: 12px; height: 12px; border-radius: 3px; }
  .game-container-colors .pattern-score { min-width: 22px; height: 20px; padding-inline: 3px; font-size: 10px; }

  .game-container-colors .colors-main-row,
  .game-container-colors .colors-main-row > .numbers-wrapper-dt,
  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child),
  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child) > .mini-action,
  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:has(#pauseBtn) > .mini-tile-debag {
    display: contents !important;
  }

  .game-container-colors .mini-tile,
  .game-container-colors .mini-reset,
  .game-container-colors .mini-reset-debag,
  .game-container-colors .debug-btn {
    width: 100%;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 0 !important;
  }

  .game-container-colors .mini-tile { font-size: 18px; font-weight: 700; }
  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }
  .game-container-colors .mini-action > .mini-reset { border-radius: 0 10px 10px 0 !important; }

  .game-container-colors .colors-main-row > .board-wrapper {
    grid-column: 1 / -1;
    order: 10;
  }

  .game-container-colors .progress-wrap { width: 100%; margin: 6px auto 0; }
  .game-container-colors .calm-track {
    width: 98%;
    height: 13px;
    margin: 5px auto 2px;
    border-radius: 999px;
  }
  .game-container-colors #progressLabel { font-size: 10px; font-weight: 700; }

  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper {
    grid-column: 1 / -1;
    order: 20;
    width: calc(100vw - 30px) !important;
    max-width: calc(100vw - 30px) !important;
    justify-self: center;
    padding: 5px 0 7px;
    overflow: visible;
    border-radius: 18px;
    background: rgba(238,249,252,.42);
  }

  .game-container-colors .number-header {
    margin: 0 38px 5px;
    font-size: 18px;
    line-height: 1.15;
    text-align: center;
  }

  .game-container-colors .number-pool-mobile-shell {
    display: grid !important;
    width: 100% !important;
    max-width: none !important;
    grid-template-columns: 32px minmax(0, 1fr) 32px !important;
    align-items: center;
    gap: 5px;
    overflow: visible;
  }

  .game-container-colors #numberPoolColor {
    display: flex !important;
    width: 100% !important;
    min-width: 0;
    max-width: none !important;
    grid-template-columns: none !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    padding: 5px 4px 8px !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-radius: 16px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .game-container-colors #numberPoolColor::-webkit-scrollbar { display: none; }

  .game-container-colors #numberPoolColor > .color-token {
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 42px !important;
    margin: 0 !important;
    scroll-snap-align: start;
  }

  .game-container-colors .number-pool-wrapper::after { display: none; }

  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:last-child {
    grid-column: 1 / -1;
    order: 30;
    width: 100%;
    margin: 0;
  }

  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%;
    height: 58px;
    min-height: 58px;
  }

  .game-container-colors .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 58px;
    min-height: 58px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    text-align: center;
  }
}

/* Numbers phone refinement. Desktop layout remains unchanged. */
.number-pool-mobile-shell { display: contents; }
.number-pool-arrow { display: none; }

@media (max-width: 620px) {
  .game-container:not(:has(.score-details-board)) {
    grid-template-columns: 54px 54px 48px 48px 48px;
    column-gap: 0;
  }

  .game-container .mini-tile {
    width: 54px;
    min-width: 54px;
    border-radius: 0 !important;
    font-size: 18px;
    font-weight: 700;
  }

  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }

  .game-container .mini-reset,
  .game-container .mini-reset-debag,
  .game-container .debug-btn {
    width: 48px;
    min-width: 48px;
    border-radius: 0 !important;
  }

  .game-container .mini-action > .mini-reset {
    border-radius: 0 10px 10px 0 !important;
  }

  .debug-header .board-meta-mode:first-child {
    font-size: 14px;
    font-weight: 700;
  }

  .game-container .progress-wrap {
    width: calc(100% - 8px);
    margin: 7px auto 1px;
  }

  .game-container .calm-track {
    height: 13px;
    border-radius: 999px;
  }

  .game-container #progressLabel {
    font-size: 10px;
    font-weight: 700;
  }

  .game-container > .numbers-wrapper-dt > .number-pool-wrapper {
    width: 100%;
    max-width: calc(100vw - 20px);
    padding: 5px 0 7px;
    border-radius: 18px;
    background: rgba(238, 249, 252, .42);
    box-shadow: inset 0 1px rgba(255,255,255,.75);
  }

  .game-container .number-header {
    margin: 0 40px 5px;
    font-size: 18px;
    line-height: 1.15;
    text-align: center;
  }

  .number-pool-mobile-shell {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 3px;
    width: 100%;
  }

  .number-pool-arrow {
    display: inline-flex;
    width: 34px;
    height: 50px;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    padding: 0 0 4px;
    border: 1px solid rgba(6, 105, 121, .55);
    border-radius: 17px;
    background: rgba(221, 246, 247, .76);
    color: #176979;
    font: 700 32px/1 Arial, sans-serif;
    box-shadow: inset 0 1px rgba(255,255,255,.8), 0 3px 9px rgba(56,91,102,.08);
    touch-action: manipulation;
  }

  .number-pool-arrow:active { transform: scale(.96); }

  #numberPool.number-pool {
    min-width: 0;
    border-radius: 14px;
    padding: 5px 4px 8px !important;
  }

  .game-container .number-pool-wrapper::after { display: none; }

  .game-container > .numbers-wrapper-dt > .info-board:last-child {
    width: min(100%, 330px);
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    height: 42px;
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    height: 42px;
    min-height: 42px;
    font-size: 14px;
    font-weight: 600;
  }
}

/* Screenshot fix: flatten control groups by identity, not DOM position. */
@media (max-width: 620px) {
  .game-container:not(:has(.score-details-board)),
  .game-container-colors:not(:has(.score-details-board)) {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 44px)) !important;
    grid-auto-flow: row;
    align-items: center;
    justify-content: center;
    gap: 6px 5px !important;
  }

  .game-container > .numbers-wrapper-dt,
  .colors-main-row,
  .colors-main-row > .numbers-wrapper-dt {
    display: contents !important;
  }

  .game-container .info-board:has(#progressLabelCopy),
  .game-container-colors .info-board:has(#progressLabelCopy),
  .game-container .info-board:has(#pauseBtn),
  .game-container-colors .info-board:has(#pauseBtn),
  .game-container .info-board:has(#progressLabelCopy) > .mini-action,
  .game-container-colors .info-board:has(#progressLabelCopy) > .mini-action,
  .game-container .info-board:has(#pauseBtn) > .mini-tile-debag,
  .game-container-colors .info-board:has(#pauseBtn) > .mini-tile-debag {
    display: contents !important;
  }

  .game-container .info-board:has(#progressLabelCopy) > .mini-tile:first-child,
  .game-container-colors .info-board:has(#progressLabelCopy) > .mini-tile:first-child {
    order: 1 !important;
  }
  .game-container .info-board:has(#progressLabelCopy) > .mini-tile:nth-child(2),
  .game-container-colors .info-board:has(#progressLabelCopy) > .mini-tile:nth-child(2) {
    order: 2 !important;
  }
  .game-container #pauseBtn,
  .game-container-colors #pauseBtn { order: 3 !important; }
  .game-container #undoBtn,
  .game-container-colors #undoBtn { order: 4 !important; }
  .game-container .info-board:has(#progressLabelCopy) .mini-reset,
  .game-container-colors .info-board:has(#progressLabelCopy) .mini-reset { order: 5 !important; }

  .game-container > .board-wrapper,
  .colors-main-row > .board-wrapper {
    grid-column: 1 / -1 !important;
    order: 10 !important;
  }

  .game-container .number-pool-wrapper,
  .game-container-colors .number-pool-wrapper {
    grid-column: 1 / -1 !important;
    order: 20 !important;
    width: 100% !important;
  }

  .game-container .info-board:has(#openPanelBtn),
  .game-container-colors .info-board:has(#openPanelBtn) {
    grid-column: 1 / -1 !important;
    order: 30 !important;
    display: block !important;
    width: min(100%, 290px) !important;
    margin-inline: auto;
  }

  .game-container .info-board:has(#openPanelBtn) > .mini-tile-debag,
  .game-container-colors .info-board:has(#openPanelBtn) > .mini-tile-debag {
    display: flex !important;
    width: 100% !important;
    height: 36px !important;
  }

  .game-container .info-board:has(#openPanelBtn) .ui-btn,
  .game-container-colors .info-board:has(#openPanelBtn) .ui-btn {
    display: block;
    flex: 1 1 50% !important;
    width: auto !important;
    min-width: 0 !important;
    height: 36px !important;
  }
}

/* Approved compact phone composition.
   This final layer intentionally overrides earlier experimental mobile passes. */
@media (max-width: 620px) {
  :root {
    --site-menus-height: 54px;
    --top-header-height: 54px;
  }

  #ad-site .site-header {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 34px auto;
    grid-template-rows: 1fr;
    gap: 7px;
    width: 100%;
    height: 54px;
    min-height: 54px;
    padding: 4px 8px;
    border-radius: 0 0 13px 13px;
  }

  #ad-site .brand-tools {
    min-width: 0;
    gap: 6px;
  }

  #ad-site .brand {
    width: 42px;
    height: 42px;
  }

  #ad-site .brand-icon {
    width: 36px;
    height: 36px;
  }

  #ad-site .brand-beta {
    top: -1px;
    left: -1px;
    font-size: 9px;
  }

  #ad-site .brand-name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
  }

  #ad-site .icon-board-cell.blocked::after {
    width: 11px;
    height: 11px;
  }

  #ad-site .icon-board-cell.num,
  #ad-site .icon-board-coef {
    font-size: 14px;
  }

  #ad-site .mobile-menu-toggle {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .18);
    color: #29343d;
    box-shadow: inset 0 1px rgba(255, 255, 255, .55);
  }

  #ad-site .mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  #ad-site .lang-dropdown {
    margin: 0;
  }

  #ad-site .lang-toggle {
    min-height: 34px;
    padding: 3px 9px;
    gap: 5px;
    font-size: 12px;
  }

  #ad-site .site-header > .menu-links {
    position: absolute;
    top: calc(100% + 5px);
    right: 8px;
    z-index: 1200;
    display: none;
    width: min(250px, calc(100vw - 16px));
    max-height: calc(100dvh - 70px);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 15px;
    background: rgba(247, 251, 253, .96);
    box-shadow: 0 18px 38px rgba(77, 101, 112, .16);
    backdrop-filter: blur(22px) saturate(120%);
  }

  #ad-site.mobile-nav-open .site-header > .menu-links {
    display: flex;
  }

  #ad-site .site-header > .menu-links a,
  #ad-site .site-header > .menu-links button {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: left;
    font-size: 14px;
  }

  #ad-site .site-header > .menu-links a:hover,
  #ad-site .site-header > .menu-links button:hover {
    background: rgba(214, 232, 238, .45);
  }

  #ad-site .menu-links .divider {
    display: none;
  }

  .apple-card.card-top {
    top: 54px;
    width: calc(100vw - 10px);
    padding: 3px 4px;
    border-radius: 0 0 11px 11px;
  }

  #content:has(.dual-task-shell) {
    gap: 4px;
    padding: 4px 5px 18px;
  }

  .debug-header,
  .board-meta {
    gap: 3px;
  }

  .header-title {
    display: none;
  }

  .board-meta-tile,
  .board-meta-mode,
  .debug-header .debug-timer {
    height: 31px;
    min-height: 31px;
    padding-inline: 5px;
    border-radius: 8px;
    font-size: 11px;
  }

  .board-meta-state {
    width: 32px;
    flex: 0 0 32px;
  }

  .board-meta-state svg {
    width: 18px;
    height: 18px;
  }

  .debug-header .debug-timer {
    min-width: 82px;
  }

  .dual-task-shell {
    padding: 3px;
    gap: 7px;
  }

  .game-container,
  .game-container-colors,
  .dual-task-left-panel {
    gap: 6px;
    padding: 7px;
    border-radius: 15px;
  }

  .patterns-card {
    width: 100%;
    padding: 4px 6px;
    border-radius: 10px;
  }

  .patterns-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }

  .patterns-title {
    margin: 0;
    font-size: 11px;
    line-height: 1.05;
  }

  .patterns-list {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    overflow: hidden;
  }

  .pattern-item {
    flex: 0 1 auto;
    gap: 2px;
  }

  .pattern-grid {
    grid-template-columns: repeat(2, 12px);
    grid-template-rows: repeat(2, 12px);
  }

  .pattern-cell {
    width: 12px;
    height: 12px;
    border-radius: 3px;
  }

  .pattern-score {
    min-width: 22px;
    height: 20px;
    padding-inline: 3px;
    font-size: 10px;
  }

  /* Exactly one control row: percent, score, pause, undo, full reset. */
  .game-container:not(:has(.score-details-board)),
  .game-container-colors:not(:has(.score-details-board)) {
    grid-template-columns: repeat(5, minmax(0, 44px));
    justify-content: center;
    column-gap: 5px;
  }

  .game-container .mini-tile,
  .game-container-colors .mini-tile,
  .game-container .mini-reset,
  .game-container-colors .mini-reset,
  .game-container .mini-reset-debag,
  .game-container-colors .mini-reset-debag,
  .game-container .debug-btn,
  .game-container-colors .debug-btn {
    width: 44px;
    min-width: 44px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px !important;
    font-size: 13px;
  }

  .game-container .mini-reset svg,
  .game-container-colors .mini-reset svg,
  .game-container .mini-reset-debag svg,
  .game-container-colors .mini-reset-debag svg,
  .game-container .debug-btn svg,
  .game-container-colors .debug-btn svg {
    width: 20px;
    height: 20px;
  }

  .board-wrapper,
  .game-container-colors .board-wrapper {
    padding: 5px;
    border-radius: 14px;
  }

  body.mobile-board-size-4x4,
  .dual-task-shell.board-size-4x4 { --cell-size: clamp(48px, 15vw, 56px); }
  body.mobile-board-size-5x5,
  .dual-task-shell.board-size-5x5 { --cell-size: clamp(39px, 12vw, 45px); }
  body.mobile-board-size-6x6,
  .dual-task-shell.board-size-6x6 { --cell-size: clamp(32px, 9.9vw, 37px); }

  .progress-wrap {
    margin-top: 3px;
  }

  .calm-track {
    height: 8px;
  }

  .number-header,
  .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    margin-bottom: 2px;
    font-size: 12px;
    line-height: 1.1;
    text-align: left;
  }

  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    width: 100%;
    max-width: calc(100vw - 24px);
    padding: 2px 0 3px;
  }

  #numberPool.number-pool,
  #numberPool.number-pool-dual-task,
  #numberPoolColor {
    gap: 6px !important;
    padding: 4px 7px 6px !important;
  }

  #numberPool.number-pool > .number,
  #numberPool.number-pool-dual-task > .number-dual-task,
  #numberPoolColor > .color-token {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
  }

  .number-pool-wrapper::after,
  .number-pool-wrapper-dual-task::after {
    margin-top: 0;
    font-size: 9px;
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child {
    width: min(100%, 290px);
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%;
    height: 36px;
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    min-width: 0;
    height: 36px;
    min-height: 36px;
    flex: 1 1 50%;
    padding: 0 8px;
    font-size: 11px;
  }

  .dual-task-right-panel,
  .game-description,
  #footer {
    margin-top: 10px;
  }
}

@media (max-width: 380px), (max-width: 620px) and (max-height: 720px) {
  body.mobile-board-size-4x4,
  .dual-task-shell.board-size-4x4 { --cell-size: min(13.5vw, 7.4dvh); }
  body.mobile-board-size-5x5,
  .dual-task-shell.board-size-5x5 { --cell-size: min(11.2vw, 6.2dvh); }
  body.mobile-board-size-6x6,
  .dual-task-shell.board-size-6x6 { --cell-size: min(9.3vw, 5.3dvh); }

  #ad-site .brand-name {
    display: none;
  }
}

/* Numbers phone refinement cascade lock. */
@media (max-width: 620px) {
  .game-container:not(:has(.score-details-board)) {
    width: 100%;
    grid-template-columns: 1.1fr 1.1fr repeat(3, 1fr);
    column-gap: 0;
  }
  .game-container .mini-tile {
    width: 100%; min-width: 0; height: 42px; min-height: 42px; border-radius: 0 !important;
    font-size: 18px; font-weight: 700;
  }
  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }
  .game-container .mini-reset,
  .game-container .mini-reset-debag,
  .game-container .debug-btn {
    width: 100%; min-width: 0; height: 42px; min-height: 42px; border-radius: 0 !important;
  }
  .game-container .mini-action > .mini-reset { border-radius: 0 10px 10px 0 !important; }
  .debug-header .board-meta-mode:first-child { font-size: 14px; font-weight: 700; }
  .game-container .progress-wrap { width: calc(100% - 8px); margin: 7px auto 1px; }
  .game-container .calm-track { height: 13px; border-radius: 999px; }
  .game-container #progressLabel { font-size: 10px; font-weight: 700; }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper {
    width: 100%; max-width: 100%; padding: 5px 0 7px;
    border-radius: 18px; background: rgba(238,249,252,.42);
    box-shadow: inset 0 1px rgba(255,255,255,.75);
    overflow: visible;
  }
  .game-container .number-header {
    margin: 0 40px 5px; font-size: 18px; line-height: 1.15; text-align: center;
  }
  .number-pool-mobile-shell {
    display: grid; grid-template-columns: 34px minmax(0,1fr) 34px;
    align-items: center; gap: 3px; width: 100%;
  }
  .number-pool-arrow {
    display: inline-flex; width: 34px; height: 50px; min-height: 50px;
    align-items: center; justify-content: center; padding: 0 0 4px;
    border: 1px solid rgba(6,105,121,.55); border-radius: 17px;
    background: rgba(221,246,247,.76); color: #176979;
    font: 700 32px/1 Arial,sans-serif;
    box-shadow: inset 0 1px rgba(255,255,255,.8),0 3px 9px rgba(56,91,102,.08);
    touch-action: manipulation;
  }
  #numberPool.number-pool { min-width: 0; border-radius: 14px; padding: 5px 4px 8px !important; }
  .game-container .number-pool-wrapper::after { display: none; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child {
    width: 100%;
    margin: 0;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%;
    height: 48px;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    height: 48px; min-height: 48px; padding-inline: 12px; font-size: 15px; font-weight: 650;
  }
}

/* Compact phone viewport: header + controls + board + pool stay on the first screen. */
@media (max-width: 620px) {
  :root {
    --site-menus-height: 72px;
    --top-header-height: 72px;
  }

  #ad-site .site-header {
    grid-template-rows: 43px 25px;
    min-height: 72px;
    height: 72px;
    padding: 1px 7px 3px;
    border-radius: 0 0 13px 13px;
  }

  #ad-site .brand-tools { gap: 5px; }
  #ad-site .brand { width: 42px; height: 42px; }
  #ad-site .brand-icon { width: 36px; height: 36px; }
  #ad-site .brand-beta { font-size: 9px; }
  #ad-site .brand-name { font-size: 14px; }
  #ad-site .icon-board-cell.blocked::after { width: 12px; height: 12px; }
  #ad-site .icon-board-cell.num,
  #ad-site .icon-board-coef { font-size: 15px; }

  #ad-site .lang-toggle {
    min-height: 32px;
    padding: 3px 8px;
    font-size: 13px;
  }

  #ad-site .site-header > .menu-links {
    gap: 14px;
    min-height: 25px;
    padding-bottom: 0;
  }

  #ad-site .site-header > .menu-links a,
  #ad-site .site-header > .menu-links button {
    min-height: 24px;
    padding: 3px 0;
    font-size: 12px;
  }

  .apple-card.card-top {
    top: 72px;
    width: calc(100vw - 10px);
    padding: 3px 4px;
    border-radius: 0 0 10px 10px;
  }

  .debug-header { gap: 3px; }
  .board-meta { gap: 3px; }

  .board-meta-tile,
  .board-meta-mode,
  .debug-header .debug-timer {
    height: 32px;
    min-height: 32px;
    border-radius: 7px;
    font-size: 12px;
  }

  .board-meta-tile { padding-inline: 4px; }
  .board-meta-state { width: 34px; flex-basis: 34px; }
  .board-meta-state svg { width: 19px; height: 19px; }
  .debug-header .debug-timer { min-width: 88px; padding-inline: 4px; }
  .board-meta-tile::before { font-size: 15px; }

  #content:has(.dual-task-shell) {
    gap: 4px;
    padding: 4px 5px 14px;
  }

  .dual-task-shell {
    min-height: 0;
    padding: 3px;
    gap: 7px;
  }

  .game-container,
  .game-container-colors,
  .dual-task-left-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    justify-items: center;
    gap: 5px 7px;
    min-height: 0;
    padding: 6px;
    border-radius: 13px;
  }

  .patterns-card,
  .game-container > .board-wrapper,
  .colors-main-row > .board-wrapper,
  .dual-task-play-area > .board-wrapper,
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task,
  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child {
    grid-column: 1 / -1;
  }

  .game-container > .numbers-wrapper-dt > .info-board:not(:last-child),
  .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child),
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:not(:last-child) {
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  .info-board { gap: 3px; }

  .mini-tile,
  .mini-tile-dual-task-main,
  .mini-tile-dual-task,
  .mini-tile-dual-task-number,
  .mini-tile-dual-task-icon,
  .mini-reset,
  .mini-reset-debag,
  .debug-btn,
  .ui-btn {
    min-height: 38px;
    height: 38px;
    border-radius: 7px;
    font-size: 15px;
  }

  .mini-tile { width: 51px; }
  .mini-reset { width: 38px; padding: 0; }
  .mini-reset svg,
  .mini-reset-debag svg,
  .debug-btn svg { width: 22px; height: 22px; }

  .mini-tile-debag {
    width: 104px;
    height: 38px;
    border-radius: 7px;
  }

  .mini-tile-debag > .mini-reset-debag,
  .mini-tile-debag > .debug-btn,
  .mini-tile-debag > .ui-btn {
    width: 52px;
    height: 38px;
    min-height: 38px;
    flex: 0 0 52px;
    padding: 0 4px;
    font-size: 11px;
  }

  body.is-series-mode .mini-tile-debag:has(> #openPanelBtn2),
  body.is-series-mode .mini-tile-debag > #openPanelBtn2 {
    width: min(100%, 208px);
    flex-basis: 208px;
  }

  .mini-tile-dual-task-main { width: 70px; }
  .mini-tile-dual-task-number { width: 43px; }
  .mini-tile-dual-task-icon,
  .dual-task-icon-numbers { width: 38px; height: 38px; }
  .mini-tile-dual-task { width: 62px; font-size: 14px; }
  .mini-tile-dual-task::before { font-size: 11px !important; }

  .score-details-board { justify-content: center; }

  .board-wrapper,
  .game-container-colors .board-wrapper {
    padding: 4px;
    border-radius: 13px;
  }

  body.mobile-board-size-4x4,
  .dual-task-shell.board-size-4x4 {
    --cell-size: clamp(44px, 14.5vw, 56px);
  }

  body.mobile-board-size-5x5,
  .dual-task-shell.board-size-5x5 {
    --cell-size: clamp(38px, 11.8vw, 47px);
  }

  body.mobile-board-size-6x6,
  .dual-task-shell.board-size-6x6 {
    --cell-size: clamp(32px, 9.7vw, 39px);
  }

  .progress-wrap { margin-top: 3px; }
  .calm-track { height: 8px; }
  #progressLabel { font-size: 9px; }

  .number-header,
  .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    margin-bottom: 2px;
    font-size: 13px;
    line-height: 1.1;
  }

  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    max-width: calc(100vw - 24px);
    padding: 2px 0 3px;
  }

  #numberPool.number-pool,
  #numberPool.number-pool-dual-task,
  #numberPoolColor {
    gap: 6px !important;
    padding: 4px 7px 6px !important;
  }

  #numberPool.number-pool > .number,
  #numberPool.number-pool-dual-task > .number-dual-task,
  #numberPoolColor > .color-token {
    flex-basis: 38px !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 18px !important;
  }

  .number-pool-wrapper::after,
  .number-pool-wrapper-dual-task::after {
    margin-top: 0;
    font-size: 9px;
  }

  .patterns-card {
    margin: 0 !important;
    padding: 3px 5px;
    border-radius: 10px;
  }

  .patterns-header { gap: 3px; }
  .patterns-title { font-size: 12px; }
  .patterns-list {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 9px;
    overflow-x: auto;
  }

  .pattern-item { flex: 0 0 auto; }
  .pattern-grid {
    grid-template-columns: repeat(2, 14px);
    grid-template-rows: repeat(2, 14px);
  }
  .pattern-cell { width: 14px; height: 14px; border-radius: 4px; }
  .pattern-score { min-width: 25px; height: 22px; font-size: 11px; }

  .dual-task-right-panel {
    padding: 7px;
    gap: 7px;
  }
}

@media (max-width: 620px) and (max-height: 720px) {
  body.mobile-board-size-4x4,
  .dual-task-shell.board-size-4x4 { --cell-size: min(13vw, 7.7dvh); }
  body.mobile-board-size-5x5,
  .dual-task-shell.board-size-5x5 { --cell-size: min(11vw, 6.5dvh); }
  body.mobile-board-size-6x6,
  .dual-task-shell.board-size-6x6 { --cell-size: min(9.2vw, 5.5dvh); }
}

@media (max-width: 390px) {
  #ad-site .brand-name { display: none; }
  .board-meta-level { max-width: 72px; }
}

/* Final phone pass. This file is linked after header/panel styles in templates. */
@media (max-width: 620px) {
  :root {
    --site-menus-height: 58px;
    --top-header-height: 58px;
  }

  #ad-site .site-header {
    grid-template-rows: 34px 21px;
    min-height: 58px;
    height: 58px;
    padding: 1px 6px 2px;
    border-radius: 0 0 10px 10px;
  }

  #ad-site .brand-tools { gap: 3px; }
  #ad-site .brand { width: 33px; height: 33px; }
  #ad-site .brand-icon { width: 29px; height: 29px; }
  #ad-site .brand-beta { top: -1px; left: -1px; font-size: 8px; }
  #ad-site .brand-name { font-size: 12px; }
  #ad-site .icon-board-cell,
  #ad-site .icon-board-coef { border-radius: 4px; }
  #ad-site .icon-board-cell.blocked::after { width: 9px; height: 9px; }
  #ad-site .icon-board-cell.num,
  #ad-site .icon-board-coef { font-size: 11px; }

  #ad-site .lang-toggle {
    min-height: 28px;
    padding: 2px 7px;
    gap: 4px;
    font-size: 11px;
  }
  #ad-site .lang-flag { font-size: 14px; }

  #ad-site .site-header > .menu-links {
    min-height: 21px;
    gap: 11px;
    padding: 0 2px;
  }
  #ad-site .site-header > .menu-links a,
  #ad-site .site-header > .menu-links button {
    min-height: 20px;
    padding: 2px 0;
    font-size: 11px;
  }
  #ad-site .menu-links .divider { height: 11px; }

  .apple-card.card-top {
    top: 58px;
    padding: 2px 3px;
  }

  .board-meta-tile,
  .board-meta-mode,
  .debug-header .debug-timer {
    height: 29px;
    min-height: 29px;
    font-size: 11px;
  }
  .board-meta-state { width: 31px; flex-basis: 31px; }
  .board-meta-state svg { width: 17px; height: 17px; }
  .debug-header .debug-timer { min-width: 80px; }

  /* Numbers and Colors: make all five controls direct grid items. */
  .game-container:not(:has(.score-details-board)),
  .game-container-colors:not(:has(.score-details-board)) {
    grid-template-columns: repeat(5, 44px);
    justify-content: center;
    gap: 4px;
  }

  .game-container > .numbers-wrapper-dt > .info-board:not(:last-child),
  .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child),
  .game-container > .numbers-wrapper-dt > .info-board:not(:last-child) > .mini-action,
  .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child) > .mini-action,
  .game-container > .numbers-wrapper-dt > .info-board:has(#pauseBtn) > .mini-tile-debag,
  .colors-main-row > .numbers-wrapper-dt > .info-board:has(#pauseBtn) > .mini-tile-debag {
    display: contents;
  }

  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:nth-child(1),
  .colors-main-row > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:nth-child(1) {
    order: 1;
  }
  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:nth-child(2),
  .colors-main-row > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:nth-child(2) {
    order: 2;
  }
  .game-container #pauseBtn,
  .game-container-colors #pauseBtn { order: 3; }
  .game-container #undoBtn,
  .game-container-colors #undoBtn { order: 4; }
  .game-container .mini-action > .mini-reset,
  .game-container-colors .mini-action > .mini-reset { order: 5; }

  .game-container > .board-wrapper,
  .colors-main-row > .board-wrapper {
    grid-column: 1 / -1;
    order: 10;
  }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper {
    grid-column: 1 / -1;
    order: 20;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child {
    grid-column: 1 / -1;
    order: 30;
  }

  .game-container .mini-tile,
  .game-container-colors .mini-tile,
  .game-container .mini-reset,
  .game-container-colors .mini-reset,
  .game-container .mini-reset-debag,
  .game-container-colors .mini-reset-debag,
  .game-container .debug-btn,
  .game-container-colors .debug-btn {
    width: 44px;
    min-width: 44px;
    height: 35px;
    min-height: 35px;
    padding: 0;
    border-radius: 7px !important;
    font-size: 13px;
  }

  /* Dual-task: action buttons also form one row; component scores stay compact. */
  .dual-task-left-panel:has(.score-details-board) {
    grid-template-columns: repeat(4, 44px);
    justify-content: center;
  }
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:first-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:first-child > .mini-action,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:has(#pauseBtn),
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:has(#pauseBtn) > .mini-tile-debag {
    display: contents;
  }
  .dual-task-play-area .mini-tile-dual-task-main { order: 1; width: 44px; }
  .dual-task-play-area #pauseBtn { order: 2; }
  .dual-task-play-area #undoBtn { order: 3; }
  .dual-task-play-area .mini-action > .mini-reset { order: 4; }
  .dual-task-play-area .score-details-board { order: 5; }
  .dual-task-play-area > .board-wrapper { grid-column: 1 / -1; order: 10; }
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    grid-column: 1 / -1;
    order: 20;
  }
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child {
    grid-column: 1 / -1;
    order: 30;
  }

  .number-header,
  .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    font-size: 12px;
    font-weight: 600;
  }

  #numberPool.number-pool,
  #numberPool.number-pool-dual-task,
  #numberPoolColor {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
}

@media (max-width: 750px) {
  :root {
    --site-menus-height: 112px;
    --top-header-height: 112px;
  }

  #ad-site .site-header {
    grid-template-rows: 68px 36px;
    min-height: 112px;
    padding: 2px 8px 6px;
    gap: 0 8px;
    border-radius: 0 0 18px 18px;
  }

  #ad-site .brand {
    width: 64px;
    height: 64px;
  }

  #ad-site .brand-icon {
    width: 54px;
    height: 54px;
  }

  #ad-site .brand-beta {
    top: 0;
    left: 0;
    font-size: 12px;
  }

  #ad-site .brand-name {
    font-size: 16px;
  }

  #ad-site .lang-toggle {
    min-height: 42px;
    padding: 6px 10px;
  }

  #ad-site .site-header > .menu-links {
    gap: 18px;
    padding: 0 4px 2px;
    scrollbar-width: none;
  }

  #ad-site .site-header > .menu-links::-webkit-scrollbar {
    display: none;
  }

  #ad-site .site-header > .menu-links a,
  #ad-site .site-header > .menu-links button {
    min-height: 34px;
    padding: 7px 0;
    font-size: 14px;
  }

  .apple-card.card-top {
    top: var(--site-menus-height);
    width: calc(100vw - 16px);
    min-height: 0;
    padding: 6px;
    border-radius: 0 0 14px 14px;
  }

  .debug-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    gap: 6px;
  }

  .debug-header .header-title {
    display: none;
  }

  .board-meta {
    min-width: 0;
    gap: 5px;
  }

  .board-meta-tile,
  .board-meta-mode {
    min-width: 0;
    height: 40px;
    padding: 0 7px;
    font-size: clamp(13px, 3.8vw, 17px);
  }

  .board-meta-mode {
    flex: 1 1 auto;
  }

  .board-meta-size,
  .board-meta-level {
    flex: 0 1 auto;
  }

  .board-meta-state {
    width: 42px;
    flex: 0 0 42px;
  }

  .board-meta-state svg {
    width: 24px;
    height: 24px;
  }

  .board-meta-tile::before {
    font-size: 20px;
  }

  .debug-header .debug-timer {
    flex: none;
    width: auto;
    min-width: 104px;
    height: 40px;
    padding-inline: 7px;
    font-size: 14px;
  }

  .dropdown-menu {
    max-width: calc(100vw - 16px);
  }

  .patterns-card {
    padding: 8px;
  }

  .patterns-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .pattern-item {
    justify-content: center;
    gap: 6px;
  }

  .pattern-grid {
    grid-template-columns: repeat(2, 20px);
    grid-template-rows: repeat(2, 20px);
  }

  .pattern-cell {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 620px) {
  :root {
    --cell-size: 48px;
    --font_size_px: 19px;
    --font_size_full: 24px;
    --font_size_number: 22px;
  }

  body.mobile-board-size-4x4 { --cell-size: clamp(52px, 16vw, 58px); }
  body.mobile-board-size-5x5 { --cell-size: clamp(44px, 13.5vw, 50px); }
  body.mobile-board-size-6x6 { --cell-size: clamp(36px, 11.2vw, 42px); }

  .dual-task-shell.board-size-4x4 { --cell-size: clamp(52px, 16vw, 58px); }
  .dual-task-shell.board-size-5x5 { --cell-size: clamp(44px, 13.5vw, 50px); }
  .dual-task-shell.board-size-6x6 { --cell-size: clamp(36px, 11.2vw, 42px); }

  .grid,
  #cellGrid {
    max-width: calc(100vw - 38px);
  }

  .number-pool,
  .game-container-colors #numberPoolColor,
  .number-pool-wrapper-dual-task #numberPool.number-pool-dual-task {
    width: min(100%, 261px) !important;
    max-width: 100% !important;
    grid-template-columns: repeat(5, minmax(38px, 43px)) !important;
    gap: 7px !important;
    padding: 4px !important;
  }

  .number,
  .number-dual-task,
  .game-container-colors .color-token {
    width: 43px !important;
    height: 43px !important;
    margin: 0 !important;
  }

  .game-results__panel,
  .game-results--session .game-results__panel {
    min-height: 100dvh;
    max-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .game-results__comparison-wrap,
  .game-results__attempt-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .game-results__comparison-table,
  .game-results__attempt-table {
    min-width: 520px;
  }

  .game-results__tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
}

@media (max-width: 380px) {
  #content { padding-inline: 5px; }
  .game-container,
  .game-container-colors,
  .dual-task-left-panel { padding-inline: 6px; }
  .board-wrapper,
  .game-container-colors .board-wrapper { padding: 5px; }
  body.mobile-board-size-6x6,
  .dual-task-shell.board-size-6x6 { --cell-size: 35px; }
  .debug-header .debug-timer { min-width: 94px; font-size: 12px; }
  .board-meta-tile { padding-inline: 5px; }
}


@media (hover: none) and (pointer: coarse) {
  .cell:hover,
  .coef:hover,
  .dual_task_cell:hover,
  .dual_task_coeff:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Mobile game order:
   controls -> board -> horizontally scrollable pool -> action buttons. */
@media (max-width: 900px) {
  .game-container > .numbers-wrapper-dt,
  .colors-main-row,
  .colors-main-row > .numbers-wrapper-dt,
  .dual-task-play-area,
  .dual-task-play-area > .numbers-wrapper-dt {
    display: contents;
  }

  .game-container > .numbers-wrapper-dt > .info-board:not(:last-child),
  .colors-main-row > .numbers-wrapper-dt > .info-board:not(:last-child),
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:not(:last-child) {
    order: 1;
    width: min(100%, 300px);
    margin-inline: auto;
  }

  .game-container > .board-wrapper,
  .colors-main-row > .board-wrapper,
  .dual-task-play-area > .board-wrapper {
    order: 2;
  }

  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    order: 3;
    width: 100%;
    max-width: calc(100vw - 36px);
    margin-inline: auto;
    padding: 10px 0 12px;
    overflow: hidden;
  }

  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child {
    order: 4;
    width: min(100%, 300px);
    margin-inline: auto;
  }

  #numberPool.number-pool,
  #numberPool.number-pool-dual-task,
  #numberPoolColor {
    display: flex !important;
    width: 100% !important;
    max-width: none !important;
    grid-template-columns: none !important;
    justify-content: flex-start !important;
    align-items: center;
    gap: 9px !important;
    padding: 7px 10px 12px !important;
    margin: 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 10px;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: thin;
  }

  #numberPool.number-pool > .number,
  #numberPool.number-pool-dual-task > .number-dual-task,
  #numberPoolColor > .color-token {
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
    scroll-snap-align: start;
  }

  .number-pool-wrapper::after,
  .number-pool-wrapper-dual-task::after {
    content: "←  ·  ·  ·  →";
    display: block;
    margin-top: 2px;
    color: rgba(43, 46, 46, .58);
    font-size: 12px;
    line-height: 1;
    text-align: center;
    pointer-events: none;
  }
}

/* FINAL PHONE CASCADE LOCK — must remain the last rules in this file. */
@media (max-width: 620px) {
  :root { --site-menus-height: 54px; --top-header-height: 54px; }
  #ad-site .site-header {
    position: relative; grid-template-columns: minmax(0,1fr) 34px auto; grid-template-rows: 1fr;
    gap: 7px; width: 100%; height: 54px; min-height: 54px; padding: 4px 8px; border-radius: 0 0 13px 13px;
  }
  #ad-site .brand-tools { min-width: 0; gap: 6px; }
  #ad-site .brand { width: 42px; height: 42px; }
  #ad-site .brand-icon { width: 36px; height: 36px; }
  #ad-site .brand-beta { top: -1px; left: -1px; font-size: 9px; }
  #ad-site .brand-name { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
  #ad-site .icon-board-cell.blocked::after { width: 11px; height: 11px; }
  #ad-site .icon-board-cell.num, #ad-site .icon-board-coef { font-size: 14px; }
  #ad-site .mobile-menu-toggle {
    display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center;
    flex-direction: column; gap: 4px; padding: 0; border: 0; border-radius: 9px;
    background: rgba(255,255,255,.18); color: #29343d; box-shadow: inset 0 1px rgba(255,255,255,.55);
  }
  #ad-site .mobile-menu-toggle span { width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  #ad-site .lang-dropdown { margin: 0; }
  #ad-site .lang-toggle { min-height: 34px; padding: 3px 9px; gap: 5px; font-size: 12px; }
  #ad-site .site-header > .menu-links {
    position: absolute; top: calc(100% + 5px); right: 8px; z-index: 1200; display: none;
    width: min(250px,calc(100vw - 16px)); min-height: 0; max-height: calc(100dvh - 70px);
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0; overflow-y: auto;
    padding: 8px; border: 1px solid rgba(255,255,255,.72); border-radius: 15px;
    background: rgba(247,251,253,.96); box-shadow: 0 18px 38px rgba(77,101,112,.16);
    backdrop-filter: blur(22px) saturate(120%);
  }
  #ad-site.mobile-nav-open .site-header > .menu-links { display: flex; }
  #ad-site .site-header > .menu-links a, #ad-site .site-header > .menu-links button {
    min-height: 42px; padding: 10px 12px; border-radius: 10px; text-align: left; font-size: 14px;
  }
  #ad-site .menu-links .divider { display: none; }
  .apple-card.card-top { top: 54px; width: calc(100vw - 10px); padding: 3px 4px; border-radius: 0 0 11px 11px; }
  #content:has(.dual-task-shell) { gap: 4px; padding: 4px 5px 18px; }
  .header-title { display: none; }
  .debug-header, .board-meta { gap: 3px; }
  .board-meta-tile, .board-meta-mode, .debug-header .debug-timer {
    height: 31px; min-height: 31px; padding-inline: 5px; border-radius: 8px; font-size: 11px;
  }
  .board-meta-state { width: 32px; flex: 0 0 32px; }
  .board-meta-state svg { width: 18px; height: 18px; }
  .debug-header .debug-timer { min-width: 82px; }
  .dual-task-shell { padding: 3px; gap: 7px; }
  .game-container, .game-container-colors, .dual-task-left-panel { gap: 6px; padding: 7px; border-radius: 15px; }
  .patterns-card { width: 100%; margin: 0 !important; padding: 4px 6px; border-radius: 10px; }
  .patterns-header { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 7px; }
  .patterns-title { margin: 0; font-size: 11px; line-height: 1.05; }
  .patterns-list { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 4px; width: 100%; overflow: hidden; }
  .pattern-item { flex: 0 1 auto; gap: 2px; }
  .pattern-grid { grid-template-columns: repeat(2,12px); grid-template-rows: repeat(2,12px); }
  .pattern-cell { width: 12px; height: 12px; border-radius: 3px; }
  .pattern-score { min-width: 22px; height: 20px; padding-inline: 3px; font-size: 10px; }
  .game-container:not(:has(.score-details-board)), .game-container-colors:not(:has(.score-details-board)) {
    grid-template-columns: repeat(5,minmax(0,44px)); justify-content: center; column-gap: 5px;
  }
  .game-container .mini-tile, .game-container-colors .mini-tile,
  .game-container .mini-reset, .game-container-colors .mini-reset,
  .game-container .mini-reset-debag, .game-container-colors .mini-reset-debag,
  .game-container .debug-btn, .game-container-colors .debug-btn {
    width: 44px; min-width: 44px; height: 36px; min-height: 36px; padding: 0; border-radius: 8px !important; font-size: 13px;
  }
  .game-container .mini-reset svg, .game-container-colors .mini-reset svg,
  .game-container .mini-reset-debag svg, .game-container-colors .mini-reset-debag svg,
  .game-container .debug-btn svg, .game-container-colors .debug-btn svg { width: 20px; height: 20px; }
  .board-wrapper, .game-container-colors .board-wrapper { padding: 5px; border-radius: 14px; }
  body.mobile-board-size-4x4, .dual-task-shell.board-size-4x4 { --cell-size: clamp(48px,15vw,56px); }
  body.mobile-board-size-5x5, .dual-task-shell.board-size-5x5 { --cell-size: clamp(39px,12vw,45px); }
  body.mobile-board-size-6x6, .dual-task-shell.board-size-6x6 { --cell-size: clamp(32px,9.9vw,37px); }
  .progress-wrap { margin-top: 3px; }
  .calm-track { height: 8px; }
  .number-header, .game-container-colors .number-pool-wrapper .number-header,
  .numbers-wrapper-dt > .number-pool-wrapper-dual-task .number-header {
    margin-bottom: 2px; font-size: 12px; line-height: 1.1; text-align: left;
  }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper,
  .colors-main-row > .numbers-wrapper-dt > .number-pool-wrapper,
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    width: 100%; max-width: calc(100vw - 24px); padding: 2px 0 3px;
  }
  #numberPool.number-pool, #numberPool.number-pool-dual-task, #numberPoolColor { gap: 6px !important; padding: 4px 7px 6px !important; }
  #numberPool.number-pool > .number, #numberPool.number-pool-dual-task > .number-dual-task,
  #numberPoolColor > .color-token { flex: 0 0 40px !important; width: 40px !important; height: 40px !important; font-size: 18px !important; }
  .number-pool-wrapper::after, .number-pool-wrapper-dual-task::after { margin-top: 0; font-size: 9px; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child { width: min(100%,290px); }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag { width: 100%; height: 36px; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .colors-main-row > .numbers-wrapper-dt > .info-board:last-child .ui-btn,
  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    min-width: 0; height: 36px; min-height: 36px; flex: 1 1 50%; padding: 0 8px; font-size: 11px;
  }

  /* Final Numbers-only overrides. */
  .game-container:not(:has(.score-details-board)) {
    grid-template-columns: 54px 54px 48px 48px 48px;
    column-gap: 0;
  }
  .game-container .mini-tile {
    width: 54px; min-width: 54px; border-radius: 0 !important;
    font-size: 18px; font-weight: 700;
  }
  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }
  .game-container .mini-reset,
  .game-container .mini-reset-debag,
  .game-container .debug-btn {
    width: 48px; min-width: 48px; border-radius: 0 !important;
  }
  .game-container .mini-action > .mini-reset { border-radius: 0 10px 10px 0 !important; }
  .debug-header .board-meta-mode:first-child { font-size: 14px; font-weight: 700; }
  .game-container .progress-wrap { width: calc(100% - 8px); margin: 7px auto 1px; }
  .game-container .calm-track { height: 13px; border-radius: 999px; }
  .game-container #progressLabel { font-size: 10px; font-weight: 700; }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper {
    width: 100%; max-width: calc(100vw - 20px); padding: 5px 0 7px;
    border-radius: 18px; background: rgba(238,249,252,.42);
    box-shadow: inset 0 1px rgba(255,255,255,.75);
  }
  .game-container .number-header {
    margin: 0 40px 5px; font-size: 18px; line-height: 1.15; text-align: center;
  }
  .number-pool-mobile-shell {
    position: relative; display: block; width: 100%; margin-inline: auto; overflow: visible;
  }
  .number-pool-arrow {
    position: absolute; top: -31px; z-index: 3; display: inline-flex;
    width: 30px; height: 30px; min-height: 30px;
    align-items: center; justify-content: center; padding: 0;
    border: 1px solid rgba(255,255,255,.78); border-radius: 50%;
    background: rgba(245,251,252,.78); color: #176979;
    font: 500 0/1 -apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
    box-shadow: 0 3px 12px rgba(42,76,89,.15), inset 0 1px rgba(255,255,255,.88);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    touch-action: manipulation;
    transform: none;
  }
  .number-pool-arrow::before {
    content: "";
    width: 7px; height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
  }
  .number-pool-arrow--left { left: 4px; }
  .number-pool-arrow--right { right: 4px; }
  .number-pool-arrow--left::before { transform: translateX(1px) rotate(-135deg); }
  .number-pool-arrow--right::before { transform: translateX(-1px) rotate(45deg); }
  .number-pool-arrow:active { transform: scale(.95); }
  #numberPool.number-pool {
    width: 100% !important; min-width: 0; border-radius: 16px;
    gap: 5px !important;
    padding: 5px 4px 8px !important;
  }
  #numberPool.number-pool > .number {
    flex: 0 0 34px !important;
    width: 34px !important;
    height: 42px !important;
    font-size: 16px !important;
  }
  .game-container .number-pool-wrapper::after { display: none; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child { width: min(100%,330px); }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag { height: 42px; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    height: 42px; min-height: 42px; font-size: 14px; font-weight: 600;
  }

  /* Results are a normal vertical mobile screen, not a desktop grid squeezed into a phone. */
  .game-results { padding: 0; }
  .game-results__panel,
  .game-results--session .game-results__panel {
    display: block;
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .game-results__header {
    position: relative;
    padding: 18px 16px 14px;
  }
  .game-results__header h2 { font-size: 22px; }
  .game-results__field-meta > span { min-width: 0; flex: 1 1 120px; }
  .game-results__body {
    overflow: visible;
    padding: 14px 16px 18px;
  }
  .game-results__verification { display: none !important; }
  .game-results__footer {
    position: static;
    display: flex;
    padding: 14px 16px 20px;
    background: #fff;
  }
  .game-results__footer p { line-height: 1.35; }
  .game-results__continue {
    position: static;
    width: 100%;
    max-width: none;
    margin: 0;
  }
  .game-results__cards,
  .game-results__cards--overview { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .game-results__card { min-height: 90px; padding: 12px; }
  .game-results__card strong { font-size: 23px; }
  .game-results__comparison-wrap,
  .game-results__attempt-table-wrap { overflow-x: hidden; }
  .game-results__comparison-table,
  .game-results__attempt-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }
  .game-results__comparison-table th,
  .game-results__comparison-table td,
  .game-results__attempt-table th,
  .game-results__attempt-table td {
    padding: 9px 6px;
    font-size: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .game-results__attempts-toggle { width: 100%; }
}
@media (max-width: 380px), (max-width: 620px) and (max-height: 720px) {
  body.mobile-board-size-4x4, .dual-task-shell.board-size-4x4 { --cell-size: min(13.5vw,7.4dvh); }
  body.mobile-board-size-5x5, .dual-task-shell.board-size-5x5 { --cell-size: min(11.2vw,6.2dvh); }
  body.mobile-board-size-6x6, .dual-task-shell.board-size-6x6 { --cell-size: min(9.3vw,5.3dvh); }
  #ad-site .brand-name { display: none; }
}

/* Approved Numbers layout. This block must stay last. */
@media (max-width: 620px) {
  .game-container:not(:has(.score-details-board)) {
    width: 100%; grid-template-columns: 1.1fr 1.1fr repeat(3,1fr) !important; column-gap: 0 !important;
  }
  .game-container .mini-tile,
  .game-container .mini-reset,
  .game-container .mini-reset-debag,
  .game-container .debug-btn {
    width: 100%; min-width: 0; height: 42px; min-height: 42px; border-radius: 0 !important;
  }
  .game-container .mini-tile { font-size: 18px; font-weight: 700; }
  .game-container > .numbers-wrapper-dt > .info-board:first-child > .mini-tile:first-child {
    border-radius: 10px 0 0 10px !important;
  }
  .game-container .mini-action > .mini-reset { border-radius: 0 10px 10px 0 !important; }
  .game-container .progress-wrap { width: 100%; margin: 6px auto 0; }
  .game-container .calm-track {
    width: 98%; height: 13px; margin: 5px auto 2px; border-radius: 999px;
  }
  .game-container #progressLabel { font-size: 10px; font-weight: 700; }
  .game-container > .numbers-wrapper-dt > .number-pool-wrapper {
    width: calc(100vw - 30px) !important;
    max-width: calc(100vw - 30px) !important;
    justify-self: center;
    padding: 5px 0 7px; overflow: visible;
    border-radius: 18px; background: rgba(238,249,252,.42);
  }
  .game-container .number-header {
    margin: 0 38px 5px; font-size: 18px; line-height: 1.15; text-align: center;
  }
  .number-pool-mobile-shell {
    display: grid !important; width: 100% !important; max-width: none !important;
    grid-template-columns: 32px minmax(0,1fr) 32px !important;
    align-items: center; gap: 5px; overflow: visible;
  }
  .number-pool-arrow {
    position: static; z-index: 3; display: inline-flex; width: 30px; height: 30px; min-height: 30px;
    align-items: center; justify-content: center; padding: 0;
    border: 1px solid rgba(255,255,255,.78); border-radius: 50%;
    background: rgba(245,251,252,.78); color: #176979;
    font: 500 0/1 -apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
    box-shadow: 0 3px 12px rgba(42,76,89,.15), inset 0 1px rgba(255,255,255,.88);
    transform: none;
  }
  .number-pool-arrow::before {
    content: ""; width: 7px; height: 7px;
    border-top: 2px solid currentColor; border-right: 2px solid currentColor;
  }
  .number-pool-arrow--left::before { transform: translateX(1px) rotate(-135deg); }
  .number-pool-arrow--right::before { transform: translateX(-1px) rotate(45deg); }
  .number-pool-arrow:active { transform: scale(.95); }
  #numberPool.number-pool {
    width: 100% !important; min-width: 0; gap: 5px !important;
    padding: 5px 4px 8px !important; border-radius: 16px;
  }
  #numberPool.number-pool > .number {
    flex: 0 0 34px !important; width: 34px !important; height: 42px !important; font-size: 16px !important;
  }
  .game-container .number-pool-wrapper::after { display: none; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child { width: 100%; margin: 0; }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%; height: 58px; min-height: 58px;
  }
  .game-container > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 58px; min-height: 58px; padding: 6px 10px;
    font-size: 14px; font-weight: 650; line-height: 1.15;
    white-space: normal; overflow-wrap: normal; word-break: normal;
    text-align: center;
  }
}

/* Mobile game information is a full-screen sheet. */
@media (max-width: 620px) {
  .dual-task-shell > .dual-task-right-panel#numbersGameInfo,
  .dual-task-shell > .dual-task-right-panel#colorsGameInfo,
  .dual-task-shell > .dual-task-right-panel#dualTaskGameInfo {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: none;
    min-height: 100dvh;
    padding: max(58px, calc(env(safe-area-inset-top) + 50px)) 12px max(18px, env(safe-area-inset-bottom));
    border-radius: 0;
    box-shadow: none;
    transform: translateX(105%);
  }

  #numbersGameInfo .mobile-info-close,
  #colorsGameInfo .mobile-info-close,
  #dualTaskGameInfo .mobile-info-close {
    top: max(10px, env(safe-area-inset-top));
  }
}

/* Final Dual-task phone layout. */
@media (max-width: 620px) {
  .dual-task-left-panel:has(.score-details-board) {
    grid-template-columns: 52px 68px 68px 44px 44px 44px;
    column-gap: 0;
    row-gap: 6px;
    justify-content: center;
  }

  .dual-task-left-panel:has(.score-details-board) > .patterns-panel {
    grid-column: 1 / -1;
    width: 100%;
    order: 0;
  }

  .dual-task-play-area .mini-tile-dual-task-main {
    order: 1;
    width: 52px;
    min-width: 52px;
    height: 38px;
    border-radius: 10px 0 0 10px;
    font-size: 18px;
    font-weight: 700;
  }

  .dual-task-play-area .score-details-board {
    display: flex;
    width: 68px !important;
    min-width: 68px;
    height: 38px;
    gap: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
  }

  .dual-task-play-area .score-details-board:nth-of-type(2) { order: 2; }
  .dual-task-play-area .score-details-board:nth-of-type(3) { order: 3; }

  .dual-task-play-area .score-details-board .mini-tile-dual-task-number {
    width: 16px;
    min-width: 16px;
    height: 38px;
    padding: 0;
    border-radius: 0;
    font-size: 9px;
  }

  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon {
    width: 18px;
    min-width: 18px;
    height: 38px;
    padding: 2px;
    border-radius: 0;
  }

  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon img {
    width: 15px;
    height: 15px;
  }

  .dual-task-play-area .score-details-board .mini-tile-dual-task {
    width: 34px;
    min-width: 34px;
    height: 38px;
    padding: 0 2px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 700;
  }

  .dual-task-play-area #pauseBtn,
  .dual-task-play-area #undoBtn,
  .dual-task-play-area .mini-action > .mini-reset {
    width: 44px;
    min-width: 44px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 0 !important;
  }

  .dual-task-play-area #pauseBtn { order: 4; }
  .dual-task-play-area #undoBtn { order: 5; }
  .dual-task-play-area .mini-action > .mini-reset {
    order: 6;
    border-radius: 0 10px 10px 0 !important;
  }

  .dual-task-play-area #pauseBtn svg,
  .dual-task-play-area #undoBtn svg,
  .dual-task-play-area .mini-action > .mini-reset svg {
    width: 20px;
    height: 20px;
  }

  .dual-task-play-area > .board-wrapper {
    grid-column: 1 / -1;
    width: fit-content;
    max-width: 100%;
    order: 10;
    padding: 5px;
    border-radius: 14px;
  }

  .dual-task-play-area .progress-wrap {
    width: calc(100% - 8px);
    margin: 7px auto 1px;
  }

  .dual-task-play-area .calm-track {
    height: 13px;
    border-radius: 999px;
  }

  .dual-task-play-area #progressLabel {
    font-size: 10px;
    font-weight: 700;
  }

  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    grid-column: 1 / -1;
    order: 20;
    width: 100%;
    max-width: calc(100vw - 20px);
    padding: 5px 0 7px;
    overflow: visible;
    border-radius: 18px;
    background: rgba(238,249,252,.42);
    box-shadow: inset 0 1px rgba(255,255,255,.75);
  }

  .dual-task-play-area .number-pool-wrapper-dual-task .number-header {
    margin: 0 38px 5px;
    font-size: 18px;
    line-height: 1.15;
    text-align: center;
  }

  .dual-task-play-area .number-pool-mobile-shell {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: 32px minmax(0, 1fr) 32px !important;
    align-items: center;
    gap: 5px;
    overflow: visible;
  }

  .dual-task-play-area .number-pool-arrow {
    position: static;
    display: inline-flex;
    width: 30px;
    height: 30px;
    min-height: 30px;
  }

  .dual-task-play-area #numberPool.number-pool-dual-task {
    width: 100% !important;
    min-width: 0;
    gap: 5px !important;
    padding: 5px 4px 8px !important;
    border-radius: 16px;
  }

  .dual-task-play-area #numberPool.number-pool-dual-task > .number-dual-task {
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 44px !important;
    font-size: 16px !important;
  }

  .dual-task-play-area .number-pool-wrapper-dual-task::after { display: none; }

  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child {
    grid-column: 1 / -1;
    order: 30;
    width: 100%;
    margin: 0;
  }

  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .mini-tile-debag {
    width: 100%;
    height: 58px;
    min-height: 58px;
  }

  .dual-task-play-area > .numbers-wrapper-dt > .info-board:last-child .ui-btn {
    display: inline-flex;
    min-width: 0;
    height: 58px;
    min-height: 58px;
    flex: 1 1 50%;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .dual-task-left-panel:has(.score-details-board) {
    grid-template-columns: 48px 63px 63px 42px 42px 42px;
  }
  .dual-task-play-area .mini-tile-dual-task-main { width: 48px; min-width: 48px; }
  .dual-task-play-area .score-details-board { width: 63px !important; min-width: 63px; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-number { width: 14px; min-width: 14px; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon { width: 17px; min-width: 17px; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task { width: 32px; min-width: 32px; }
  .dual-task-play-area #pauseBtn,
  .dual-task-play-area #undoBtn,
  .dual-task-play-area .mini-action > .mini-reset { width: 42px; min-width: 42px; }
}

/* Dual-task refinement: metrics and controls use two rows; the pool gets the
   widest safe phone width. */
@media (max-width: 620px) {
  .dual-task-left-panel:has(.score-details-board) {
    grid-template-columns: repeat(3, minmax(0, 104px));
    column-gap: 4px;
    row-gap: 5px;
  }
  .dual-task-play-area .mini-tile-dual-task-main {
    width: 100%; min-width: 0; height: 42px; border-radius: 10px;
  }
  .dual-task-play-area .score-details-board {
    width: 100% !important; min-width: 0; height: 42px; border-radius: 10px;
  }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-number,
  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon,
  .dual-task-play-area .score-details-board .mini-tile-dual-task { height: 42px; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-number { width: 20%; min-width: 20%; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon { width: 25%; min-width: 25%; }
  .dual-task-play-area .score-details-board .mini-tile-dual-task {
    width: 55%; min-width: 0; font-size: 13px;
  }
  .dual-task-play-area #pauseBtn,
  .dual-task-play-area #undoBtn,
  .dual-task-play-area .mini-action > .mini-reset {
    width: 100%; min-width: 0; height: 42px; min-height: 42px;
    border-radius: 10px !important;
  }
  .dual-task-play-area > .numbers-wrapper-dt > .number-pool-wrapper-dual-task {
    width: calc(100% + 12px); max-width: calc(100vw - 12px); margin-inline: -6px;
  }
  .dual-task-play-area .number-pool-mobile-shell {
    grid-template-columns: 28px minmax(0, 1fr) 28px !important; gap: 2px;
  }
  .dual-task-play-area .number-pool-arrow {
    width: 28px; height: 34px; min-height: 34px;
  }
  .dual-task-play-area #numberPool.number-pool-dual-task {
    gap: 6px !important; padding-inline: 6px !important;
  }
  .dual-task-play-area #numberPool.number-pool-dual-task > .number-dual-task {
    flex-basis: 40px !important; width: 40px !important;
  }
}

@media (max-width: 380px) {
  .dual-task-left-panel:has(.score-details-board) {
    grid-template-columns: repeat(3, minmax(0, 98px));
  }
}

/* Dual-task compact patterns and icon-only component metrics. */
@media (max-width: 620px) {
  .dual-task-left-panel:has(.score-details-board) .patterns-card {
    padding: 5px 6px 6px;
  }
  .dual-task-left-panel:has(.score-details-board) .patterns-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
  }
  .dual-task-left-panel:has(.score-details-board) .patterns-title {
    width: 100%;
    font-size: 11px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
  }
  .dual-task-left-panel:has(.score-details-board) .patterns-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 2px;
    overflow: visible;
  }
  .dual-task-left-panel:has(.score-details-board) .pattern-item {
    min-width: 0;
    justify-content: center;
    gap: 2px;
  }
  .dual-task-left-panel:has(.score-details-board) .pattern-grid {
    grid-template-columns: repeat(2, 11px);
    grid-template-rows: repeat(2, 11px);
  }
  .dual-task-left-panel:has(.score-details-board) .pattern-cell {
    width: 11px;
    height: 11px;
    border-radius: 3px;
  }
  .dual-task-left-panel:has(.score-details-board) .pattern-score {
    min-width: 21px;
    height: 20px;
    padding-inline: 3px;
    font-size: 10px;
  }

  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon {
    width: 38%;
    min-width: 38%;
    padding: 4px;
  }
  .dual-task-play-area .score-details-board .mini-tile-dual-task-icon img {
    width: 22px;
    height: 22px;
  }
  .dual-task-play-area .score-details-board .mini-tile-dual-task {
    width: 62%;
    min-width: 0;
    font-size: 14px;
  }

  /* All three game info sheets fit their preview and button inside the phone
     viewport; the sheet remains scrollable for long localized text. */
  #numbersGameInfo,
  #colorsGameInfo,
  #dualTaskGameInfo {
    gap: 8px;
  }
  #numbersGameInfo .game-info-card,
  #colorsGameInfo .game-info-card,
  #dualTaskGameInfo .game-info-card {
    padding: 12px;
  }
  #numbersGameInfo .game-info-title,
  #colorsGameInfo .game-info-title,
  #dualTaskGameInfo .game-info-title {
    margin-bottom: 6px;
    font-size: 17px;
  }
  #numbersGameInfo .game-info-text,
  #colorsGameInfo .game-info-text,
  #dualTaskGameInfo .game-info-text {
    margin-block: 0 7px;
    font-size: 13px;
    line-height: 1.38;
  }
  #numbersGameInfo .video-demo-card,
  #colorsGameInfo .video-demo-card,
  #dualTaskGameInfo .video-demo-card {
    padding: 10px;
    gap: 7px;
  }
  #numbersGameInfo .video-demo,
  #colorsGameInfo .video-demo,
  #dualTaskGameInfo .video-demo {
    gap: 7px;
  }
  #numbersGameInfo .video-demo__stage,
  #colorsGameInfo .video-demo__stage,
  #dualTaskGameInfo .video-demo__stage {
    height: min(210px, 29dvh);
    min-height: 145px;
    aspect-ratio: auto;
  }
  #numbersGameInfo .video-demo__button,
  #colorsGameInfo .video-demo__button,
  #dualTaskGameInfo .video-demo__button {
    min-height: 44px;
  }
}

/* Compact Challenge illustrations: keep the visual identity without making
   the three mode choices overflow an iPhone mini. */
@media (max-width: 620px) {
  .card-top-challenge .game-card {
    min-height: 126px;
    padding-top: 7px;
  }

  .card-top-challenge .game-card .mode-icon {
    display: grid;
    width: 44px;
    height: 44px;
    margin: 0 0 4px;
    padding: 3px;
    border-radius: 10px;
  }

  .card-top-challenge .game-card .dual-triangle {
    position: relative;
    display: block;
    width: 52px;
    height: 44px;
    margin: 0 0 4px;
  }

  .card-top-challenge .dual-triangle .mini-board {
    width: 19px;
    height: 19px;
    padding: 1px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(69,87,100,.12), inset 0 1px rgba(255,255,255,.9);
  }

  .card-top-challenge .dual-triangle .mini-color { left: 2px; top: 1px; }
  .card-top-challenge .dual-triangle .mini-number { right: 2px; top: 1px; }
  .card-top-challenge .dual-triangle .mini-dual {
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
  }

  .card-top-challenge .dual-triangle .dual-links {
    width: 100%;
    height: 100%;
  }

  .card-top-challenge .game-card h3 {
    min-height: 27px;
  }
}

/* Dual-task step numbers belong to the desktop legend only. */
@media (max-width: 620px) {
  .dual-task-play-area .score-details-board .mini-tile-dual-task-number {
    display: none !important;
  }
}
