/* Keep the complete table visible and put mobile controls beside the cue. */
#club-shell.game-shell .fine-controls button {
  min-width: 40px;
  min-height: 40px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}
#club-shell.game-shell .fine-controls button.is-adjusting {
  background: #244b56;
  border-color: #78f1d1;
  color: #fff;
}

@media (max-width: 900px), (pointer: coarse) and (max-width: 1500px), (orientation: landscape) and (max-height: 520px) {
  body[data-game="snooker"] #club-shell.game-shell {
    --snooker-dock-width: 104px;
    --snooker-dock-top: 116px;
    --snooker-dock-bottom: 58px;
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: var(--arcade-fs-vh, 100dvh) !important;
    min-height: 0 !important;
    max-height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #07131b !important;
    isolation: isolate;
  }
  body[data-game="snooker"] #club-shell.game-shell .workspace,
  body[data-game="snooker"] #club-shell.game-shell .table-area {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }
  body[data-game="snooker"] #club-shell.game-shell .table-interaction-row {
    position: absolute !important;
    inset: 4px !important;
    display: flex !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
  }
  body[data-game="snooker"] #club-shell.game-shell #table-viewport {
    flex: 0 0 auto !important;
    width: var(--snooker-fit-width, calc(100% - 108px)) !important;
    height: var(--snooker-fit-height, auto) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: calc(100% - 108px) !important;
    max-height: 100% !important;
    margin: 0 0 0 max(0px, calc((100% - var(--snooker-dock-width) - var(--snooker-fit-width, calc(100% - 108px))) / 2)) !important;
    overflow: auto !important;
    aspect-ratio: 1120 / 612 !important;
    align-self: center !important;
  }
  body[data-game="snooker"] #club-shell.game-shell #canvas-wrap {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    aspect-ratio: 1120 / 612 !important;
  }
  body[data-game="snooker"] #club-shell.game-shell:has(#zoom-button[aria-pressed="true"]) #canvas-wrap {
    width: 180% !important;
    height: auto !important;
  }
  body[data-game="snooker"] #club-shell.game-shell #snooker-mobile-cue {
    display: flex !important;
    position: absolute !important;
    inset: auto !important;
    top: var(--snooker-dock-top) !important;
    bottom: var(--snooker-dock-bottom) !important;
    right: 56px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 6px 3px !important;
    align-self: stretch !important;
    z-index: 8 !important;
    border-radius: 12px !important;
  }
  body[data-game="snooker"] #club-shell.game-shell .mobile-cue-track {
    flex: 1 1 auto;
    min-height: 38px;
    margin: 5px 0;
  }
  body[data-game="snooker"] #club-shell.game-shell .mobile-cue-handle {
    width: 9px;
    height: 28px;
    top: clamp(14px, calc(var(--cue-pull, 0) * 100%), calc(100% - 14px));
    transition: top 45ms linear;
  }
  body[data-game="snooker"] #club-shell.game-shell .mobile-cue-fill { height: 0; transition: height 45ms linear; }
  body[data-game="snooker"] #club-shell.game-shell .control-strip {
    position: absolute !important;
    top: calc(var(--snooker-dock-top) + 4px) !important;
    bottom: var(--snooker-dock-bottom) !important;
    right: 6px !important;
    left: auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    width: 44px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    z-index: 8 !important;
  }
  body[data-game="snooker"] #club-shell.game-shell .fine-controls { display: flex; flex-direction: column; gap: 8px; }
  body[data-game="snooker"] #club-shell.game-shell .fine-controls button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    font-size: 32px !important;
    line-height: 1 !important;
    border-radius: 11px;
  }
  body[data-game="snooker"] #club-shell.game-shell .control-strip .power-control,
  body[data-game="snooker"] #club-shell.game-shell #shoot-button,
  body[data-game="snooker"] #club-shell.game-shell .shot-help { display: none !important; }
  body[data-game="snooker"] #club-shell.game-shell .spin-wrap { display: flex; flex-direction: column; margin: 0 !important; gap: 3px; }
  body[data-game="snooker"] #club-shell.game-shell .spin-pad { width: 40px; height: 40px; }
  body[data-game="snooker"] #club-shell.game-shell .spin-pad::before,
  body[data-game="snooker"] #club-shell.game-shell .spin-pad::after { top: 20px; }
  body[data-game="snooker"] #club-shell.game-shell .table-topbar { display: contents !important; }
  body[data-game="snooker"] #club-shell.game-shell .table-tools {
    position: absolute !important;
    right: 6px !important;
    bottom: 6px !important;
    display: grid !important;
    grid-template-columns: 44px 44px;
    gap: 6px !important;
    width: 94px;
    z-index: 9;
  }
  body[data-game="snooker"] #club-shell.game-shell .table-tools > button { display: none !important; }
  body[data-game="snooker"] #club-shell.game-shell .table-tools #pause-button,
  body[data-game="snooker"] #club-shell.game-shell .table-tools #mobile-settings-toggle {
    display: grid !important;
    position: static !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 11px;
    font-size: 20px;
    place-items: center;
  }
  body[data-game="snooker"] #club-shell.game-shell .ball-on {
    position: absolute;
    right: 6px;
    top: 88px;
    display: flex;
    justify-content: center;
    gap: 5px;
    width: 94px;
    height: 18px;
    font-size: 10px;
    z-index: 8;
  }
  body[data-game="snooker"] #club-shell.game-shell .ball-on .label { display: none; }
  body[data-game="snooker"] #club-shell.game-shell > .scoreboard {
    position: absolute !important;
    top: 51px !important;
    right: 6px !important;
    left: auto !important;
    bottom: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important;
    gap: 6px !important;
    width: 94px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    z-index: 8;
  }
  body[data-game="snooker"] #club-shell.game-shell .scoreboard .player { display: flex; flex-direction: column; justify-content: center; gap: 0 !important; }
  body[data-game="snooker"] #club-shell.game-shell .scoreboard .player .name { max-width: 44px; font-size: 8px !important; text-align: center; }
  body[data-game="snooker"] #club-shell.game-shell .scoreboard .player .score { font-size: 18px !important; line-height: 1; }
  body[data-game="snooker"] #club-shell.game-shell .scoreboard .player.active::after { bottom: -3px !important; }
  body[data-game="snooker"] #club-shell.game-shell .scoreboard :is(.frame-info,.avatar,.meta),
  body[data-game="snooker"] #club-shell.game-shell .sidebar,
  body[data-game="snooker"] #club-shell.game-shell .table-status,
  body[data-game="snooker"] #club-shell.game-shell .bottom-note,
  body[data-game="snooker"] #club-shell.game-shell #snooker-reaction-bar,
  body[data-game="snooker"] #club-shell.game-shell #snooker-turn-timer,
  body[data-game="snooker"] #club-shell.game-shell #arcade-fs-diff-bar { display: none !important; }
  body[data-game="snooker"] #club-shell.game-shell #online-hud-bar:not([hidden]) { position: absolute; top: 103px; right: 6px; width: 94px; justify-content: center; z-index: 8; }
  body[data-game="snooker"] #club-shell.game-shell #online-room-pill { display: none; }
  body[data-game="snooker"] #club-shell.game-shell #online-clock-badge { padding: 0 5px; font-size: 9px; min-height: 12px; }
  body[data-game="snooker"] #club-shell.game-shell #mobile-game-info-badge {
    display: contents !important;
    position: static !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  body[data-game="snooker"] #club-shell.game-shell #mobile-game-info-badge .mobile-header-left { display: contents !important; }
  body[data-game="snooker"] #club-shell.game-shell #mobile-game-info-badge .mobile-header-title-wrap,
  body[data-game="snooker"] #club-shell.game-shell #mobile-game-info-badge .mobile-header-right { display: none !important; }
  body[data-game="snooker"] #club-shell.game-shell #mobile-game-info-badge #mobile-app-back-btn {
    display: grid !important;
    position: absolute !important;
    inset: auto !important;
    top: max(5px, env(safe-area-inset-top)) !important;
    right: max(6px, env(safe-area-inset-right)) !important;
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    font-size: 24px;
    z-index: 70 !important;
    place-items: center;
  }
  body[data-game="snooker"] #club-shell.game-shell #snooker-mobile-menu {
    top: auto !important;
    bottom: 7px !important;
    right: 110px !important;
    width: min(260px, calc(100% - 124px));
    max-height: calc(100% - 14px);
    grid-template-columns: 1fr 1fr;
  }
  body[data-game="snooker"] #club-shell.game-shell #snooker-mobile-menu button { min-height: 42px; }
  body[data-game="snooker"] #club-shell.game-shell #snooker-play-alert { left: calc((100% - var(--snooker-dock-width)) / 2); max-width: calc(100% - 130px); }

  body[data-game="snooker"] #club-shell.game-shell.force-landscape-rotate {
    inset: auto !important;
    top: 50% !important;
    left: 50% !important;
    width: 100dvh !important;
    height: 100dvw !important;
    max-width: none !important;
    max-height: none !important;
  }
}

@media (orientation: landscape) and (max-height: 340px) {
  body[data-game="snooker"] #club-shell.game-shell { --snooker-dock-top: 108px; }
  body[data-game="snooker"] #club-shell.game-shell .spin-wrap { display: none; }
  body[data-game="snooker"] #club-shell.game-shell .control-strip { gap: 5px !important; }
}
