/* The hearing games share touch sizes and safe areas, with individual layouts
   for their illustrated play fields. */
@media (max-width: 900px), (max-height: 520px), (pointer: coarse) {
  .cl-play[data-world="hearing"] {
    --hear-hit: 44px;
    --hear-left: max(8px, env(safe-area-inset-left));
    --hear-right: max(8px, env(safe-area-inset-right));
    --hear-top: max(6px, env(safe-area-inset-top));
    --hear-bottom: max(6px, env(safe-area-inset-bottom));
    --hear-paper: #fff8e9f5;
    --hear-border: 1px solid #a791655c;
    --hear-shadow: 0 2px 9px #312a2238;
  }

  .cl-play[data-world="hearing"] .cl-viewport .cl-head :is(button, #cl-mute, #cl-exit, #cl-settings),
  .cl-play[data-world="hearing"] :is(#cl-exit, #cl-settings, #cl-hide),
  .cl-play[data-world="hearing"] #cl-stage :is(.fy-replay, .wm-read, .mb-replay, .br-head button, .br-buttons button),
  .cl-play[data-world="hearing"] #cl-drawer :is(.cl-options label, select, .cl-desk-tools button) {
    min-width: var(--hear-hit);
    min-height: var(--hear-hit);
  }

  .cl-play[data-world="hearing"] > #cl-drawer {
    width: min(300px, 87vw);
  }

  .cl-play[data-world="hearing"] .cl-viewport .cl-head > div > button { touch-action: manipulation; }

  .cl-play[data-world="hearing"]:is([data-world-game="16"], [data-world-game="24"], [data-world-game="167"]) .cl-viewport .cl-head > div {
    position: static;
  }

  .cl-play[data-world="hearing"] #cl-stage .fy-replay {
    flex: none;
  }

  .cl-play[data-world="hearing"] #cl-stage .mb-slot {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .cl-play[data-world-game="15"] #cl-stage .fy-field.ag-board {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    touch-action: pan-x;
    scrollbar-width: thin;
    scrollbar-color: #8d7451 #f8edce;
  }

  .cl-play[data-world-game="15"] #cl-stage .fy-paint {
    position: relative;
    inset: auto;
    transform: none;
    width: max(100%, 146cqh);
    height: 100%;
    aspect-ratio: auto;
  }

  .cl-play[data-world-game="15"] #cl-stage .fy-instruction {
    flex-wrap: wrap;
    column-gap: .3em;
    row-gap: 0;
    padding: 5px 8px max(7px, env(safe-area-inset-bottom));
  }

  .cl-play[data-world-game="15"] #cl-stage .fy-instruction::after {
    content: "Суретті оңға-солға сырғыт.";
    flex-basis: 100%;
    color: #435a3d;
    font: 600 13px/1.2 "Segoe UI", sans-serif;
  }

  .cl-play[data-world-game="24"] .cl-viewport .cl-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding-inline: var(--hear-left) var(--hear-right);
  }

  .cl-play[data-world-game="24"] .cl-viewport .cl-head h1 {
    text-align: center;
    font-size: clamp(16px, 4.7vw, 27px);
  }

  .cl-play[data-world-game="24"] .cl-viewport .cl-head #cl-exit {
    width: var(--hear-hit);
    padding-inline: 0;
  }

  .cl-play[data-world-game="24"] .cl-head #cl-exit span { display: none; }
  .cl-play[data-world-game="24"] .cl-head #cl-exit::before { content: "←"; font-size: 22px; }

  .cl-play[data-world-game="24"] .cl-viewport .cl-head > div {
    margin-inline-end: calc(var(--hear-hit) + 4px);
  }

  .cl-play[data-world="hearing"][data-world-game="24"] #cl-settings {
    position: absolute;
    top: calc(var(--school-head) / 2 - var(--hear-hit) / 2);
    right: var(--hear-right);
    bottom: auto;
    width: var(--hear-hit);
    height: var(--hear-hit);
    transform: none;
    border-radius: 12px;
  }

  .cl-play[data-world-game="167"] .cl-viewport .cl-head {
    inset: var(--hear-top) var(--hear-right) auto var(--hear-left);
    height: auto;
    min-height: 44px;
    padding: 0;
    gap: 5px;
  }

  .cl-play[data-world-game="167"] .cl-viewport .cl-head h1 {
    min-width: 0;
    font-size: clamp(17px, 5vw, 30px);
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-field::after {
    content: "";
    position: absolute;
    z-index: 0;
    inset: -20px;
    background: url("games/mountain-bears/art/family-asleep.png") center / cover no-repeat;
    filter: blur(24px);
    opacity: .37;
    pointer-events: none;
  }

  .cl-play[data-world-game="167"] #cl-stage :is(.mb-view, .mb-message) { z-index: 1; }

  .cl-play[data-world-game="167"] #cl-stage .mb-field .mb-view {
    top: 42%;
    height: min(94vw, 50dvh);
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-field .mb-cabinet {
    top: 94%;
    bottom: auto;
    left: 9%;
    right: 9%;
    padding: 5px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: clamp(44px, 14vw, 65px);
    gap: 3px;
    border: 2px solid #9b724a;
    border-radius: 14px;
    background: #554136;
    box-shadow: inset 0 1px 0 #b58b65, var(--hear-shadow);
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-cabinet .mb-bell-icon {
    width: min(84cqw, 69cqh);
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-foot {
    height: auto;
    min-height: 64px;
    padding-block: 6px var(--hear-bottom);
  }
}

@media (orientation: landscape) and (max-height: 520px),
       (orientation: landscape) and (pointer: coarse) {
  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"]) .cl-viewport #cl-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .cl-play[data-world="hearing"] #cl-stage :is(.fy-field, .school-field, .br-view) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"]) .cl-viewport .cl-head {
    position: absolute;
    inset: var(--hear-top) var(--hear-right) auto var(--hear-left);
    height: var(--hear-hit);
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    pointer-events: none;
  }

  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"], [data-world-game="14"], [data-world-game="167"]) .cl-viewport .cl-head h1,
  .cl-play[data-world="hearing"] #cl-stage :is(.fy-instruction, .mb-instruction, .br-heading, .br-notice, .br-top-count) {
    padding: .37em .65em;
    border: var(--hear-border);
    border-radius: 14px;
    background: var(--hear-paper);
    box-shadow: var(--hear-shadow);
    font-size: clamp(15px, 5.4dvh, 29px);
    line-height: 1.12;
  }

  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"], [data-world-game="167"]) .cl-viewport .cl-head :is(button, #cl-mute, #cl-exit),
  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"], [data-world-game="167"]) :is(#cl-exit, #cl-settings),
  .cl-play[data-world="hearing"] #cl-stage .br-head button {
    height: var(--hear-hit);
    padding: 0 7px;
    border: var(--hear-border);
    border-radius: 12px;
    background: var(--hear-paper);
    color: #244a39;
    box-shadow: var(--hear-shadow);
    pointer-events: auto;
  }

  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"], [data-world-game="167"]) .cl-viewport .cl-head > div {
    pointer-events: auto;
  }

  .cl-play[data-world="hearing"]:is([data-world-game="15"], [data-world-game="24"], [data-world-game="167"]) #cl-settings {
    position: absolute;
    top: var(--hear-top);
    right: var(--hear-right);
    bottom: auto;
    transform: none;
    opacity: 1;
    width: var(--hear-hit);
  }

  .cl-play[data-world-game="15"] .cl-viewport .cl-head > div { right: calc(var(--hear-hit) + 5px); }
  .cl-play[data-world="hearing"][data-world-game="15"] #cl-exit {
    top: var(--hear-top);
    left: var(--hear-left);
  }

  .cl-play[data-world-game="15"] #cl-stage .fy-paint {
    --fy-height: max(100dvh, min(66.667vw, 135dvh));
    width: 100%;
    height: var(--fy-height);
    top: calc((100dvh - var(--fy-height)) * .42);
    left: 0;
    transform: none;
    aspect-ratio: auto;
  }

  .cl-play[data-world-game="15"] #cl-stage .fy-instruction,
  .cl-play[data-world-game="24"] .cl-viewport #cl-stage .school-status {
    position: absolute;
    z-index: 2;
    inset: auto auto var(--hear-bottom) 50%;
    width: max-content;
    max-width: calc(100% - var(--hear-left) - var(--hear-right));
    translate: -50% 0;
    box-sizing: border-box;
  }

  .cl-play[data-world-game="24"] .cl-viewport .cl-head > div { margin-inline-end: calc(var(--hear-hit) + 6px); }

  .cl-play[data-world-game="24"] .cl-viewport #cl-stage .school-stand {
    top: calc(var(--hear-top) + var(--hear-hit) + 8px);
    bottom: calc(var(--hear-bottom) + 38px);
    height: auto;
  }

  .cl-play[data-world-game="24"] .cl-viewport #cl-stage .school-status {
    padding: .45em .95em;
    border: 1px solid #c8b079;
    border-radius: 14px;
    background: #244a37f3;
    font-size: clamp(15px,5.25dvh,26px);
  }

  .cl-play[data-world="hearing"]:is([data-world-game="14"], [data-world-game="16"], [data-world-game="167"]) .cl-viewport .cl-head {
    inset: var(--hear-top) var(--hear-right) auto var(--hear-left);
    padding: 0;
  }

  .cl-play[data-world-game="14"] .cl-viewport .cl-head h1 {
    position: absolute;
    left: 50%;
    translate: -50% 0;
    white-space: nowrap;
  }

  .cl-play[data-world-game="14"] .cl-viewport .cl-head > div { margin-inline-start: auto; }

  .cl-play[data-world="hearing"][data-world-game="16"] .cl-viewport .cl-head {
    right: calc(var(--hear-right) + var(--hear-hit) + 6px);
  }

  .cl-play[data-world-game="16"] .cl-viewport .cl-head h1 { font-size: clamp(18px, 6dvh, 34px); }

  .cl-play[data-world="hearing"][data-world-game="16"] #cl-settings {
    top: var(--hear-top);
    right: var(--hear-right);
    bottom: auto;
    width: var(--hear-hit);
    height: var(--hear-hit);
    transform: none;
    border-radius: 50%;
    background: #0d2141dd;
    color: #fff6dd;
  }

  .cl-play[data-world-game="16"] #cl-stage .orbit-status {
    bottom: var(--hear-bottom);
    font-size: clamp(15px, 5.1dvh, 27px);
  }

  .cl-play[data-world-game="167"] .cl-viewport .cl-head > div { margin-inline-end: calc(var(--hear-hit) + 6px); }
  .cl-play[data-world-game="167"] .cl-viewport .cl-head svg { width: 68%; height: 68%; }
  .cl-play[data-world-game="167"] #cl-stage .mb-view { --sky-space: 0px; }

  .cl-play[data-world-game="167"] #cl-stage .mb-shelf {
    top: var(--hear-top);
    bottom: auto;
    left: 50%;
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-foot {
    inset: auto var(--hear-right) var(--hear-bottom) var(--hear-left);
    width: auto;
    height: auto;
    min-height: 0;
    padding: 0;
    background: none;
    pointer-events: none;
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-replay { pointer-events: auto; }

  .cl-play[data-world-game="6"] #cl-stage .br-view { --br-full-landscape: 1; }
  .cl-play[data-world-game="6"] #cl-stage .br-view::before { content: none; }
  .cl-play[data-world-game="6"] #cl-stage .br-illustration { object-fit: fill; }

  .cl-play[data-world-game="6"] #cl-stage :is(.br-head, .br-foot) {
    position: absolute;
    inset-inline: var(--hear-left) var(--hear-right);
    min-height: 0;
    padding: 0;
    gap: 6px;
    background: transparent;
    pointer-events: none;
  }

  .cl-play[data-world-game="6"] #cl-stage .br-head { top: var(--hear-top); }
  .cl-play[data-world-game="6"] #cl-stage .br-foot { bottom: var(--hear-bottom); }
  .cl-play[data-world-game="6"] #cl-stage .br-heading { gap: 0 .6em; }
  .cl-play[data-world-game="6"] #cl-stage .br-heading h1 { font-size: clamp(15px,5.1dvh,25px); }
  .cl-play[data-world-game="6"] #cl-stage .br-head button span { display: none; }
  .cl-play[data-world-game="6"] #cl-stage .br-top-count { font-size: clamp(13px,4.5dvh,19px); }
  .cl-play[data-world-game="6"] #cl-stage .br-line { font-size: clamp(13px,4.4dvh,22px); }
  .cl-play[data-world-game="6"] #cl-stage .br-buttons button { pointer-events: auto; }
  .cl-play[data-world-game="6"] #cl-stage .br-curtain { padding-block: 44px; gap: 6px; }
  .cl-play[data-world-game="6"] #cl-stage .br-curtain > svg { width: 46px; height: 46px; padding: 8px; }
}

@media (orientation: landscape) and (max-width: 680px) {
  .cl-play[data-world-game="14"] .cl-viewport .cl-head h1 {
    left: var(--hear-left);
    translate: none;
  }

  .cl-play[data-world-game="167"] #cl-stage .mb-shelf {
    top: calc(var(--hear-top) + var(--hear-hit) + 4px);
  }
}
